diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/kk.yaml b/kk.yaml new file mode 100644 index 0000000..654c88b --- /dev/null +++ b/kk.yaml @@ -0,0 +1,91 @@ +version: "3.4" +services: + tdarr: + lxc_name: tdarr + image: ghcr.io/haveagitgat/tdarr:latest + restart: unless-stopped + network_mode: bridge + ports: + - 8265:8265 # webUI port + - 8266:8266 # server port + environment: + - TZ=Europe/Rome + - PUID=${PUID} + - PGID=${PGID} + - UMASK_SET=002 + - serverIP=0.0.0.0 + - serverPort=8266 + - webUIPort=8265 + - internalNode=true + - inContainer=true + - ffmpegVersion=7 + - nodeName=MyInternalNode + - auth=false + - openBrowser=true + - maxLogSizeMB=10 + - cronPluginUpdate= + # - NVIDIA_DRIVER_CAPABILITIES=all + # - NVIDIA_VISIBLE_DEVICES=all + volumes: + - /docker/tdarr/server:/app/server + - /docker/tdarr/configs:/app/configs + - /docker/tdarr/logs:/app/logs + - /media:/media + - /transcode_cache:/temp + + # devices: + # - /dev/dri:/dev/dri + # deploy: + # resources: + # reservations: + # devices: + # - driver: nvidia + # count: all + # capabilities: [gpu] + + +# node example + tdarr-node: + lxc_name: tdarr-node + image: ghcr.io/haveagitgat/tdarr_node:latest + restart: unless-stopped + network_mode: service:tdarr + environment: + - TZ=Europe/Rome + - PUID=${PUID} + - PGID=${PGID} + - UMASK_SET=002 + - nodeName=MyExternalNode + - serverIP=0.0.0.0 + - serverPort=8266 + - inContainer=true + - ffmpegVersion=7 + - nodeType=mapped + - priority=-1 + - cronPluginUpdate= + - apiKey= + - maxLogSizeMB=10 + - pollInterval=2000 + - startPaused=false + - transcodegpuWorkers=1 + - transcodecpuWorkers=2 + - healthcheckgpuWorkers=1 + - healthcheckcpuWorkers=1 + # - NVIDIA_DRIVER_CAPABILITIES=all + # - NVIDIA_VISIBLE_DEVICES=all + + volumes: + - /docker/tdarr/configs:/app/configs + - /docker/tdarr/logs:/app/logs + - /media:/media + - /transcode_cache:/temp + + # devices: + # - /dev/dri:/dev/dri + # deploy: + # resources: + # reservations: + # devices: + # - driver: nvidia + # count: all + # capabilities: [gpu] \ No newline at end of file diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..ac68e74 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,16 @@ +[platformio] +description = Audio Example +default_envs = esp32dev + +[env:esp32dev] +platform = https://github.com/platformio/platform-espressif32.git +board = esp32dev +framework = arduino +lib_deps = + https://github.com/pschatzmann/arduino-audio-tools.git + https://github.com/pschatzmann/arduino-audio-driver.git + https://github.com/pschatzmann/arduino-midi.git +build_flags = -DCORE_DEBUG_LEVEL=5 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format-extra-args +monitor_speed = 115200 +monitor_filters = esp32_exception_decoder +board_build.partitions = huge_app.csv \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..a90688e --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,78 @@ +// or LyratV42,LyratV43,AudioKitAC101,AudioKitEs8388V1,AudioKitEs8388V2 + +#include "AudioTools.h" +#include "AudioTools/AudioLibs/AudioBoardStream.h" +#include "AudioTools/AudioLibs/AudioRealFFT.h" // or AudioKissFFT +#include + +MidiBleServer ble("MidiServer"); +MidiCallbackAction action; + +AudioBoardStream kit(AudioKitEs8388V1); // Audio source +AudioRealFFT fft; // or AudioKissFFT +StreamCopy copier(fft, kit); // copy mic to tfl +int channels = 2; +int samples_per_second = 44100; +int bits_per_sample = 16; +float value=0; +int midi_note; +int prev_note; +int amplitude=50; + +int freqToMidi(float frequency) { + if (frequency <= 0) return -1; // Error case + return round(69 + 12 * log(frequency / 440.0) / log(2)); + } + +// display fft result +void fftResult(AudioFFTBase &fft){ + float diff; + auto result = fft.result(); + if (result.magnitude>100000){ + Serial.print(result.frequency); + Serial.print(" "); + Serial.print(result.magnitude); + Serial.print(" => "); + Serial.print(result.frequencyAsNote(diff)); + Serial.print( " diff: "); + Serial.println(diff); + midi_note == freqToMidi(result.frequency); + if (midi_note != prev_note){ + ble.noteOff( prev_note, 20 ); + prev_note = midi_note; + ble.noteOn(midi_note, amplitude ); + } + + } +} + +void setup() { + Serial.begin(115200); + AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); + + ble.begin(action); + + // ble.begin(); + ble.setDefaultSendingChannel(0); + + // setup Audiokit + auto cfg = kit.defaultConfig(RX_MODE); + cfg.input_device = ADC_INPUT_LINE2; + cfg.channels = channels; + cfg.sample_rate = samples_per_second; + cfg.bits_per_sample = bits_per_sample; + kit.begin(cfg); + + // Setup FFT + auto tcfg = fft.defaultConfig(); + tcfg.length = 8192; + tcfg.channels = channels; + tcfg.sample_rate = samples_per_second; + tcfg.bits_per_sample = bits_per_sample; + tcfg.callback = &fftResult; + fft.begin(tcfg); +} + +void loop() { + copier.copy(); +} \ No newline at end of file