This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
see [Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/Examples)

View File

@@ -0,0 +1,154 @@
# ESP32 Configuration
If you are using ESP32 by Espressif Systems version 3.0.0 and later, audio tools will use the new adc_continuous API.
For the adc_continuous API, audio tools provides the following options:
- **sample_rate** (per channel), the effective ADC sampling rate is the number of channels x sample rate and can be:
- ESP32: 20kHz to 2MHz
- ESP32 S2, S3, H2, C6, C3: 611Hz to 83.333kHz
for example:
- 306
- 4,000
- 5,000
- 8,000
- 10,000
- 11,025
- 16,000
- 20,000
- 22,050
- 40,000
- 44,100
- 48,000
- 88,200
- 96,000
- 176,400
- 192,200
- 352,800
- 384,000
- 500,000
- 1,000,000
- **adc_bit_with**
- 9, 10, 11, 12 depending on ESP32 model
- audio stream is int16_t
- **adc_calibration_active**: values measured are in mV
- **is_auto_center_read**: subtraction of current estimated average from samples
- **adc_attenuation**:
| attenuation | range | accurate range |
| ------------ | --------| -------------- |
| ADC_ATTEN_DB_0 | 0..1.1V | 100-950mV |
| ADC_ATTEN_DB_2_5| 0..1.5V | 100-1250mV |
| ADC_ATTEN_DB_6 | 0..2.2V | 150-1750mV |
| ADC_ATTEN_DB_12 | 0..3.9V | 150-2450mV |
- **channels**:
- mono = 1
- stereo = 2
- **adc_channels**: defining the channels (only channels on ADC unit 1 are supported) e.g.:
- A3 on Sparkfun ESP32 Thing Plus is ADC_CHANNEL_3
- A4 on Sparkfun ESP32 Thing Plus is ADC_CHANNEL_0
- D5 on Adafruit ESP32-S3 is ADC_CHANNEL_4
- D6 on Adafruit ESP32-S3 is ADC_CHANNEL_5
- **buffer_size**
- maximum is 2048
- minimum is number of channels
- number needs to be divisible by number of channels
- care must be taken because some streams in audio tools can not exceed 1024 bytes
## Example Configuration
```
auto adcConfig = adc.defaultConfig(RX_MODE);
adcConfig.sample_rate = 44100;
adcConfig.adc_bit_width = 12;
adcConfig.adc_calibration_active = true;
adcConfig.is_auto_center_read = false;
adcConfig.adc_attenuation = ADC_ATTEN_DB_12;
adcConfig.channels = 2;
adcConfig.adc_channels[0] = ADC_CHANNEL_4;
adcConfig.adc_channels[1] = ADC_CHANNEL_5;
```
## ADC unit 1 channels on common ESP32 boards
Audio tools continuous ADC framework supports ADC Unit 1 only.
### Sparkfun ESP32 Thing Plus (ESP32)
- A2, ADC1_CH6
- A3, ADC1_CH3
- A4, ADC1_CH0
- 32, ADC1_CH4
- 33, ADC1_CH5
### Sparkfun ESP32 Thing Plus C (ESP32)
- A2, ADC1_CH6
- A3, ADC1_CH3
- A4, ADC1_CH0
- A5, ADC1_CH7
- 32/6, ADC1_CH4
- 33/10, ADC1_CH5
### Sparkfun ESP32 Qwiic Pocket Development (ESP32C6)
- 2, ADC1_CH2
- 3, ADC1_CH3
- 4, ADC1_CH4
- 5, ADC1_CH5
### ESP32-C6-DevKit
- 4, ADC1_CH4
- 5, ADC1_CH5
- 6, ADC1_CH6
- 7, ADC1_CH0
- 0, ADC1_CH1
- 2, ADC1_CH2
- 3, ADC1_CH3
### ESP32-H2-DevKit
- 1, ADC1_CH0
- 2, ADC1_CH1
- 3, ADC1_CH2
- 4, ADC1_CH3
- 5, ADC1_CH4
### ESP32­-S3­-DevKit
- 1, ADC1_CH0
- 2, ADC1_CH1
- 4, ADC1_CH3
- 5, ADC1_CH4
- 6, ADC1_CH5
- 7, ADC1_CH6
- 8, ADC1_CH7
- 3, ADC1_CH2
- 9, ADC1_CH8
- 10, ADC1_CH9
### ESP32-C3-DevKit
- 4, IO2, ADC1_CH2
- 5, IO3, ADC1_CH3
- 9, IO0, ADC1_CH0
- 10, IO1, ADC1_CH1
- 11, IO4, ADC1_CH4
### Adafruit ESP32 Feather V2
- D32, ADC1_CH4
- D33, ADC1_CH5
- A2, ADC1_CH6
- A3, ADC1_CH3
- A4, ADC1_CH0
- D37, ADC1_CH1
### Adafruit ESP32-S3 Feather
- D5, ADC1_CH4
- D6, ADC1_CH5
- D9, ADC1_CH8
- D10, ADC1_CH9
- A5, ADC1_CH7
### Adafruit QT Py ESP32-C3
- A0, ADC1-CH4
- A1, ADC1-CH3
- A2, ADC1-CH1
- A3, ADC1-CH0

View File

@@ -0,0 +1,18 @@
esp32:esp32:esp32 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32c3 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32c5 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32c6 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32s2 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32s3 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32h2 ./examples-stream/streams-generator-serial -> rc=0
esp32:esp32:esp32p4 ./examples-stream/streams-generator-serial -> rc=0
esp8266:esp8266:generic ./examples-stream/streams-generator-serial -> rc=0
rp2040:rp2040:generic ./examples-stream/streams-generator-serial -> rc=0
arduino:avr:nano ./examples-stream/streams-generator-serial -> rc=0
arduino:samd:arduino_zero_native ./examples-stream/streams-generator-serial -> rc=0
arduino:renesas_uno:unor4wifi ./examples-stream/streams-generator-serial -> rc=0
arduino:mbed_nano:nano33ble ./examples-stream/streams-generator-serial -> rc=0
arduino:mbed_rp2040:pico ./examples-stream/streams-generator-serial -> rc=0
arduino:mbed_giga:giga ./examples-stream/streams-generator-serial -> rc=0
arduino:zephyr:nano33ble ./examples-stream/streams-generator-serial -> rc=0
STMicroelectronics:stm32:GenF4 ./examples-stream/streams-generator-serial -> rc=0

View File

@@ -0,0 +1,41 @@
#!/bin/bash
##
# We compile an example for different architectures using arduino-cli in order to identify compile errors
# The return codes are made available in the build-examples-log.txt file.
# -> rc=0: success
# -> rc=1: error
##
git -C .. pull
git -C ../../ESP32-A2DP pull
function compile_example {
ARCH=$1
FILE="./examples-stream/streams-generator-serial"
# take action on each file. $f store current file name
arduino-cli compile -b "$ARCH" "$FILE"
EC=$?
echo -e "$ARCH $FILE -> rc=$EC" >> "build-arch-log.txt"
}
rm build-arch-log.txt
compile_example "esp32:esp32:esp32"
compile_example "esp32:esp32:esp32c3"
compile_example "esp32:esp32:esp32c5"
compile_example "esp32:esp32:esp32c6"
compile_example "esp32:esp32:esp32s2"
compile_example "esp32:esp32:esp32s3"
compile_example "esp32:esp32:esp32h2"
compile_example "esp32:esp32:esp32p4"
compile_example "esp8266:esp8266:generic"
compile_example "rp2040:rp2040:generic"
compile_example "arduino:avr:nano"
compile_example "arduino:samd:arduino_zero_native"
compile_example "arduino:renesas_uno:unor4wifi"
compile_example "arduino:mbed_nano:nano33ble"
compile_example "arduino:mbed_rp2040:pico"
compile_example "arduino:mbed_giga:giga"
compile_example "arduino:zephyr:nano33ble"
compile_example "STMicroelectronics:stm32:GenF4"
./cleanup.sh

View File

@@ -0,0 +1,353 @@
../examples/examples-basic-api/base-adc-average-mono-serial -> rc=0
../examples/examples-basic-api/base-adc-measure -> rc=0
../examples/examples-basic-api/base-adc-serial -> rc=0
../examples/examples-basic-api/base-file_raw-serial -> rc=0
../examples/examples-basic-api/base-SynchronizedBufferRTOS -> rc=0
../examples/examples-player/player-callback-i2s -> rc=0
../examples/examples-player/player-ftp-audiokit -> rc=0
../examples/examples-player/player-littlefs-i2s -> rc=0
../examples/examples-player/player-sd-audiokit -> rc=0
../examples/examples-player/player-sdfat-analog -> rc=0
../examples/examples-player/player-sdfat-audiokit -> rc=0
../examples/examples-player/player-sdfat-ffti2s -> rc=0
../examples/examples-player/player-sdfat-i2s -> rc=0
../examples/examples-player/player-sd-i2s -> rc=0
../examples/examples-player/player-sd_m4a-audiokit -> rc=0
../examples/examples-player/player-sdmmc-audiokit -> rc=0
../examples/examples-player/player-spiffs-i2s -> rc=0
../examples/examples-player/player-vector_sdfat-audiokit -> rc=0
../examples/examples-stream/streams-adc-i2s -> rc=0
../examples/examples-stream/streams-adc-serial -> rc=0
../examples/examples-stream/streams-adsr-i2s -> rc=0
../examples/examples-stream/streams-generator-analog -> rc=0
../examples/examples-stream/streams-generator-bin-serial -> rc=0
../examples/examples-stream/streams-generator-formatconverter-i2s -> rc=0
../examples/examples-stream/streams-generator_fromarray-analog -> rc=0
../examples/examples-stream/streams-generator-i2s -> rc=0
../examples/examples-stream/streams-generator-merge-pwm -> rc=0
../examples/examples-stream/streams-generator-pwm -> rc=0
../examples/examples-stream/streams-generator-r2r -> rc=0
../examples/examples-stream/streams-generator-serial -> rc=0
../examples/examples-stream/streams-generator-spdif -> rc=0
../examples/examples-stream/streams-generator-timedstream-serial -> rc=0
../examples/examples-stream/streams-generator-volume -> rc=0
../examples/examples-stream/streams-generator-wm8960 -> rc=0
../examples/examples-stream/streams-i2s-filter-i2s -> rc=0
../examples/examples-stream/streams-i2s-i2s -> rc=0
../examples/examples-stream/streams-i2s-i2s-2 -> rc=0
../examples/examples-stream/streams-i2s_pdm-serial -> rc=0
../examples/examples-stream/streams-i2s-serial -> rc=0
../examples/examples-stream/streams-i2s-serial_16bit -> rc=0
../examples/examples-stream/streams-i2s-tf -> rc=0
../examples/examples-stream/streams-memory_mp3-analog -> rc=0
../examples/examples-stream/streams-memory_mp3-metadata -> rc=0
../examples/examples-stream/streams-memory_mp3-pwm -> rc=0
../examples/examples-stream/streams-memory_mp3_short-i2s -> rc=0
../examples/examples-stream/streams-memory_mp3_short-i2s-2 -> rc=0
../examples/examples-stream/streams-memory_raw-i2s -> rc=0
../examples/examples-stream/streams-memory_wav-pwm -> rc=0
../examples/examples-stream/streams-memory_wav-serial -> rc=0
../examples/examples-stream/streams-mp34dt05-serial -> rc=1
../examples/examples-stream/streams-sdfat_mp3-metadata -> rc=0
../examples/examples-stream/streams-sd_mp3-i2s -> rc=0
../examples/examples-stream/streams-sd_wav4-i2s -> rc=0
../examples/examples-stream/streams-tf-i2s -> rc=0
../examples/examples-audiokit/streams-audiokit-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-effects-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-fft -> rc=0
../examples/examples-audiokit/streams-audiokit-fft-led -> rc=0
../examples/examples-audiokit/streams-audiokit-filter-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-goertzel -> rc=0
../examples/examples-audiokit/streams-audiokit-multioutput -> rc=0
../examples/examples-audiokit/streams-audiokit-multioutput-server -> rc=0
../examples/examples-audiokit/streams-audiokit-ram-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-ram-ptichshift-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-sd-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-sd_wav -> rc=0
../examples/examples-audiokit/streams-audiokit-serial -> rc=0
../examples/examples-audiokit/streams-audiokit-tf -> rc=0
../examples/examples-audiokit/streams-file_loop-audiokit -> rc=0
../examples/examples-audiokit/streams-generator-audiokit -> rc=0
../examples/examples-audiokit/streams-generator_fromarray-audiokit -> rc=0
../examples/examples-audiokit/streams-generator_inputmixer-audiokit -> rc=0
../examples/examples-audiokit/streams-generator_outputmixer-audiokit -> rc=0
../examples/examples-audiokit/streams-generator_sinfromtable-audiokit -> rc=0
../examples/examples-audiokit/streams-memory_mp3-audiokit -> rc=0
../examples/examples-audiokit/streams-memory_pcm-mixer-audiokit -> rc=0
../examples/examples-audiokit/streams-pins-audiokit -> rc=0
../examples/examples-audiokit/streams-rtttl-audiokit -> rc=0
../examples/examples-audiokit/streams-sd_flac-audiokit -> rc=0
../examples/examples-audiokit/streams-sd_m4a-audiokit -> rc=0
../examples/examples-audiokit/streams-sdmmc_wav-audiokit -> rc=0
../examples/examples-audiokit/streams-sd_mp3-audiokit -> rc=0
../examples/examples-audiokit/streams-synth-audiokit -> rc=0
../examples/examples-audiokit/streams-synthbasic1-audiokit -> rc=0
../examples/examples-audiokit/streams-synthbasic2-audiokit -> rc=0
../examples/examples-audiokit/streams-synthbasic3-audiokit -> rc=0
../examples/examples-audiokit/streams-synthstk-audiokit -> rc=0
../examples/examples-audiokit/streams-tf-audiokit -> rc=0
../examples/examples-tts/streams-azure_tts-i2s -> rc=0
../examples/examples-tts/streams-espeak-audiokit -> rc=0
../examples/examples-tts/streams-espeak-i2s -> rc=0
../examples/examples-tts/streams-flite-audiokit -> rc=0
../examples/examples-tts/streams-flite-i2s -> rc=0
../examples/examples-tts/streams-google-audiokit -> rc=0
../examples/examples-tts/streams-sam-audiokit -> rc=0
../examples/examples-tts/streams-sam-i2s -> rc=0
../examples/examples-tts/streams-simple_tts-a2dp -> rc=0
../examples/examples-tts/streams-simple_tts-i2s -> rc=0
../examples/examples-tts/streams-talkie-a2dp -> rc=0
../examples/examples-tts/streams-talkie-audiokit -> rc=0
../examples/examples-tts/streams-tts-i2s -> rc=0
../examples/examples-tts/streams-url_wav-i2s -> rc=0
../examples/examples-dsp/examples-maximilian/01-TestTone -> rc=0
../examples/examples-dsp/examples-maximilian/02-TwoTones -> rc=0
../examples/examples-dsp/examples-maximilian/03-AM1 -> rc=0
../examples/examples-dsp/examples-maximilian/04-AM2 -> rc=0
../examples/examples-dsp/examples-maximilian/05-FM1 -> rc=0
../examples/examples-dsp/examples-maximilian/06-FM2 -> rc=0
../examples/examples-dsp/examples-maximilian/07-Counting1 -> rc=0
../examples/examples-dsp/examples-maximilian/08-Counting2 -> rc=0
../examples/examples-dsp/examples-maximilian/08-Counting3 -> rc=0
../examples/examples-dsp/examples-maximilian/08-Counting4 -> rc=0
../examples/examples-dsp/examples-maximilian/09-Envelopes -> rc=0
../examples/examples-dsp/examples-maximilian/10-Filters -> rc=0
../examples/examples-dsp/examples-maximilian/11-Mixing -> rc=0
../examples/examples-dsp/examples-maximilian/12-SamplePlayer -> rc=0
../examples/examples-dsp/examples-maximilian/13-AdvancedFilters -> rc=0
../examples/examples-dsp/examples-maximilian/14-MonoSynth -> rc=0
../examples/examples-dsp/examples-maximilian/15-PolySynth -> rc=0
../examples/examples-dsp/examples-maximilian/16-Replicant -> rc=0
../examples/examples-dsp/examples-maximilian/17-Compressor -> rc=0
../examples/examples-dsp/examples-maximilian/18-DrumMachine -> rc=0
../examples/examples-dsp/examples-maximilian/19-Enveloping2 -> rc=0
../examples/examples-dsp/examples-maximilian/20-FFT -> rc=0
../examples/examples-dsp/examples-mozzi/audio_input -> rc=0
../examples/examples-dsp/examples-mozzi/control_gain -> rc=0
../examples/examples-dsp/examples-mozzi/control_gain-a2dp -> rc=0
../examples/examples-dsp/examples-pd/streams-generator-pd-audiokit -> rc=0
../examples/examples-dsp/examples-pd/streams-pd-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_allinstruments-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk-desktop -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_files-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_generator-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_loop-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_myinstrument-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_sine-audiokit -> rc=0
../examples/examples-dsp/examples-stk/streams-stk_synth-audiokit -> rc=0
../examples/examples-dsp/examples-faust/streams-faust_flute-i2s -> rc=0
../examples/examples-dsp/examples-faust/streams-faust_noise-i2s -> rc=0
../examples/examples-dsp/examples-faust/streams-generator-faust-i2s -> rc=0
../examples/examples-dsp/examples-faust/streams-i2s-faust_copy-i2s -> rc=0
../examples/examples-dsp/examples-faust/streams-i2s-faust_guitarix-i2s -> rc=0
../examples/examples-dsp/examples-faust/streams-i2s-faust_pitchshift-i2s -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-audiokit -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-eq-audiokit -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-fft -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-fft-led -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-i2s -> rc=0
../examples/examples-communication/a2dp/basic-a2dp-mixer-i2s -> rc=0
../examples/examples-communication/a2dp/basic-adc-a2dp -> rc=0
../examples/examples-communication/a2dp/basic-audiokit-a2dp -> rc=0
../examples/examples-communication/a2dp/basic-file_mp3-a2dp -> rc=0
../examples/examples-communication/a2dp/basic-generator-a2dp -> rc=0
../examples/examples-communication/a2dp/basic-i2s-a2dp -> rc=0
../examples/examples-communication/a2dp/basic-player-a2dp -> rc=0
../examples/examples-communication/a2dp/player-sd_a2dp-audiokit -> rc=0
../examples/examples-communication/a2dp/player-sdfat-a2dp -> rc=0
../examples/examples-communication/a2dp/streams-a2dp-audiokit -> rc=0
../examples/examples-communication/a2dp/streams-a2dp-serial -> rc=0
../examples/examples-communication/a2dp/streams-a2dp-spdif -> rc=0
../examples/examples-communication/a2dp/streams-generator-a2dp -> rc=0
../examples/examples-communication/a2dp/streams-i2s-a2dp -> rc=0
../examples/examples-communication/a2dp/streams-synth-a2dp -> rc=0
../examples/examples-communication/esp-now/codec/communication-codec-espnow-receive -> rc=0
../examples/examples-communication/esp-now/codec/communication-codec-espnow-receive_measure -> rc=0
../examples/examples-communication/esp-now/codec/communication-codec-espnow-send -> rc=0
../examples/examples-communication/esp-now/pcm/communication-espnow-receive -> rc=0
../examples/examples-communication/esp-now/pcm/communication-espnow-receive_csv -> rc=0
../examples/examples-communication/esp-now/pcm/communication-espnow-receive_measure -> rc=0
../examples/examples-communication/esp-now/pcm/communication-espnow-send -> rc=0
../examples/examples-communication/esp-now/speed-test/communication-espnow-receive_measure -> rc=0
../examples/examples-communication/esp-now/speed-test/communication-espnow-send -> rc=0
../examples/examples-communication/ip/communication-ip-receive -> rc=0
../examples/examples-communication/ip/communication-ip-receive_measure -> rc=0
../examples/examples-communication/ip/communication-ip-send -> rc=0
../examples/examples-communication/udp/communication-udp-receive -> rc=0
../examples/examples-communication/udp/communication-udp-send -> rc=0
../examples/examples-communication/vban/player-sdmmc-vban -> rc=0
../examples/examples-communication/vban/streams-audiokit-vban -> rc=0
../examples/examples-communication/vban/streams-generator-vban -> rc=0
../examples/examples-communication/vban/streams-vban-audiokit -> rc=0
../examples/examples-communication/rtsp/communication-audiokit-rtsp -> rc=0
../examples/examples-communication/rtsp/communication-codec-rtsp -> rc=1
../examples/examples-communication/rtsp/communication-generator-rtsp -> rc=0
../examples/examples-communication/rtsp/communication-player_mp3-rtsp -> rc=0
../examples/examples-communication/rtsp/communication-player_mp3-rtsp_adcpm -> rc=0
../examples/examples-communication/rtsp/communication-rtsp555-audiokit -> rc=0
../examples/examples-communication/rtsp/communication-rtsp555-i2s -> rc=0
../examples/examples-communication/rtsp/communication-rtsp-audiokit -> rc=0
../examples/examples-communication/serial/mp3 -> rc=1
../examples/examples-communication/serial/mp3-custom -> rc=1
../examples/examples-communication/serial/mp3-xon-xoff -> rc=1
../examples/examples-communication/serial/send-8bit-receive -> rc=0
../examples/examples-communication/serial/send-adpcm_framed-receive -> rc=0
../examples/examples-communication/serial/send-adpcm-receive -> rc=0
../examples/examples-communication/serial/send-receive -> rc=0
../examples/examples-communication/snapcast/snapclient-i2s -> rc=0
../examples/examples-communication/http-client/player-url-i2s -> rc=0
../examples/examples-communication/http-client/player-url_icy-audiokit -> rc=0
../examples/examples-communication/http-client/player-url_icy-i2s -> rc=0
../examples/examples-communication/http-client/player-url_subclass-i2s -> rc=0
../examples/examples-communication/http-client/streams-eth_url_mp3_helix-i2s -> rc=0
../examples/examples-communication/http-client/streams-http_post -> rc=0
../examples/examples-communication/http-client/streams-url_aac-audiokit -> rc=0
../examples/examples-communication/http-client/streams-url_aac-i2s -> rc=0
../examples/examples-communication/http-client/streams-url-file -> rc=0
../examples/examples-communication/http-client/streams-url_flac_foxen-i2s -> rc=0
../examples/examples-communication/http-client/streams-url_flac-i2s -> rc=0
../examples/examples-communication/http-client/streams-url-measuring -> rc=0
../examples/examples-communication/http-client/streams-url_mp3-analog -> rc=0
../examples/examples-communication/http-client/streams-url_mp3-audiokit -> rc=0
../examples/examples-communication/http-client/streams-url_mp3_helix-i2s -> rc=0
../examples/examples-communication/http-client/streams-url_mp3_helix-i2s_32bit -> rc=0
../examples/examples-communication/http-client/streams-url_mp3_mad-i2s -> rc=0
../examples/examples-communication/http-client/streams-url_mp3-metadata -> rc=0
../examples/examples-communication/http-client/streams-url_mp3-metadata2 -> rc=0
../examples/examples-communication/http-client/streams-url_mp3-pwm -> rc=0
../examples/examples-communication/http-client/streams-url_mts-hex -> rc=0
../examples/examples-communication/http-client/streams-url_post -> rc=0
../examples/examples-communication/http-client/streams-url_raw-i2s -> rc=0
../examples/examples-communication/http-client/streams-url_raw-serial -> rc=0
../examples/examples-communication/http-client/streams-url_vorbis_i2s -> rc=0
../examples/examples-communication/http-server/player-sd-webserverex_mp3 -> rc=0
../examples/examples-communication/http-server/python-post-server -> rc=1
../examples/examples-communication/http-server/streams-audiokit-webserver_aac -> rc=0
../examples/examples-communication/http-server/streams-audiokit-webserver_mp3 -> rc=0
../examples/examples-communication/http-server/streams-audiokit-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-effect-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-flite-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-generator-webserver_aac -> rc=0
../examples/examples-communication/http-server/streams-generator-webserverex_wav -> rc=0
../examples/examples-communication/http-server/streams-generator-webserverex_wav1 -> rc=0
../examples/examples-communication/http-server/streams-generator-webserver_mp3 -> rc=0
../examples/examples-communication/http-server/streams-generator-webserver_ogg -> rc=0
../examples/examples-communication/http-server/streams-generator-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-i2s-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-sam-webserver_wav -> rc=0
../examples/examples-communication/http-server/streams-tts-webserver_wav -> rc=0
../examples/tests/adc/read-csv -> rc=0
../examples/tests/adc/read-csv_unsigned -> rc=0
../examples/tests/adc/read-esp32-multi-channel-csv -> rc=0
../examples/tests/adc/read-speed -> rc=0
../examples/tests/basic/24bits-write -> rc=0
../examples/tests/basic/test-allocator -> rc=0
../examples/tests/basic/test-buffer -> rc=0
../examples/tests/basic/test-buffered-stream -> rc=0
../examples/tests/basic/test-queue -> rc=0
../examples/tests/basic/test-vector -> rc=0
../examples/tests/codecs/test-codec-aac-fdk -> rc=0
../examples/tests/codecs/test-codec-aac-fdk-dec -> rc=0
../examples/tests/codecs/test-codec-adpcm -> rc=0
../examples/tests/codecs/test-codec-adpcm-xq -> rc=0
../examples/tests/codecs/test-codec-alac -> rc=0
../examples/tests/codecs/test-codec-aptx -> rc=0
../examples/tests/codecs/test-codec-base64 -> rc=0
../examples/tests/codecs/test-codec-codec2 -> rc=0
../examples/tests/codecs/test-codec-flac -> rc=0
../examples/tests/codecs/test-codec-g711_alaw -> rc=0
../examples/tests/codecs/test-codec-g711_ulaw -> rc=0
../examples/tests/codecs/test-codec-g721 -> rc=0
../examples/tests/codecs/test-codec-g722 -> rc=0
../examples/tests/codecs/test-codec-g723_24 -> rc=0
../examples/tests/codecs/test-codec-g723_40 -> rc=0
../examples/tests/codecs/test-codec-gsm -> rc=0
../examples/tests/codecs/test-codec-iLBC -> rc=0
../examples/tests/codecs/test-codec-l8 -> rc=0
../examples/tests/codecs/test-codec-lc3 -> rc=0
../examples/tests/codecs/test-codec-opus -> rc=0
../examples/tests/codecs/test-codec-opusogg -> rc=0
../examples/tests/codecs/test-codec-sbc -> rc=0
../examples/tests/codecs/test-codec-wav-adpcm -> rc=0
../examples/tests/codecs/test-compile-all -> rc=0
../examples/tests/codecs/test-container-binary -> rc=0
../examples/tests/codecs/test-container-binary-meta -> rc=0
../examples/tests/codecs/test-container-ogg -> rc=0
../examples/tests/codecs/test-memory-helix -> rc=0
../examples/tests/codecs/test-mp3-helix -> rc=0
../examples/tests/codecs/test-mp3-helix-reading -> rc=0
../examples/tests/codecs/test-mp3-mad -> rc=0
../examples/tests/codecs/test-mp3_parser -> rc=0
../examples/tests/codecs/test-streaming-adapter -> rc=0
../examples/tests/concurrency/audio-test -> rc=0
../examples/tests/concurrency/BufferRTOS -> rc=0
../examples/tests/concurrency/NBuffer -> rc=0
../examples/tests/concurrency/synchNBuffer -> rc=0
../examples/tests/concurrency/synchRingBuffer -> rc=0
../examples/tests/conversion/channel-converter-avg -> rc=0
../examples/tests/conversion/channel-converter-bin -> rc=0
../examples/tests/conversion/channel-converter-bindiff -> rc=0
../examples/tests/conversion/channel-converter-decimate -> rc=0
../examples/tests/conversion/channel-converter-diff -> rc=0
../examples/tests/conversion/channel-converter-increase-in -> rc=0
../examples/tests/conversion/channel-converter-increase-out -> rc=0
../examples/tests/conversion/channel-converter-reduce-in -> rc=0
../examples/tests/conversion/channel-converter-reduce-out -> rc=0
../examples/tests/conversion/format-converter-in -> rc=0
../examples/tests/conversion/numberformat-converter -> rc=0
../examples/tests/conversion/numberformat-converter-typed -> rc=0
../examples/tests/conversion/pipeline-in -> rc=0
../examples/tests/conversion/pipeline-out -> rc=0
../examples/tests/conversion/resample-mixer-in -> rc=0
../examples/tests/conversion/test-panning -> rc=0
../examples/tests/conversion/test-resample-in -> rc=0
../examples/tests/conversion/test-resample-out -> rc=0
../examples/tests/conversion/test-volumestream -> rc=0
../examples/tests/effects/delay-in -> rc=0
../examples/tests/effects/delay-out -> rc=0
../examples/tests/effects/pitch-shift -> rc=0
../examples/tests/effects/pitch-shift-180 -> rc=0
../examples/tests/effects/pitch-shift-simple -> rc=0
../examples/tests/etc/callback-write -> rc=0
../examples/tests/etc/test-mulit-compilation-units -> rc=0
../examples/tests/etc/test-pins -> rc=0
../examples/tests/etc/test-ringbufferfile -> rc=0
../examples/tests/etc/test-tdm -> rc=0
../examples/tests/etc/test-write-memory -> rc=0
../examples/tests/fft/fft-cmsis -> rc=1
../examples/tests/fft/fft-esp32 -> rc=0
../examples/tests/fft/fft-espressif -> rc=0
../examples/tests/fft/fft-ifft -> rc=0
../examples/tests/fft/fft-kiss -> rc=0
../examples/tests/fft/fft-real -> rc=0
../examples/tests/fft/fft-topn -> rc=0
../examples/tests/fft/fft-window -> rc=0
../examples/tests/filters/test-90deg -> rc=0
../examples/tests/filters/test-filter -> rc=0
../examples/tests/filters/test-lowpass -> rc=0
../examples/tests/filters/test-median-filter -> rc=0
../examples/tests/performance/file-speeds-sd -> rc=0
../examples/tests/performance/file-speeds-sdfat -> rc=0
../examples/tests/performance/file-speeds-sdmmc -> rc=0
../examples/tests/performance/file-speeds-vfssd -> rc=0
../examples/tests/performance/file-speeds-vfssdmmc -> rc=0
../examples/tests/performance/mp3-Speed -> rc=0
../examples/tests/performance/mp3-SynchronizedBufferRTOS -> rc=0
../examples/tests/performance/mp3-SynchronizedNBuffer -> rc=0
../examples/tests/performance/mp3-SynchronizedRingBuffer -> rc=0
../examples/tests/performance/sine -> rc=0
../examples/tests/performance/throttle -> rc=0
../examples/tests/performance/wifi -> rc=0
../examples/tests/player/test-array-source -> rc=0
../examples/tests/player/test-index-sd -> rc=0
../examples/tests/player/test-index-sdfat -> rc=0
../examples/tests/player/test-index-sdmmc -> rc=0
../examples/tests/player/test-player -> rc=0
../examples/tests/player/test-vector-source -> rc=0
../examples/tests/player/test-vfs -> rc=0
../examples/tests/timer/test-timer -> rc=0
../examples/tests/timer/test-timercb_rx -> rc=0
../examples/tests/timer/test-timercb_tx -> rc=0
../examples/tests/timer/test-timercbx_rx -> rc=0
../examples/tests/timer/test-timercbx_tx -> rc=0

View File

@@ -0,0 +1,76 @@
#!/bin/bash
##
# We compile all examples using arduino-cli in order to identify compile errors
# The return codes are made available in the build-examples-log.txt file.
# -> rc=0: success
# -> rc=1: error
##
#arduino-cli lib upgrade
#arduino-cli lib linstall
git -C .. pull
git -C ../../ESP32-A2DP pull
git -C ../../arduino-audio-driver pull
git -C ../../arduino-libhelix pull
function compile_example {
ARCH=$1
FILES=$2
for f in $FILES
do
# Skip README.md files
if [[ $(basename "$f") == "README.md" ]]; then
echo "Skipping README.md file: $f"
continue
fi
echo "Processing $f ..."
# take action on each file. $f store current file name
#arduino-cli compile -b "$ARCH" "$f"
arduino-cli compile -b "$ARCH" --build-property "build.partitions=rainmaker" --build-property "upload.maximum_size=3145728" "$f"
EC=$?
#if [ $EC -ne 0 ]; then
#break
echo -e "$f -> rc=$EC" >> "build-examples-log.txt"
#fi
done
}
rm build-examples-log.txt
compile_example "esp32:esp32:esp32" "../examples/examples-basic-api/base*"
compile_example "esp32:esp32:esp32" "../examples/examples-player/player*"
compile_example "esp32:esp32:esp32" "../examples/examples-stream/streams*"
compile_example "esp32:esp32:esp32" "../examples/examples-audiokit/*"
compile_example "esp32:esp32:esp32" "../examples/examples-tts/streams*"
compile_example "esp32:esp32:esp32" "../examples/examples-dsp/examples-maximilian/*"
compile_example "esp32:esp32:esp32" "../examples/examples-dsp/examples-mozzi/*"
compile_example "esp32:esp32:esp32" "../examples/examples-dsp/examples-pd/*"
compile_example "esp32:esp32:esp32" "../examples/examples-dsp/examples-stk/*"
compile_example "esp32:esp32:esp32" "../examples/examples-dsp/examples-faust/streams*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/a2dp/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/codec/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/pcm/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/speed-test/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/ip/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/udp/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/vban/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/rtsp/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/serial/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/snapcast/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/http-client/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/http-server/*"
compile_example "esp32:esp32:esp32" "../examples/tests/adc/*"
compile_example "esp32:esp32:esp32" "../examples/tests/basic/*"
compile_example "esp32:esp32:esp32" "../examples/tests/codecs/*"
compile_example "esp32:esp32:esp32" "../examples/tests/concurrency/*"
compile_example "esp32:esp32:esp32" "../examples/tests/conversion/*"
compile_example "esp32:esp32:esp32" "../examples/tests/effects/*"
compile_example "esp32:esp32:esp32" "../examples/tests/etc/*"
compile_example "esp32:esp32:esp32" "../examples/tests/fft/*"
compile_example "esp32:esp32:esp32" "../examples/tests/filters/*"
compile_example "esp32:esp32:esp32" "../examples/tests/performance/*"
compile_example "esp32:esp32:esp32" "../examples/tests/player/*"
compile_example "esp32:esp32:esp32" "../examples/tests/timer/*"
rm -rf /tmp/arduino
./cleanup.sh

View File

@@ -0,0 +1,4 @@
#!/bin/bash
find . -name debug_custom.json -delete
find . -name debug.cfg -delete
find . -name esp32.svd -delete

View File

@@ -0,0 +1,7 @@
# AudioKit
Please read the [Audio Boards Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/Audio-Boards) first.
These sketches work on the AI Thinker AudioKit, the LyraT or any other board that is supported by the [arduino-audio-driver](https://github.com/pschatzmann/arduino-audio-driver) library.
If you want to use them on any other board, you just pass the corresponding board variable in the constructor or you compose your own board. Further information can be found in [this Wiki](https://github.com/pschatzmann/arduino-audio-driver/wiki).

View File

@@ -0,0 +1,15 @@
# Stream Input from an AudioKit to AudioKit Output
## General Description:
We implement a AudioKit source and sink: We stream the sound input which we read in from the I2S interface and write it back via I2S to the Speaker
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
### Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver

View File

@@ -0,0 +1,31 @@
/**
* @file streams-audiokit-audiokit.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/streams-audiokit-audiokit/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioBoardStream kit(AudioKitEs8388V1); // Access I2S as stream
StreamCopy copier(kit, kit); // copy kit to kit
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = false;
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
}
// Arduino loop - copy data
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,157 @@
/**
* @file audiokit-effects-audiokit.ino
* @author Phil Schatzmann
* @brief Some Guitar Effects that can be controlled via a Web Gui.
* @version 0.1
* @date 2022-10-14
*
* @copyright Copyright (c) 2022
*
*/
#include <ArduinoJson.h> // https://arduinojson.org/
#include "HttpServer.h" // https://github.com/pschatzmann/TinyHttp
#include "AudioTools.h" // https://github.com/pschatzmann/arduino-audio-tools.git
#include "AudioTools/AudioLibs/AudioBoardStream.h" // https://github.com/pschatzmann/arduino-audio-driver.git
// Server
WiFiServer wifi;
HttpServer server(wifi);
const char *ssid = "SSID";
const char *password = "PASSWORD";
// Audio Format
const int sample_rate = 44100;
const int channels = 1;
const int bits_per_sample = 16;
// Effects control input
float volumeControl = 0.1;
int16_t clipThreashold = 0;
float fuzzEffectValue = 0;
int16_t fuzzMaxValue = 0;
int16_t tremoloDuration = 0;
float tremoloDepth = 0;
// Effects
Boost boost(volumeControl);
Distortion distortion(clipThreashold);
Fuzz fuzz(fuzzEffectValue);
Tremolo tremolo(tremoloDuration, tremoloDepth, sample_rate);
// Audio
AudioBoardStream kit(AudioKitEs8388V1); // Access I2S as stream
AudioEffectStream effects(kit); // input from kit
StreamCopy copier(kit, effects); // copy effects to kit
// Update values in effects
void updateValues(){
// update values in controls
boost.setVolume(volumeControl);
boost.setActive(volumeControl>0);
distortion.setClipThreashold(clipThreashold);
distortion.setActive(clipThreashold>0);
fuzz.setFuzzEffectValue(fuzzEffectValue);
fuzz.setMaxOut(fuzzMaxValue);
fuzz.setActive(fuzzEffectValue>0);
tremolo.setDepth(tremoloDepth);
tremolo.setDuration(tremoloDuration);
tremolo.setActive(tremoloDuration>0);
}
// provide JSON as webservice
void getJson(HttpServer * server, const char*requestPath, HttpRequestHandlerLine * hl) {
auto parameters2Json = [](Stream & out) {
DynamicJsonDocument doc(1024);
doc["volumeControl"]["value"] = volumeControl;
doc["volumeControl"]["min"] = 0;
doc["volumeControl"]["max"] = 1;
doc["volumeControl"]["step"] = 0.1;
doc["clipThreashold"]["value"] = clipThreashold;
doc["clipThreashold"]["min"] = 0;
doc["clipThreashold"]["max"] = 6000;
doc["clipThreashold"]["step"] = 100;
doc["fuzzEffectValue"]["value"] = fuzzEffectValue;
doc["fuzzEffectValue"]["min"] = 0;
doc["fuzzEffectValue"]["max"] = 10;
doc["fuzzEffectValue"]["step"] = 0.1;
doc["fuzzMaxValue"]["value"] = fuzzMaxValue;
doc["fuzzMaxValue"]["min"] = 0;
doc["fuzzMaxValue"]["max"] = 32200;
doc["fuzzMaxValue"]["step"] = 1;
doc["tremoloDuration"]["value"] = tremoloDuration;
doc["tremoloDuration"]["min"] = 0;
doc["tremoloDuration"]["max"] = 2000;
doc["tremoloDuration"]["step"] = 1;
doc["tremoloDepth"]["value"] = tremoloDepth;
doc["tremoloDepth"]["min"] = 0;
doc["tremoloDepth"]["max"] = 100;
doc["tremoloDepth"]["step"] = 1;
serializeJson(doc, out);
};
// provide data as json using callback
server->reply("text/json", parameters2Json, 200);
};
// Poroces Posted Json
void postJson(HttpServer *server, const char*requestPath, HttpRequestHandlerLine *hl) {
// post json to server
DynamicJsonDocument doc(1024);
deserializeJson(doc, server->client());
volumeControl = doc["volumeControl"];
clipThreashold = doc["clipThreashold"];
fuzzEffectValue = doc["fuzzEffectValue"];
fuzzMaxValue = doc["fuzzMaxValue"];
tremoloDuration = doc["tremoloDuration"];
tremoloDepth = doc["tremoloDepth"];
// update values in controls
updateValues();
server->reply("text/json", "{}", 200);
char msg[120];
snprintf(msg, 120, "====> updated values %f %d %f %d %d %f", volumeControl, clipThreashold, fuzzEffectValue, tremoloDuration, tremoloDepth);
Serial.println(msg);
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// Setup Server
static HttpTunnel tunnel_url("https://pschatzmann.github.io/TinyHttp/app/guitar-effects.html");
server.on("/", T_GET, tunnel_url);
server.on("/service", T_GET, getJson);
server.on("/service", T_POST, postJson);
server.begin(80, ssid, password);
server.setNoConnectDelay(0);
// Setup Kit
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = false;
cfg.input_device = ADC_INPUT_LINE2;
cfg.sample_rate = sample_rate;
cfg.channels = channels;
// minimize lag
cfg.buffer_count = 2;
cfg.buffer_size = 256;
kit.begin(cfg);
kit.setVolume(1.0);
// setup effects
effects.addEffect(boost);
effects.addEffect(distortion);
effects.addEffect(fuzz);
effects.addEffect(tremolo);
effects.begin(cfg);
updateValues();
}
// Arduino loop - copy data
void loop() {
copier.copy();
server.copy();
}

View File

@@ -0,0 +1,64 @@
/**
* @file streams-audiokit-fft-led.ino
* @author Phil Schatzmann
* @brief We peform FFT on the microphone input of the AudioKit and display the
* result on a 32*8 LED matrix
* @version 0.1
* @date 2022-10-14
*
* @copyright Copyright (c) 2022
*
*/
#include <FastLED.h> // to prevent conflicts introduced with 3.9
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioLibs/AudioRealFFT.h" // or AudioKissFFT
#include "AudioTools/AudioLibs/LEDOutput.h"
#define PIN_LEDS 22
#define LED_X 32
#define LED_Y 8
AudioBoardStream kit(AudioKitEs8388V1); // Audio source
AudioRealFFT fft; // or AudioKissFFT
FFTDisplay fft_dis(fft);
LEDOutput led(fft_dis); // output to LED matrix
StreamCopy copier(fft, kit); // copy mic to fft
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup Audiokit as input device
auto cfg = kit.defaultConfig(RX_MODE);
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
// Setup FFT output
auto tcfg = fft.defaultConfig();
tcfg.length = 1024;
tcfg.copyFrom(cfg);
fft.begin(tcfg);
// Setup FFT Display
fft_dis.fft_group_bin = 3;
fft_dis.fft_start_bin = 0;
fft_dis.fft_max_magnitude = 40000;
fft_dis.begin();
// Setup LED matrix output
auto lcfg = led.defaultConfig();
lcfg.x = LED_X;
lcfg.y = LED_Y;
led.begin(lcfg);
// add LEDs
FastLED.addLeds<WS2812B, PIN_LEDS, GRB>(led.ledData(), led.ledCount());
}
void loop() {
// update FFT
copier.copy();
// update LEDs
led.update();
}

View File

@@ -0,0 +1,21 @@
## FFT
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies
The fast Fourier transform (FFT) can be used to determine the frequencies of a singal. More [details can be found in the Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/FFT)
### Note
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
## Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver

View File

@@ -0,0 +1,53 @@
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioLibs/AudioRealFFT.h" // or AudioKissFFT
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;
// display fft result
void fftResult(AudioFFTBase &fft){
float diff;
auto result = fft.result();
if (result.magnitude>100){
Serial.print(result.frequency);
Serial.print(" ");
Serial.print(result.magnitude);
Serial.print(" => ");
Serial.print(result.frequencyAsNote(diff));
Serial.print( " diff: ");
Serial.println(diff);
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// 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();
}

View File

@@ -0,0 +1,46 @@
/**
* @file streams-kit-filter-kit.ino
* @brief Copy audio from I2S to I2S using an FIR filter
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16);
AudioBoardStream kit(AudioKitEs8388V1);
// copy filtered values
FilteredStream<int16_t, float> filtered(kit, info.channels); // Defiles the filter as BaseConverter
StreamCopy copier(filtered, kit); // copies sound into i2s (both from kit to filtered or filered to kit are supported)
// define FIR filter
float coef[] = { 0.021, 0.096, 0.146, 0.096, 0.021};
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
// change to Warning to improve the quality
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup filters for all available channels
filtered.setFilter(0, new FIR<float>(coef));
filtered.setFilter(1, new FIR<float>(coef));
// start I2S in
Serial.println("starting KIT...");
auto config = kit.defaultConfig(RXTX_MODE);
config.copyFrom(info);
config.sd_active = false;
config.input_device = ADC_INPUT_LINE2;
kit.begin(config);
Serial.println("KIT started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,86 @@
// Example for DTMF detection using Goertzel algorithm
// Uses AudioKit and I2S microphones as input
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16); // 8kHz, mono, 16 bits
AudioBoardStream kit(AudioKitEs8388V1); // Access I2S as stream
//CsvOutput<int16_t> out(Serial, 1);
GoertzelStream goertzel; //(out);
StreamCopy copier(goertzel, kit); // copy kit to georzel
// represent DTMF keys
class DTMF {
public:
enum Dimension { Row, Col };
DTMF() = default;
DTMF(Dimension d, int i) {
if (d == Row)
row = i;
else
col = i;
}
void clear() {
row = -1;
col = -1;
}
char getChar() {
if (row == -1 || col == -1) return '?';
return keys[row][col];
}
int row = -1;
int col = -1;
const char* keys[4] = {"123A", "456B", "789C", "*0#D"};
} actual_dtmf;
// combine row and col information
void GoetzelCallback(float frequency, float magnitude, void* ref) {
DTMF* dtmf = (DTMF*)ref;
LOGW("Time: %lu - Hz: %f Mag: %f", millis(), frequency, magnitude);
// we get either row or col information
if (dtmf->row != -1) {
actual_dtmf.row = dtmf->row;
} else {
actual_dtmf.col = dtmf->col;
// print detected key
Serial.println(actual_dtmf.getChar());
actual_dtmf.clear();
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start audio input from microphones
auto cfg = kit.defaultConfig(RX_MODE);
cfg.copyFrom(info);
cfg.sd_active = false;
cfg.input_device = ADC_INPUT_LINE2;
cfg.use_apll = false;
kit.begin(cfg);
// lower frequencies - with keys
goertzel.addFrequency(697, new DTMF(DTMF::Row, 0));
goertzel.addFrequency(770, new DTMF(DTMF::Row, 1));
goertzel.addFrequency(852, new DTMF(DTMF::Row, 2));
goertzel.addFrequency(941, new DTMF(DTMF::Row, 3));
// higher frequencies with idx
goertzel.addFrequency(1209, new DTMF(DTMF::Col, 0));
goertzel.addFrequency(1336, new DTMF(DTMF::Col, 1));
goertzel.addFrequency(1477, new DTMF(DTMF::Col, 2));
goertzel.addFrequency(1633, new DTMF(DTMF::Col, 3));
// define callback
goertzel.setFrequencyDetectionCallback(GoetzelCallback);
// start goertzel
auto gcfg = goertzel.defaultConfig();
gcfg.copyFrom(info);
gcfg.threshold = 5.0;
gcfg.block_size = 1024;
goertzel.begin(gcfg);
}
void loop() { copier.copy(); }

View File

@@ -0,0 +1,51 @@
/**
* @file streams-audiokit-multioutput-server.ino
* @author Phil Schatzmann
* @brief MultiOutput Example using output to speaker and webserver
* @version 0.1
* @date 2022-07-26
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/Communication/AudioHttp.h"
const int buffer_count = 10;
const int buffer_size = 1024;
AudioBoardStream kit(AudioKitEs8388V1); // input & output
QueueStream<uint8_t> queue(buffer_size, buffer_count, true);
AudioEncoderServer server(new WAVEncoder(),"WIFI","password");
MultiOutput out(queue, kit);
StreamCopy copier(out, kit); // copy kit to kit
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup audiokit
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = false;
cfg.input_device = ADC_INPUT_LINE2; // input from microphone
cfg.sample_rate = 16000;
kit.setVolume(0.5);
kit.begin(cfg);
// start queue
queue.begin();
// start server
server.begin(queue, cfg);
Serial.println("started...");
}
// Arduino loop - copy data
void loop() {
copier.copy();
server.copy();
}

View File

@@ -0,0 +1,42 @@
/**
* @file streams-audiokit-multioutput.ino
* @author Phil Schatzmann
* @brief MultiOutput Example using add
* @version 0.1
* @date 2022-07-26
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(8000, 2, 16);
AudioBoardStream kit(AudioKitEs8388V1); // Access I2S as stream
CsvOutput<int16_t> csv(Serial);
MultiOutput out;
StreamCopy copier(out, kit); // copy kit to kit
// Arduino Setup
void setup(void) {
Serial.begin(230400);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
out.add(csv);
out.add(kit);
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.copyFrom(info);
cfg.sd_active = false;
cfg.input_device = ADC_INPUT_LINE2; // input from microphone
kit.setVolume(0.5);
kit.begin(cfg);
csv.begin(info);
}
// Arduino loop - copy data
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,70 @@
/**
* @file streams-audiokit-sd-audiokit.ino
* @author Phil Schatzmann
* @brief We record the input from the microphone to SPI RAM and constantly repeat to play the file
* The input is triggered by pressing key 1. Recording stops when key 1 is released!
* @version 0.1
* @date 2022-09-01
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioLibs/MemoryManager.h"
AudioInfo info(16000, 1, 16);
AudioBoardStream kit(AudioKitEs8388V1);
DynamicMemoryStream recording(true); // Audio stored on heap
StreamCopy copier; // copies data
void record_start(bool pinStatus, int pin, void* ref){
Serial.println("Recording...");
recording.begin();
copier.begin(recording, kit);
}
void record_end(bool pinStatus, int pin, void* ref){
Serial.println("Playing...");
// Remove popping noise, from button: we delete 6 segments at the beginning and end
// and on the resulting audio we slowly raise the volume on the first segment
// end decrease it on the last segment
recording.postProcessSmoothTransition<int16_t>(info.channels, 0.01, 6);
// Restart from beginning
recording.rewind();
// output to kit
copier.begin(kit, recording); // start playback
}
void setup(){
Serial.begin(115200);
while(!Serial); // wait for serial to be ready
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup input and output
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = true;
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
kit.setVolume(1.0);
// record when key 1 is pressed
kit.audioActions().add(kit.getKey(1), record_start, record_end);
Serial.println("Press Key 1 to record");
}
void loop(){
// record or play recording
copier.copy();
// Process keys
kit.processActions();
}

View File

@@ -0,0 +1,75 @@
/**
* @file streams-audiokit-sd-audiokit.ino
* @author Phil Schatzmann
* @brief We record the input from the microphone to SPI RAM and constantly repeat to play the file
* The input is triggered by pressing key 1. Recording stops when key 1 is released!
* The output pitch is shifted by 1 octave!
* @version 0.1
* @date 2022-11-21
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioLibs/MemoryManager.h"
AudioInfo info(16000, 1, 16);
MemoryManager memory(500); // Activate SPI RAM for objects > 500 bytes
AudioBoardStream kit(AudioKitEs8388V1);
//use one of VariableSpeedRingBufferSimple, VariableSpeedRingBuffer, VariableSpeedRingBuffer180
PitchShiftOutput<int16_t, VariableSpeedRingBuffer<int16_t>> pitch_shift(kit);
DynamicMemoryStream recording(false); // Audio stored on heap, non repeating
StreamCopy copier; // copies data
void record_start(bool pinStatus, int pin, void* ref){
Serial.println("Recording...");
recording.begin();
copier.begin(recording, kit);
}
void record_end(bool pinStatus, int pin, void* ref){
Serial.println("Playing...");
// Remove popping noise, from button: we delete 6 segments at the beginning and end
// and on the resulting audio we slowly raise the volume on the first segment
// end decrease it on the last segment
recording.postProcessSmoothTransition<int16_t>(info.channels, 0.01, 6);
// output with pitch shifting
copier.begin(pitch_shift, recording); // start playback
}
void setup(){
Serial.begin(115200);
while(!Serial); // wait for serial to be ready
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup input and output
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = true;
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
kit.setVolume(1.0);
// setup pitch shift
auto cfg_pc = pitch_shift.defaultConfig();
cfg_pc.pitch_shift = 2; // one octave up
cfg_pc.buffer_size = 1000;
cfg_pc.copyFrom(info);
pitch_shift.begin(cfg_pc);
// record when key 1 is pressed
kit.audioActions().add(kit.getKey(1), record_start, record_end);
Serial.println("Press Key 1 to record");
}
void loop(){
// record or play recording
copier.copy();
// Process keys
kit.processActions();
}

View File

@@ -0,0 +1,85 @@
/**
* @file streams-audiokit-sd-audiokit.ino
* @author Phil Schatzmann
* @brief We record the input from the microphone to a file and constantly repeat to play the file
* The input is triggered by pressing key 1. Recording stops when key 1 is released!
* @version 0.1
* @date 2022-09-01
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include <SPI.h>
#include <SD.h>
const char *file_name = "/rec.raw";
AudioInfo info(16000, 1, 16);
AudioBoardStream kit(AudioKitEs8388V1);
File file; // final output stream
StreamCopy copier; // copies data
bool recording = false; // flag to make sure that close is only executed one
uint64_t end_time; // trigger to call endRecord
void record_start(bool pinStatus, int pin, void* ref){
Serial.println("Recording...");
// open the output file
file = SD.open(file_name, FILE_WRITE);
copier.begin(file, kit);
recording = true;
}
void record_end(bool pinStatus, int pin, void* ref){
if (recording == true){
Serial.println("Playing...");
file.close();
recording = false;
file = SD.open(file_name); // reopen in read mode
copier.begin(kit, file); // start playback
}
}
void setup(){
Serial.begin(115200);
while(!Serial); // wait for serial to be ready
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup input and output: setup audiokit before SD!
auto cfg = kit.defaultConfig(RXTX_MODE);
cfg.sd_active = true;
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
kit.setVolume(1.0);
// Open SD drive
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
Serial.println("Initialization failed!");
while (1); // stop
}
Serial.println("Initialization done.");
// record when key 1 is pressed
kit.audioActions().add(kit.getKey(1), record_start, record_end);
Serial.println("Press Key 1 to record");
}
void loop(){
// record or play file
copier.copy();
// while playing: at end of file -> reposition to beginning
if (!recording && file.size()>0 && file.available()==0){
file.seek(0);
Serial.println("Replay...");
}
// Process keys
kit.processActions();
}

View File

@@ -0,0 +1,76 @@
/**
* @file streams-audiokit-sd_wav.ino
* @author Phil Schatzmann
* @brief Demonstrates how to use an encoder to write to a file
* @version 0.1
* @date 2023-05-04
*
* @copyright Copyright (c) 2023
*
*/
#include <SD.h>
#include <SPI.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
const char* file_name = "/rec.wav";
AudioInfo info(16000, 1, 16);
AudioBoardStream in(AudioKitEs8388V1);
File file; // final output stream
EncodedAudioStream out(&file, new WAVEncoder());
StreamCopy copier(out, in); // copies data
uint64_t timeout;
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup input
auto cfg = in.defaultConfig(RX_MODE);
cfg.sd_active = true;
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2; // microphone
in.begin(cfg);
// Open SD drive
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
Serial.println("Initialization failed!");
stop();
}
// Cleanup if necessary
if (SD.exists(file_name))
SD.remove(file_name);
// open file
file = SD.open(file_name, FILE_WRITE);
if (!file){
Serial.println("file failed!");
stop();
}
// setup output
out.begin(info);
// set timeout - recoring for 5 seconds
timeout = millis() + 5000;
}
void loop() {
if (millis() < timeout) {
// record to wav file
copier.copy();
} else {
// close file when done
if (file) {
file.flush();
Serial.print("File has ");
Serial.print(file.size());
Serial.println(" bytes");
file.close();
}
}
}

View File

@@ -0,0 +1,15 @@
# Stream Input from an AudioKit to CSV Output
## General Description:
We implement a AudioKit source: We stream the sound input which we read in from the I2S interface and display it on the Arduino Serial Plotter.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
### Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver

View File

@@ -0,0 +1,37 @@
/**
* @file streams-audiokit-csv.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/streams-audiokit-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16);
AudioBoardStream kit(AudioKitEs8388V1); // Access I2S as stream
CsvOutput<int16_t> csvOutput(Serial);
StreamCopy copier(csvOutput, kit); // copy kit to csvOutput
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
auto cfg = kit.defaultConfig(RX_MODE);
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2;
kit.begin(cfg);
// make sure that we have the correct channels set up
csvOutput.begin(info);
}
// Arduino loop - copy data
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,26 @@
## Using the AI Thinker ESP32 Audio Kit Micro Speech
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies
The staring point for doing speech recognition on an Arduino based board is TensorFlow Light For Microcontrollers with the example sketch called micro_speech!
I have adapted the MicroSpeech example from TensorFlow Lite to follow the philosophy of this framework. The example uses a Tensorflow model which can recognise the words 'yes' and 'no'. The output stream class is TfLiteAudioOutput. In the example I am using an ESP32 AudioKit board, but you can replace this with any type of processor with a microphone.
Further information can be found in the [Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/TensorFlow-Lite---MicroSpeech)
### Note
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
## Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver
- https://github.com/pschatzmann/tflite-micro-arduino-examples

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioLibs/TfLiteAudioStream.h"
#include "model.h" // tensorflow model
AudioBoardStream kit(AudioKitEs8388V1); // Audio source
TfLiteAudioStream tfl; // Audio sink
const char* kCategoryLabels[4] = {
"silence",
"unknown",
"yes",
"no",
};
StreamCopy copier(tfl, kit); // copy mic to tfl
int channels = 1;
int samples_per_second = 16000;
void respondToCommand(const char* found_command, uint8_t score,
bool is_new_command) {
if (is_new_command) {
char buffer[80];
sprintf(buffer, "Result: %s, score: %d, is_new: %s", found_command, score,
is_new_command ? "true" : "false");
Serial.println(buffer);
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup Audiokit
auto cfg = kit.defaultConfig(RX_MODE);
cfg.input_device = ADC_INPUT_LINE2;
cfg.channels = channels;
cfg.sample_rate = samples_per_second;
cfg.use_apll = false;
//cfg.auto_clear = true;
cfg.buffer_size = 512;
cfg.buffer_count = 16;
kit.begin(cfg);
// Setup tensorflow
auto tcfg = tfl.defaultConfig();
tcfg.setCategories(kCategoryLabels);
tcfg.channels = channels;
tcfg.sample_rate = samples_per_second;
tcfg.kTensorArenaSize = 10 * 1024;
tcfg.respondToCommand = respondToCommand;
tcfg.model = g_model;
tfl.begin(tcfg);
}
void loop() { copier.copy(); }

View File

@@ -0,0 +1,48 @@
/**
* @file streams-file_loop-audiokit.ino
* @author Phil Schatzmann
* @brief Just a small demo, how to use looping (=repeating) files with the SD library
* @version 0.1
* @date 2022-10-09
*
* @copyright Copyright (c) 2022
*
*/
#include <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/Disk/FileLoop.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
EncodedAudioStream decoder(&i2s, new MP3DecoderHelix()); // Decoding stream
FileLoop loopingFile;
StreamCopy copier(decoder, loopingFile);
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = true;
i2s.begin(config);
// setup file
SD.begin(chipSelect);
loopingFile.setFile(SD.open("/ZZ Top/Unknown Album/Lowrider.mp3"));
//loopingFile.setLoopCount(-1); // define loop count
//audioFile.setStartPos(44); // restart from pos 44
//if ((audioFile.size()-44) % 1024!=0) audioFile.setSize((((audioFile.size()-44)/1024)+1)*1024+44);
loopingFile.begin();
// setup I2S based on sampling rate provided by decoder
decoder.begin();
}
void loop(){
copier.copy();
}

View File

@@ -0,0 +1,37 @@
/**
* @file streams-generator-audiokit.ino
* @brief Tesing I2S output on audiokit
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(32000, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
AudioBoardStream out(AudioKitEs8388V1);
StreamCopy copier(out, sound); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave.begin(info, N_B4);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,39 @@
/**
* @file streams-generator_fromarray-audiokit.ino
* @brief Tesing GeneratorFromArray with output on audiokit
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16);
int16_t sine_array[] = {0, 2285, 4560, 6812, 9031, 11206, 13327, 15383, 17363, 19259, 21062, 22761, 24350, 25820, 27165, 28377, 29450, 30381, 31163, 31793, 32269, 32587, 32747, 32747, 32587, 32269, 31793, 31163, 30381, 29450, 28377, 27165, 25820, 24350, 22761, 21062, 19259, 17363, 15383, 13327, 11206, 9031, 6812, 4560, 2285, 0, -2285, -4560, -6812, -9031, -11206, -13327, -15383, -17363, -19259, -21062, -22761, -24350, -25820, -27165, -28377, -29450, -30381, -31163, -31793, -32269, -32587, -32747, -32747, -32587, -32269, -31793, -31163, -30381, -29450, -28377, -27165, -25820, -24350, -22761, -21062, -19259, -17363, -15383, -13327, -11206, -9031, -6812, -4560, -2285 };
GeneratorFromArray<int16_t> sineWave(sine_array,0,false);
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
AudioBoardStream out(AudioKitEs8388V1);
StreamCopy copier(out, sound); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave.begin(info);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,46 @@
/**
* @file streams-generator_inputmixer-audiokit.ino
* @brief Tesing input mixer
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(32000, 2, 16);
SineWaveGenerator<int16_t> sineWave1(32000); // subclass of SoundGenerator with max amplitude of 32000
SineWaveGenerator<int16_t> sineWave2(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound1(sineWave1); // Stream generated from sine wave
GeneratedSoundStream<int16_t> sound2(sineWave2); // Stream generated from sine wave
InputMixer<int16_t> mixer;
AudioBoardStream out(AudioKitEs8388V1);
StreamCopy copier(out, mixer); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave1.begin(info, N_B4);
sineWave2.begin(info, N_E4);
mixer.add(sound1);
mixer.add(sound2);
mixer.begin(info);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,54 @@
/**
* @file streams-generator_outputmixer-audiokit.ino
* @brief Tesing output mixer
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16);
const int N = 5;
SineWaveGenerator<int16_t> sineWave[N](32000);
GeneratedSoundStream<int16_t> sound[N];
AudioBoardStream out(AudioKitEs8388V1);
OutputMixer<int16_t> mixer(out, N, DefaultAllocatorRAM);
StreamCopy copier[N](DefaultAllocatorRAM);
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
for (int j = 0; j < N; j++) {
sineWave[j].begin(info, 440 * (j + 1));
sound[j].setInput(sineWave[j]);
sound[j].begin(info);
copier[j].begin(mixer, sound[j]);
}
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// setup Output mixer with default buffer size
mixer.begin();
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
// write each output
for (int j = 0; j < N; j++) {
copier[j].copy();
}
// We could flush to force the output but this is not necessary because we
// were already writing all streams
// mixer.flushMixer();
}

View File

@@ -0,0 +1,47 @@
/**
* @file streams-generator_sinfromtable-audiokit.ino
* @brief Tesing SineFromTable with output on audiokit
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(32000, 2, 16);
SineFromTable<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
AudioBoardStream out(AudioKitEs8388V1);
//CsvOutput<int16_t> out(Serial);
int sound_len=1024;
StreamCopy copier(out, sound, sound_len); // copies sound into i2s
int freq = 122;
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(); //TX_MODE
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave.begin(info, freq);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
// the length is defined by sound_len
copier.copy();
// increase frequency
freq += 10;
if (freq>=10000){
freq = 20;
}
sineWave.setFrequency(freq);
}

View File

@@ -0,0 +1,46 @@
/**
* @file streams-memory_mp3_short-i2s.ino
* @author Phil Schatzmann
* @brief decode MP3 stream and output as i2s signal
* @version 0.1
* @date 2021-01-24
*
* @copyright Copyright (c) 2021
*/
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "zero.h"
MemoryStream mp3(zero_mp3, zero_mp3_len);
AudioBoardStream i2s(AudioKitEs8388V1);
MP3DecoderHelix helix;
EncodedAudioStream out(&i2s, &helix); // output to decoder
StreamCopy copier(out, mp3); // copy in to i2s
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// begin processing
auto cfg = i2s.defaultConfig();
cfg.sample_rate = 24000;
cfg.channels = 1;
i2s.begin(cfg);
out.begin();
}
void loop(){
if (mp3.available()) {
copier.copy();
} else {
helix.end(); // flush output
auto info = out.decoder().audioInfo();
LOGI("The audio rate from the mp3 file is %d", info.sample_rate);
LOGI("The channels from the mp3 file is %d", info.channels);
i2s.end();
stop();
}
}

View File

@@ -0,0 +1,365 @@
#pragma once
const unsigned char zero_mp3[] = {
0xff, 0xf3, 0x44, 0xc4, 0x00, 0x11, 0x20, 0x6a, 0x1c, 0x00, 0x7b, 0x0c,
0x28, 0x52, 0x24, 0x4c, 0x22, 0xb4, 0xe2, 0x18, 0x80, 0x0e, 0x52, 0x2f,
0xa0, 0x17, 0x07, 0xc5, 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 0x2e, 0x37, 0x3b, 0x3b, 0xb3, 0xfc, 0xb2, 0xd4, 0x3f, 0xd6,
0x5b, 0x3f, 0x96, 0x19, 0xac, 0xbd, 0x60, 0xa0, 0x81, 0x03, 0x8f, 0x8b,
0x33, 0xff, 0x82, 0xc2, 0xe2, 0x37, 0x7d, 0x4d, 0xfe, 0x2a, 0x28, 0xdf,
0xff, 0x16, 0xd4, 0x2f, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e, 0x31, 0x30,
0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e,
0xff, 0xf3, 0x44, 0xc4, 0xb8, 0x11, 0x20, 0xda, 0x00, 0x00, 0x62, 0x06,
0x70, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e,
0xff, 0xf3, 0x44, 0xc4, 0xc6, 0x11, 0xb9, 0x49, 0x90, 0x00, 0x79, 0x86,
0x94, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x4c, 0x41, 0x4d, 0x45, 0x33, 0x2e,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x1c, 0xe0, 0x43, 0x42, 0x88, 0x20,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0x9a, 0x09, 0xa0, 0x5e, 0x03, 0x90, 0x30, 0x02, 0x46, 0x3f, 0xd7,
0x8b, 0x61, 0x38, 0x2e, 0x04, 0x81, 0x40, 0x30, 0x05, 0x93, 0xec, 0x2c,
0x8c, 0x13, 0x3f, 0x0c, 0x23, 0x36, 0x81, 0xc8, 0xd1, 0xa3, 0xa6, 0xc4,
0x00, 0x80, 0x20, 0x18, 0x8a, 0xe2, 0xb2, 0x7b, 0xeb, 0x8b, 0x34, 0x00,
0x00, 0x00, 0x03, 0x17, 0xf1, 0x02, 0x00, 0x23, 0xff, 0x10, 0x00, 0x00,
0xbf, 0x40, 0x80, 0x00, 0x02, 0x3d, 0x11, 0x11, 0x13, 0x74, 0xc3, 0x81,
0x99, 0x71, 0xc0, 0xf8, 0x3e, 0xc0, 0xf9, 0x70, 0x7c, 0x40, 0x08, 0x41,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0x01, 0x87, 0x1f, 0xc9, 0x88, 0x1f, 0x39, 0xf0, 0xc1, 0x0d, 0x43,
0x1d, 0xfc, 0x49, 0x59, 0xf5, 0x9c, 0x89, 0xc3, 0xea, 0x2d, 0xc9, 0x54,
0x40, 0xa7, 0x2a, 0x65, 0xd5, 0x2a, 0x58, 0x67, 0xdd, 0xc5, 0x7a, 0x8b,
0x54, 0x86, 0xcd, 0x79, 0xc6, 0x92, 0xce, 0x39, 0x51, 0x30, 0x49, 0x10,
0xa9, 0xb6, 0x4a, 0xa0, 0x00, 0x48, 0xcb, 0x81, 0x22, 0x23, 0x60, 0x8b,
0xad, 0x23, 0x40, 0x30, 0x15, 0x19, 0x00, 0xa0, 0x4a, 0x12, 0x51, 0xa3,
0x3a, 0xca, 0xc4, 0xc8, 0x91, 0x6c, 0x56, 0x44, 0xd4, 0x91, 0x6c, 0xa6,
0xff, 0xf3, 0x44, 0xc4, 0xac, 0x00, 0x00, 0x03, 0x48, 0x00, 0x00, 0x00,
0x00, 0xcd, 0x22, 0x9a, 0x4d, 0x7a, 0x35, 0x16, 0xaa, 0x25, 0xa7, 0x58,
0x05, 0x4c, 0x95, 0x6f, 0xef, 0x39, 0x26, 0xa2, 0x52, 0x4e, 0xd5, 0x53,
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
* @file streams-mixer-audiokit.ino
* @author Phil Schatzmann
* @brief Simple Demo for mixing 2 input streams
* @version 0.1
* @date 2022-11-15
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "drums.h"
#include "guitar.h"
InputMixer<int16_t> mixer;
AudioBoardStream kit(AudioKitEs8388V1);
MemoryStream drums(drums_raw, drums_raw_len);
MemoryStream guitar(guitar_raw, guitar_raw_len);
StreamCopy copier(kit, mixer);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// auto restart when MemoryStream has ended
drums.setLoop(true);
guitar.setLoop(true);
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.channels = 1;
cfg.sample_rate = 8000;
kit.begin(cfg);
// max volume
kit.setVolume(1.0);
mixer.add(drums);
mixer.add(guitar);
mixer.begin(cfg);
}
void loop() { copier.copy(); }

View File

@@ -0,0 +1,18 @@
# AudioActions
Originally I was of the opinion that the program logic for __reading of the GPIO pins__ and the processing of the related actions should belong into a specific __Arduino sketch__ and should not be part of an Audio Framework.
The [Audio Kit](https://docs.ai-thinker.com/en/esp32-audio-kit) made me revise this because I think that an Arduino Sketch should be __as concise as possible__. For this I have created the AudioActions class which has been integrated into the AudioKit.
Since the Audio Kit does not have any display, I think to use TTS is a good choice.
You just need to define you __handler methods__ (button1, button2...) and assign them to the __GPIO pins__.
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)
- [Audio Driver](https://github.com/pschatzmann/arduino-audio-driver)
- [FLITE](https://github.com/pschatzmann/arduino-flite)

View File

@@ -0,0 +1,50 @@
/**
* @file stream-pins-audiokit.ino
* @brief see
* https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/streams-pins-audiokit/README.md
* @author Phil Schatzmann
* @copyright Copyright (c) 2021
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "flite_arduino.h"
AudioBoardStream kit(AudioKitEs8388V1);
Flite flite(kit);
void button1(bool, int, void*) { flite.say("Button One"); }
void button2(bool, int, void*) { flite.say("Button Two"); }
void button3(bool, int, void*) { flite.say("Button Three"); }
void button4(bool, int, void*) { flite.say("Button Four"); }
// Arduino setup
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
//AUDIOKIT_LOG_LEVEL = AudioKitDebug;
auto cfg = kit.defaultConfig(TX_MODE);
cfg.bits_per_sample = 16;
cfg.channels = 1;
cfg.sample_rate = 8000;
cfg.sd_active = false;
kit.begin(cfg);
// Assign pins to methods
kit.addAction(kit.getKey(1), button1);
kit.addAction(kit.getKey(2), button2);
kit.addAction(kit.getKey(3), button3);
kit.addAction(kit.getKey(4), button4);
// example with actions using lambda expression
auto down = [](bool,int,void*) { AudioBoardStream::actionVolumeDown(true, -1, nullptr); flite.say("Volume down"); };
kit.addAction(kit.getKey(5), down);
auto up = [](bool,int,void*) { AudioBoardStream::actionVolumeUp(true, -1, nullptr ); flite.say("Volume up"); };
kit.addAction(kit.getKey(6), up);
flite.say("Please push a button");
}
// Arduino Loop
void loop() { kit.processActions(); }

View File

@@ -0,0 +1,32 @@
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
AudioBoardStream out(AudioKitEs8388V1);
RTTTLOutput<int16_t> rtttl(sineWave, out);
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
delay(5000);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave (optional)
sineWave.begin(info);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
rtttl.begin(info);
rtttl.print("ComplexDemo: d=8, o=5, b=140: c4 e g c6 a5 g4 e g a g4 e c4 e2 g4 c6 a5 g4 e g a g4 e c2 p c4 e g c6 a5 g4 e g a g4 e c4 e2 g4 c6 a5 g4 e g a g4 e c2");
delay(1000);
}

View File

@@ -0,0 +1,45 @@
/**
* @file streams-sd-audiokit.ino
* @author Phil Schatzmann
* @brief Just a small demo, how to use files with the SD library with a streaming decoder
* @version 0.1
* @date 2022-10-09
*
* @copyright Copyright (c) 2022
*
*/
#include <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecFLAC.h"
const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
FLACDecoder dec;
File audioFile;
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = true;
i2s.begin(config);
// setup file
SD.begin(chipSelect);
audioFile = SD.open("/flac/test2.flac");
// setup decoder
dec.setInput(audioFile);
dec.setOutput(i2s);
dec.begin();
}
void loop(){
dec.copy();
}

View File

@@ -0,0 +1,65 @@
/**
* @file streams-sd_m4a-audiokit.ino
* @author Peter Schatzmann
* @brief Example for decoding M4A files on the AudioKit using the AudioBoardStream
* @version 0.1
* @date 2023-10-01
*/
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecALAC.h"
#include "AudioTools/AudioCodecs/CodecAACHelix.h"
#include "AudioTools/AudioCodecs/ContainerM4A.h"
#include "AudioTools/AudioCodecs/MultiDecoder.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h" // install https://github.com/pschatzmann/arduino-audio-driver
#include "SD.h"
MultiDecoder multi_decoder;
ContainerM4A dec_m4a(multi_decoder);
AACDecoderHelix dec_aac;
DecoderALAC dec_alac;
AudioBoardStream out(AudioKitEs8388V1);
EncodedAudioOutput decoder_output(&out, &dec_m4a);
File file;
StreamCopy copier(decoder_output, file);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start AudioBoard with setup of CD pins
auto cfg = out.defaultConfig(TX_MODE);
cfg.sd_active = true;
if (!out.begin(cfg)){
Serial.println("Failed to start CSV output!");
return;
}
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)){
Serial.println("SD Card initialization failed!");
return;
}
file = SD.open("/m4a/aac.m4a");
if (!file) {
Serial.println("Failed to open file!");
return;
}
// mp4 supports alac and aac
multi_decoder.addDecoder(dec_alac,"audio/alac");
multi_decoder.addDecoder(dec_aac,"audio/aac");
// start decoder output
if(!decoder_output.begin()) {
Serial.println("Failed to start decoder output!");
return;
}
Serial.println("M4A decoding started...");
}
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,49 @@
/**
* @file streams-sd-audiokit.ino
* @author Phil Schatzmann
* @brief Just a small demo, how to use files with the SD library
* @version 0.1
* @date 2022-10-09
*
* @copyright Copyright (c) 2022
*
*/
#include <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
EncodedAudioStream decoder(&i2s, new MP3DecoderHelix()); // Decoding stream
StreamCopy copier;
File audioFile;
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = true;
i2s.begin(config);
// setup file
SD.begin(chipSelect);
audioFile = SD.open("/ZZ Top/Unknown Album/Lowrider.mp3");
// setup I2S based on sampling rate provided by decoder
decoder.begin();
// begin copy
copier.begin(decoder, audioFile);
}
void loop(){
if (!copier.copy()) {
stop();
}
}

View File

@@ -0,0 +1,50 @@
/**
* @file streams-sdmmc_wav-audiokit.ino
* @author Phil Schatzmann
* @brief A simple example that shows how to play (eg. a 24bit) wav file
* @date 2021-11-07
*
* @copyright Copyright (c) 2021
*/
#include "FS.h"
#include "SD_MMC.h"
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioBoardStream i2s(AudioKitEs8388V1);
WAVDecoder wav;
EncodedAudioStream encoded(&i2s, &wav); // Decoding stream
File audioFile;
StreamCopy copier(encoded, audioFile);
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = false;
i2s.begin(config);
i2s.setVolume(1.0);
// open sdmmc
if (!SD_MMC.begin("/sdcard", false)){
Serial.println("SD_MMC Error");
stop();
}
// open file
audioFile = SD_MMC.open("/wav24/test.wav");
if (!audioFile){
Serial.println("File does not exist");
stop();
}
// start decoder stream
encoded.begin();
}
void loop(){
copier.copy();
}

View File

@@ -0,0 +1,13 @@
# A Simple Synthesizer for the AI Thinker AudioKit
I was taking the synthbasic example, extended it to handle multiple keys at the same time and wrapped it into a nice, easy to use class.
Here is a Synthesizer in just 30 lines of code..
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)
- [Midi](https://github.com/pschatzmann/arduino-midi)

View File

@@ -0,0 +1,38 @@
/**
* @file streams-synth-audiokit.ino
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioBoardStream kit(AudioKitEs8388V1);
Synthesizer synthesizer;
GeneratedSoundStream<int16_t> in(synthesizer);
StreamCopy copier(kit, in);
SynthesizerKey keys[] = {{kit.getKey(1), N_C3},{kit.getKey(2), N_D3},{kit.getKey(3), N_E3},{kit.getKey(4), N_F3},{kit.getKey(5), N_G3},{kit.getKey(6), N_A3},{0,0}};
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
// Setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
kit.setVolume(80);
// define synthesizer keys for AudioKit
synthesizer.setKeys(kit.audioActions(), keys, AudioActions::ActiveLow);
synthesizer.setMidiName("AudioKit Synthesizer");
// Setup sound generation & synthesizer based on AudioKit default settings
in.begin(cfg);
}
void loop() {
copier.copy();
kit.processActions();
}

View File

@@ -0,0 +1,10 @@
# A Simple Basic Synthesizer for the AI Thinker Audio Kit
A [detailed description can be found in my blog](https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/) ...
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)

View File

@@ -0,0 +1,61 @@
/**
* @file streams-synthbasic-audiokit.ino
* @author Phil Schatzmann
* @brief see https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/)
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioBoardStream kit(AudioKitEs8388V1);
SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> in(sine);
StreamCopy copier(kit, in);
void actionKeyOn(bool active, int pin, void* ptr){
int freq = *((float*)ptr);
sine.setFrequency(freq);
in.begin();
}
void actionKeyOff(bool active, int pin, void* ptr){
in.end();
}
// We want to play some notes on the AudioKit keys
void setupActions(){
// assign buttons to notes
auto act_low = AudioActions::ActiveLow;
static float note[] = {N_C3, N_D3, N_E3, N_F3, N_G3, N_A3}; // frequencies
kit.audioActions().add(kit.getKey(1), actionKeyOn, actionKeyOff, act_low, &(note[0])); // C3
kit.audioActions().add(kit.getKey(2), actionKeyOn, actionKeyOff, act_low, &(note[1])); // D3
kit.audioActions().add(kit.getKey(3), actionKeyOn, actionKeyOff, act_low, &(note[2])); // E3
kit.audioActions().add(kit.getKey(4), actionKeyOn, actionKeyOff, act_low, &(note[3])); // F3
kit.audioActions().add(kit.getKey(5), actionKeyOn, actionKeyOff, act_low, &(note[4])); // G3
kit.audioActions().add(kit.getKey(6), actionKeyOn, actionKeyOff, act_low, &(note[5])); // A3
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// Setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
kit.setVolume(80);
// Setup sound generation based on AudioKit settins
in.begin(cfg);
// activate keys
setupActions();
}
// copy the data
void loop() {
copier.copy();
kit.processActions();
}

View File

@@ -0,0 +1,10 @@
# A Simple Basic Synthesizer for the AI Thinker Audio Kit
A [detailed description can be found in my blog](https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/) ...
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)

View File

@@ -0,0 +1,72 @@
/**
* @file streams-synthbasic-audiokit.ino
* @author Phil Schatzmann
* @brief see https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/)
* ADSR
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioBoardStream kit(AudioKitEs8388V1);
SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> sine_stream(sine);
AudioEffectStream effects(sine_stream);
ADSRGain adsr(0.0001,0.0001, 0.9 , 0.0002);
StreamCopy copier(kit, effects);
void actionKeyOn(bool active, int pin, void* ptr){
Serial.println("KeyOn");
float freq = *((float*)ptr);
sine.setFrequency(freq);
adsr.keyOn();
}
void actionKeyOff(bool active, int pin, void* ptr){
Serial.println("KeyOff");
adsr.keyOff();
}
// We want to play some notes on the AudioKit keys
void setupActions(){
// assign buttons to notes
auto act_low = AudioActions::ActiveLow;
static float note[] = {N_C3, N_D3, N_E3, N_F3, N_G3, N_A3}; // frequencies
kit.audioActions().add(kit.getKey(1), actionKeyOn, actionKeyOff, act_low, &(note[0])); // C3
kit.audioActions().add(kit.getKey(2), actionKeyOn, actionKeyOff, act_low, &(note[1])); // D3
kit.audioActions().add(kit.getKey(3), actionKeyOn, actionKeyOff, act_low, &(note[2])); // E3
kit.audioActions().add(kit.getKey(4), actionKeyOn, actionKeyOff, act_low, &(note[3])); // F3
kit.audioActions().add(kit.getKey(5), actionKeyOn, actionKeyOff, act_low, &(note[4])); // G3
kit.audioActions().add(kit.getKey(6), actionKeyOn, actionKeyOff, act_low, &(note[5])); // A3
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
// setup effects
effects.addEffect(adsr);
// Setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
kit.setVolume(80);
// Setup sound generation based on AudioKit settins
sine.begin(cfg, 0);
sine_stream.begin(cfg);
effects.begin(cfg);
// activate keys
setupActions();
}
// copy the data
void loop() {
copier.copy();
kit.processActions();
}

View File

@@ -0,0 +1,11 @@
# A Simple Basic Synthesizer for the AI Thinker Audio Kit
A [detailed description can be found in my blog](https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/) ...
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)
- [Arduino Audio Tools - Midi](https://github.com/pschatzmann/arduino-midi)

View File

@@ -0,0 +1,89 @@
/**
* @file streams-synthbasic-audiokit.ino
* @author Phil Schatzmann
* @brief see https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audio-kit-building-a-simple-synthesizer-with-the-audiotools-library/)
* Midi Support
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include <Midi.h>
SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> sine_stream(sine);
ADSRGain adsr(0.0001,0.0001, 0.9 , 0.0002);
AudioEffectStream effects(sine_stream);
AudioBoardStream kit(AudioKitEs8388V1);
StreamCopy copier(kit, effects);
class SynthAction : public MidiAction {
public:
void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity) {
int frq = MidiCommon::noteToFrequency(note);
sine.setFrequency(frq);
adsr.keyOn();
}
void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity) {
adsr.keyOff();
}
void onControlChange(uint8_t channel, uint8_t controller, uint8_t value) {}
void onPitchBend(uint8_t channel, uint8_t value) {}
} action;
MidiBleServer ble("MidiServer", &action);
void actionKeyOn(bool active, int pin, void* ptr){
Serial.println("KeyOn");
float freq = *((float*)ptr);
sine.setFrequency(freq);
adsr.keyOn();
}
void actionKeyOff(bool active, int pin, void* ptr){
Serial.println("KeyOff");
adsr.keyOff();
}
// We want to play some notes on the AudioKit keys
void setupActions(){
// assign buttons to notes
auto act_low = AudioActions::ActiveLow;
static float note[] = {N_C3, N_D3, N_E3, N_F3, N_G3, N_A3}; // frequencies
kit.audioActions().add(kit.getKey(1), actionKeyOn, actionKeyOff, act_low, &(note[0])); // C3
kit.audioActions().add(kit.getKey(2), actionKeyOn, actionKeyOff, act_low, &(note[1])); // D3
kit.audioActions().add(kit.getKey(3), actionKeyOn, actionKeyOff, act_low, &(note[2])); // E3
kit.audioActions().add(kit.getKey(4), actionKeyOn, actionKeyOff, act_low, &(note[3])); // F3
kit.audioActions().add(kit.getKey(5), actionKeyOn, actionKeyOff, act_low, &(note[4])); // G3
kit.audioActions().add(kit.getKey(6), actionKeyOn, actionKeyOff, act_low, &(note[5])); // A3
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
// setup effects
effects.addEffect(adsr);
// Setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
kit.setVolume(80);
// Setup sound generation based on AudioKit settins
sine.begin(cfg, 0);
sine_stream.begin(cfg);
effects.begin(cfg);
// activate keys
setupActions();
}
// copy the data
void loop() {
copier.copy();
kit.processActions();
}

View File

@@ -0,0 +1,13 @@
# Implementing a Synthesizer using the STK Framwork
We can use the STK framework to implement a Synthesizer which receives Midi Messages and translates them
into sound. Here we use a Clarinet...
For [further info see my blog](https://www.pschatzmann.ch/home/2021/12/21/ai-thinker-audiokit-a-simply-synthesizer-with-stk/)
### Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver
- https://github.com/pschatzmann/arduino-midi
- https://github.com/pschatzmann/Arduino-STK

View File

@@ -0,0 +1,65 @@
/**
* @file streams-synthstk-audiokit.ino
* @brief see https://www.pschatzmann.ch/home/2021/12/17/ai-thinker-audiokit-a-simple-synthesizer-with-stk/
* @author Phil Schatzmann
* @copyright Copyright (c) 2021
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "StkAll.h"
AudioBoardStream kit(AudioKitEs8388V1);
Clarinet clarinet(440);
Voicer voicer;
ArdStreamOut output(&kit);
float noteAmplitude = 128;
int group = 0;
void actionKeyOn(bool active, int pin, void* ptr){
float note = *((float*)ptr);
voicer.noteOn(note, noteAmplitude, group);
}
void actionKeyOff(bool active, int pin, void* ptr){
float note = *((float*)ptr);
voicer.noteOff(note, noteAmplitude, group);
}
// We want to play some notes on the AudioKit keys
void setupActions(){
// assign buttons to notes
auto act_low = AudioActions::ActiveLow;
static int note[] = {48,50,52,53,55,57}; // midi keys
kit.audioActions().add(kit.getKey(1), actionKeyOn, actionKeyOff, act_low, &(note[0])); // C3
kit.audioActions().add(kit.getKey(2), actionKeyOn, actionKeyOff, act_low, &(note[1])); // D3
kit.audioActions().add(kit.getKey(3), actionKeyOn, actionKeyOff, act_low, &(note[2])); // E3
kit.audioActions().add(kit.getKey(4), actionKeyOn, actionKeyOff, act_low, &(note[3])); // F3
kit.audioActions().add(kit.getKey(5), actionKeyOn, actionKeyOff, act_low, &(note[4])); // G3
kit.audioActions().add(kit.getKey(6), actionKeyOn, actionKeyOff, act_low, &(note[5])); // A3
}
void setup() {
Serial.begin(9600);
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
voicer.addInstrument(&clarinet, group);
// define data format
auto cfg = kit.defaultConfig(TX_MODE);
cfg.channels = 1;
cfg.bits_per_sample = 16;
cfg.sample_rate = Stk::sampleRate();
cfg.sd_active = false;
kit.begin(cfg);
// play notes with keys
setupActions();
}
void loop() {
for (int j=0;j<1024;j++) {
output.tick( voicer.tick() );
}
kit.processActions();
}

View File

@@ -0,0 +1,22 @@
## Using the AI Thinker ESP32 with Tensoflow Lite to Generate Audio
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board. You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
The starting point is the good overview provided by [the "Hallo World" example of Tensorflow Lite](https://www.tensorflow.org/lite/microcontrollers/get_started_low_level#train_a_model) which describes how to create, train and use a model which based on the __sine function__. Further information can be found in the [Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/Tensorflow-Lite----Audio-Output/_edit)
### Note
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
## Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-audio-driver
- https://github.com/pschatzmann/tflite-micro-arduino-examples

View File

@@ -0,0 +1,206 @@
#pragma once
const unsigned char g_model[] = {
0x20, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x00, 0x00,
0x14, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00,
0x14, 0x00, 0x00, 0x00, 0x18, 0x00, 0x1c, 0x00, 0x14, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
0x28, 0x01, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x98, 0x03, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x10, 0x09, 0x00, 0x00, 0x0c, 0x09, 0x00, 0x00, 0xdc, 0x07, 0x00, 0x00,
0x30, 0x07, 0x00, 0x00, 0xbc, 0x05, 0x00, 0x00, 0x18, 0x05, 0x00, 0x00,
0x94, 0x04, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x00, 0xf0, 0x08, 0x00, 0x00,
0xec, 0x08, 0x00, 0x00, 0xe8, 0x08, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00,
0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x5f,
0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x01, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x34, 0x00, 0xba, 0xf8, 0xff, 0xff,
0x04, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73,
0x65, 0x5f, 0x32, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00,
0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x6d, 0x69, 0x6e, 0x5f,
0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x00, 0x0a, 0xf9, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x31, 0x2e, 0x31, 0x34, 0x2e, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x4d, 0x4c, 0x49, 0x52, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74,
0x65, 0x64, 0x2e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x04, 0x00,
0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x44, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x44, 0x07, 0x00, 0x00, 0xc8, 0x06, 0x00, 0x00, 0x3c, 0x06, 0x00, 0x00,
0x88, 0x05, 0x00, 0x00, 0x24, 0x04, 0x00, 0x00, 0x70, 0x03, 0x00, 0x00,
0xfc, 0x02, 0x00, 0x00, 0x38, 0x02, 0x00, 0x00, 0x1c, 0x01, 0x00, 0x00,
0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0xc0, 0x01, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x5a, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa0, 0xf8, 0xff, 0xff,
0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x54, 0xf9, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09, 0x14, 0x00, 0x00, 0x00,
0x0a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x53, 0x74, 0x61, 0x74,
0x65, 0x66, 0x75, 0x6c, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x65, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x3a, 0x30, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
0x3c, 0xf9, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x2c, 0xce, 0x0a, 0x3c, 0x01, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x10, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x0c, 0xfa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09,
0x14, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x78, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00,
0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31,
0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33, 0x2f, 0x4d, 0x61, 0x74,
0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33,
0x2f, 0x52, 0x65, 0x6c, 0x75, 0x3b, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e,
0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65,
0x5f, 0x33, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00,
0x2c, 0xfa, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0xe4, 0xd1, 0xc0, 0x3b, 0x01, 0x00, 0x00, 0x00,
0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00,
0x07, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0x24, 0xfb, 0xff, 0xff,
0x00, 0x00, 0x00, 0x09, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x52, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32,
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x65, 0x71, 0x75,
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e,
0x73, 0x65, 0x5f, 0x32, 0x2f, 0x52, 0x65, 0x6c, 0x75, 0x3b, 0x73, 0x65,
0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64,
0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41,
0x64, 0x64, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x10, 0x00, 0x00, 0x00, 0x44, 0xfb, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0xdf, 0x47, 0x3c,
0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x6a, 0xfc, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x8c, 0xef, 0xff, 0xff, 0x56, 0xfc, 0xff, 0xff,
0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73,
0x65, 0x5f, 0x34, 0x2f, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00,
0xac, 0xfb, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x22, 0xd9, 0x51, 0x38, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xce, 0xfc, 0xff, 0xff,
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0xa5, 0x8b, 0xca,
0x5e, 0x1d, 0xce, 0x42, 0x9d, 0xce, 0x1f, 0xb0, 0xdf, 0x54, 0x2f, 0x81,
0xc6, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09, 0x10, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x1b, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x34,
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x2c, 0xfc, 0xff, 0xff,
0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0xce, 0x4d, 0x0b, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4e, 0xfd, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x04, 0x00, 0x00,
0x78, 0x0a, 0x00, 0x00, 0x2d, 0x06, 0x00, 0x00, 0x71, 0xf8, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x99, 0x0a, 0x00, 0x00, 0xfe, 0xf7, 0xff, 0xff,
0x0f, 0x05, 0x00, 0x00, 0xd4, 0x09, 0x00, 0x00, 0x47, 0xfe, 0xff, 0xff,
0xb6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0xf7, 0xff, 0xff,
0x4b, 0xf9, 0xff, 0xff, 0x4a, 0x05, 0x00, 0x00, 0x76, 0xfd, 0xff, 0xff,
0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73,
0x65, 0x5f, 0x33, 0x2f, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00,
0xcc, 0xfc, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0xb2, 0x9e, 0x21, 0x39, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xee, 0xfd, 0xff, 0xff,
0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xee, 0xfc, 0x00, 0xec,
0x05, 0x17, 0xef, 0xec, 0xe6, 0xf8, 0x03, 0x01, 0x00, 0xfa, 0xf8, 0xf5,
0xdc, 0xeb, 0x27, 0x14, 0xf1, 0xde, 0xe2, 0xdb, 0xf0, 0xde, 0x31, 0x06,
0x02, 0xe6, 0xee, 0xf9, 0x00, 0x16, 0x07, 0xe0, 0xfe, 0xff, 0xe9, 0x06,
0xe7, 0xef, 0x81, 0x1b, 0x18, 0xea, 0xc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xe0, 0x19,
0x1f, 0x13, 0x36, 0x1c, 0x12, 0xeb, 0x3b, 0x0c, 0xb4, 0xcb, 0xe6, 0x13,
0xfa, 0xeb, 0xf1, 0x06, 0x1c, 0xfa, 0x18, 0xe5, 0xeb, 0xcb, 0x0c, 0xf4,
0xd6, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x09, 0x10, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x1b, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x33,
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x3c, 0xfe, 0xff, 0xff,
0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x6b, 0x01, 0x4f, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x5e, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x77, 0x0b, 0x00, 0x00,
0x53, 0xf6, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x77, 0x0c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x2f, 0x07, 0x00, 0x00, 0x67, 0xf5, 0xff, 0xff,
0x34, 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x86, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73,
0x65, 0x5f, 0x32, 0x2f, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00,
0xdc, 0xfe, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x28, 0xb3, 0xd9, 0x38, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x75, 0x1c, 0x11, 0xe1, 0x0c, 0x81, 0xa5, 0x42,
0xfe, 0xd5, 0xd4, 0xb2, 0x61, 0x78, 0x19, 0xdf, 0x00, 0x00, 0x0e, 0x00,
0x18, 0x00, 0x08, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x10, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x1b, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,
0x61, 0x6c, 0x5f, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32,
0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x74, 0xff, 0xff, 0xff,
0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0xd5, 0x6b, 0x8a, 0x3b, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x08, 0x00, 0x07, 0x00,
0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00,
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x14, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
0x34, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x73, 0x65, 0x72, 0x76,
0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f,
0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x5f, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x3a, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5d, 0x4f, 0xc9, 0x3c,
0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00
};
unsigned int g_model_len = 2408;

View File

@@ -0,0 +1,45 @@
/**
* @file streams-tf-i2s.ino
* @author Phil Schatzmann
* @brief We use Tenorflow lite to generate some audio data and output it via I2S to the AudioKit
* @version 0.1
* @date 2022-04-07
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/TfLiteAudioStream.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "model.h"
TfLiteSineReader tf_reader(20000,0.3); // Audio generation logic
TfLiteAudioStream tf_stream; // Audio source -> no classification so N is 0
AudioBoardStream i2s(AudioKitEs8388V1); // Audio destination
StreamCopy copier(i2s, tf_stream); // copy tf_stream to i2s
int channels = 1;
int samples_per_second = 16000;
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// Setup tensorflow input
auto tcfg = tf_stream.defaultConfig();
tcfg.channels = channels;
tcfg.sample_rate = samples_per_second;
tcfg.kTensorArenaSize = 2 * 1024;
tcfg.model = g_model;
tcfg.reader = &tf_reader;
tf_stream.begin(tcfg);
// setup Audioi2s output
auto cfg = i2s.defaultConfig(TX_MODE);
cfg.channels = channels;
cfg.sample_rate = samples_per_second;
i2s.begin(cfg);
}
void loop() { copier.copy(); }

View File

@@ -0,0 +1,3 @@
# Basic API
Using the A2DP Callback directly is usually much more efficient then the A2DPStream which set up an additional buffer

View File

@@ -0,0 +1,55 @@
/**
* @file base-BufferRTOS.ino
* @author Phil Schatzmann
* @brief Data provider on core 0 with data consumer on core 1
* @version 0.1
* @date 2022-11-25
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/Concurrency.h" // https://github.com/pschatzmann/arduino-freertos-addons
BufferRTOS<int16_t> buffer(1024);
void doWrite(); // forward declaration
Task writeTask("write",5000,10, 0); // FreeRTOS task from addons
// create data and write it to buffer
void doWrite() {
int16_t data[512];
for (int j=0;j<512;j++){
data[j]=j;
}
buffer.writeArray(data, 512);
}
void setup(){
// Setup logging
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start on core 0
writeTask.begin(doWrite);
}
// The loop runs on core 1: We read back the data
void loop(){
int16_t data[512];
uint64_t start = micros();
buffer.readArray(data, 512);
// process (verify) data
int error=0;
for (int j=0;j<512;j++){
if(data[j]!=j){
error++;
}
}
// write result
Serial.print("error: ");
Serial.print(error);
Serial.print(" runtime: ");
Serial.println(micros()-start);
}

View File

@@ -0,0 +1,86 @@
/**
* @file base-adc-average-mono-serial.ino
* @brief Attempts down sampling with binning of a mono audio signal by AVG_LEN
* @author Urs Utzinger
* @copyright GPLv3
**/
#include "Arduino.h"
#include "AudioTools.h"
// On board analog to digital converter
AnalogAudioStream analog_in;
// Serial terminal output
CsvOutput<int16_t> serial_out(Serial);
#define BAUD_RATE 500000
#define SAMPLE_RATE 44100
#define BUFFER_SIZE 256
#define AVG_LEN 64
#define BYTES_PER_SAMPLE sizeof(int16_t)
// buffer to read samples and store the average samples
int16_t buffer[BUFFER_SIZE];
void setup() {
delay(3000); // wait for serial to become available
// Serial Interface
Serial.begin(BAUD_RATE);
// Include logging to serial
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Error); // Debug, Warning, Info, Error
// Start ADC input
Serial.println("Starting ADC...");
auto adcConfig = analog_in.defaultConfig(RX_MODE);
adcConfig.sample_rate = SAMPLE_RATE;
adcConfig.channels = 1;
// For ESP32 by Espressif Systems version 3.0.0 and later:
// see examples/README_ESP32.md
// adcConfig.sample_rate = 44100;
// adcConfig.adc_bit_width = 12;
// adcConfig.adc_calibration_active = true;
// adcConfig.is_auto_center_read = false;
// adcConfig.adc_attenuation = ADC_ATTEN_DB_12;
// adcConfig.channels = 1;
// adcConfig.adc_channels[0] = ADC_CHANNEL_4;
analog_in.begin(adcConfig);
// Start Serial Output CSV
Serial.println("Starting Serial Out...");
auto csvConfig = serial_out.defaultConfig();
csvConfig.sample_rate = SAMPLE_RATE/AVG_LEN;
csvConfig.channels = 1;
csvConfig.bits_per_sample = 16;
serial_out.begin(csvConfig);
}
void loop() {
// Read the values from the ADC buffer to local buffer
size_t bytes_read = analog_in.readBytes((uint8_t*) buffer, BUFFER_SIZE * BYTES_PER_SAMPLE); // read byte stream and cast to destination type
size_t samples_read = bytes_read/BYTES_PER_SAMPLE;
size_t avg_samples = samples_read/AVG_LEN;
// Average the samples over AVG_LEN
int32_t sum; // register to hold summed values
int16_t *sample = (int16_t*) buffer; // sample pointer (input)
int16_t *avg = (int16_t*) buffer; // result pointer (output)
// each time we access a sample we increment sample pointer
for(uint16_t j=0; j<avg_samples; j++){
sum = *sample++; // initialize sum
for (uint16_t i=1; i<AVG_LEN; i++){
sum += *sample++; // sum the samples
}
// compute average and store in output buffer
*avg++ = (int16_t) (sum/AVG_LEN);
}
serial_out.write((uint8_t*)buffer, avg_samples*BYTES_PER_SAMPLE); // stream to output as byte type
}

View File

@@ -0,0 +1,60 @@
# ESP32 Analog to Digital Conversion Throughput using Continuous ADC API
Data is reported in bytes per second when using a single ADC unit and two A/D channels.
When each channel is measured with 4,000 samples per second the ADC is running at 8,000 samples per second as it multiplexes between the two channels.
The maximum sampling frequency depends on the ESP32 model.
The older ESP32 models can convert up to 2 Million samples per second, however there is discrepancy between the expected and effective throughput of about 20%.
The library creates int16_t datatype which is 2 bytes per sample.
## Adafruit Feather ESP32-S3 2MB PSRAM
```
SPS : expected, measured
150: error, sample rate eff: 300, range: 611 to 83,333
306: 1,224, 1,000
4,000: 16,000, 16,000
8,000: 32,000, 32,000
11,025: 44,100, 44,000
16,000: 64,000, 64,000
20,000: 80,000, 80,000
22,050: 88,200, 89,000
40,000: 160,000, 161,000
44,100: error, sample rate eff: 88,200, range: 611 to 83,333
```
## Sparkfun ESP32 WROOM Plus C
```
Data: bytes per second, single unit, two channels
SPS/CH expected, measured % of expected
5000: error, sample rate eff: 10000, range: 20000 to 2000000
10000: 40,000, 32,000
22050: 88,200, 72,000
44100: 176,400, 144,000
88200: 352,800, 157,000
500000: 2,000,000, 1,635,000
1000000: 4,000,000, 3,271,000
```
## DOIT ESP32 DEVKIT V1
```
Data: bytes per second, single unit, two channels
SPS : expected, measured 80% of expected
5000: error, sample rate: 5000, range: 10000 to 1000000
10000: 40,000, 32,000
20000: 80,000, 64,000
22050: 88,200, 72,000
44100: 176,400, 144,000
48000: 192,000, 156,000
88200: 352,800, 288,000
96000: 384,000, 313,000
176400: 705,600, 576,000
192200: 768,800, 628,000
352800: 1,411,200, 1,153,000
384000: 1,536,000, 1,256,000
500000: 2,000,000, 1,635,000
1000000: 4,000,000, 3,271,000
1500000: error, sample rate: 1500000, range: 10000 to 1000000
```

View File

@@ -0,0 +1,53 @@
/**
* Internal ADC: It depdens pretty much on our processor & arduino version if and how
* this is supported.
*/
#include "Arduino.h"
#include "AudioTools.h"
// On board analog to digital converter
AnalogAudioStream analog_in;
// Measure throughput
MeasuringStream measure(1000, &Serial);
// Copy input to output
StreamCopy copier(measure, analog_in);
void setup() {
delay(3000); // wait for serial to become available
// Serial Interface
Serial.begin(115200);
// Include logging to serial
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info); //Warning, Info, Error, Debug
// Configure ADC input
auto adcConfig = analog_in.defaultConfig(RX_MODE);
// For ESP32 by Espressif Systems version 3.0.0 and later
// see examples/README_ESP32.md
// adcConfig.sample_rate = 22050;
// adcConfig.adc_bit_width = 12;
// adcConfig.adc_calibration_active = true;
// adcConfig.is_auto_center_read = false;
// adcConfig.adc_attenuation = ADC_ATTEN_DB_12;
// adcConfig.channels = 2;
// adcConfig.adc_channels[0] = ADC_CHANNEL_4;
// adcConfig.adc_channels[1] = ADC_CHANNEL_5;
adcConfig.sample_rate = 44100; // per channel
Serial.println("Starting ADC...");
analog_in.begin(adcConfig);
// Start Measurements
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); //Warning, Debug, Info, Error
Serial.println("Starting through put measurement...");
}
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,25 @@
# Stream Analog input to Serial
We can read an analog signal from a microphone and and write it out to Serial so that we can check the result in the __Arduino Serial Plotter__. To test the functionality I am using a MCP6022 microphone module.
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022.jpeg)
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022-1.jpeg)
The MCP6022 is a anlog microphone which operates at 3.3 V
We sample the sound signal with the help of the ESP32 I2S ADC input functionality.
### Pins:
| MCP6022 | ESP32
|---------|---------------
| VCC | 3.3
| GND | GND
| OUT | GPIO34
## Serial Plotter
![Serial](https://pschatzmann.github.io/Resources/img/serial_plotter.png)

View File

@@ -0,0 +1,62 @@
/**
* @file adc-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/adc-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
* #TODO retest is outstanding
*/
#include "Arduino.h"
#include "AudioTools.h"
/**
* @brief We use a mcp6022 analog microphone on GPIO34 and write it to Serial
*/
AnalogAudioStream adc;
const int32_t max_buffer_len = 1024;
uint8_t buffer[max_buffer_len];
// The data has a center of around 26427, so we we need to shift it down to bring the center to 0
ConverterScaler<int16_t> scaler(1.0, -26427, 32700 );
// Arduino Setup
void setup(void) {
delay(3000); // wait for serial to become available
Serial.begin(115200);
// Include logging to serial
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info); //Warning, Info, Error, Debug
Serial.println("starting ADC...");
auto adcConfig = adc.defaultConfig(RX_MODE);
// For ESP32 by Espressif Systems version 3.0.0 and later:
// see examples/README_ESP32.md
// adcConfig.sample_rate = 44100;
// adcConfig.adc_bit_width = 12;
// adcConfig.adc_calibration_active = true;
// adcConfig.is_auto_center_read = false;
// adcConfig.adc_attenuation = ADC_ATTEN_DB_12;
// adcConfig.channels = 2;
// adcConfig.adc_channels[0] = ADC_CHANNEL_4;
// adcConfig.adc_channels[1] = ADC_CHANNEL_5;
adc.begin(adcConfig);
}
// Arduino loop - repeated processing
void loop() {
size_t len = adc.readBytes(buffer, max_buffer_len);
// move center to 0 and scale the values
scaler.convert(buffer, len);
int16_t *sample = (int16_t*) buffer;
int size = len / 4;
for (int j=0; j<size; j++){
Serial.print(*sample++);
Serial.print(", ");
Serial.println(*sample++);
}
}

View File

@@ -0,0 +1,37 @@
/**
* @file file_raw-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/file_raw-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
File sound_file;
const char* file_name = "/audio.raw";
const int sd_ss_pin = 5;
const int32_t max_buffer_len = 512;
int32_t buffer[max_buffer_len][2];
// Arduino Setup
void setup(void) {
Serial.begin(115200);
// Setup SD and open file
SD.begin(sd_ss_pin);
sound_file = SD.open(file_name, FILE_READ);
}
// Arduino loop - repeated processing
void loop() {
size_t len = sound_file.read((uint8_t*)buffer, max_buffer_len * sizeof(int16_t) * 2 );
for (size_t j=0;j<len;j++){
Serial.print(buffer[j][0]);
Serial.print(", ");
Serial.println(buffer[j][1]);
}
}

View File

@@ -0,0 +1,5 @@
# Communication Examples
You can transmit audio information over a wire or (e.g. if you have an ESP32) wirelessly. It is important that you make sure that the transmitted amount of audio data is below the transmission capacity of the medium (e.g. by limiting the channels, the sample rate or the bits per sample).
You can also use [one of the many supported CODECs](https://github.com/pschatzmann/arduino-audio-tools/wiki/Encoding-and-Decoding-of-Audio) to decrease the transmitted amount of data!

View File

@@ -0,0 +1,17 @@
## Using the AI Thinker ESP32 Audio Kit as A2DP Receiver
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
I am using the data callback of the A2DP library to feed the AudioBoardStream
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
## Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/ESP32-A2DP
- https://github.com/pschatzmann/arduino-audio-driver

View File

@@ -0,0 +1,37 @@
/**
* @file basic-a2dp-audiokit.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/basic-a2dp-audiokit/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h" // install https://github.com/pschatzmann/ESP32-A2DP
#include "AudioTools/AudioLibs/AudioBoardStream.h" // install https://github.com/pschatzmann/arduino-audio-driver
BluetoothA2DPSink a2dp_sink;
AudioBoardStream kit(AudioKitEs8388V1);
// Write data to AudioKit in callback
void read_data_stream(const uint8_t *data, uint32_t length) {
kit.write(data, length);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
// register callback
a2dp_sink.set_stream_reader(read_data_stream, false);
a2dp_sink.start("AudioKit");
}
void loop() {
}

View File

@@ -0,0 +1,17 @@
## Using the AI Thinker ESP32 Audio Kit as A2DP Receiver with Equalizer
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress.
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
I am using the data callback of the A2DP library to feed the AudioBoardStream that will be controlled by an Equalizer
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
## Dependencies
You need to install the following libraries:
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/ESP32-A2DP
- https://github.com/pschatzmann/arduino-audio-driver

View File

@@ -0,0 +1,51 @@
/**
* @file basic-a2dp-audiokit.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/basic-a2dp-audiokit/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h" // install https://github.com/pschatzmann/ESP32-A2DP
#include "AudioTools/AudioLibs/AudioBoardStream.h" // install https://github.com/pschatzmann/arduino-audio-driver
BluetoothA2DPSink a2dp_sink;
AudioBoardStream kit(AudioKitEs8388V1);
Equalizer3Bands eq(kit);
ConfigEqualizer3Bands cfg_eq;
// Write data to AudioKit in callback
void read_data_stream(const uint8_t *data, uint32_t length) {
eq.write(data, length);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false;
kit.begin(cfg);
// max volume
kit.setVolume(1.0);
// setup equilizer
cfg_eq = eq.defaultConfig();
cfg_eq.setAudioInfo(cfg); // use channels, bits_per_sample and sample_rate from kit
cfg_eq.gain_low = 0.5;
cfg_eq.gain_medium = 0.5;
cfg_eq.gain_high = 1.0;
eq.begin(cfg_eq);
// register callback
a2dp_sink.set_stream_reader(read_data_stream, false);
a2dp_sink.start("AudioKit");
}
void loop() {
}

View File

@@ -0,0 +1,68 @@
/**
* @file basic-a2dp-fft-led.ino
* @brief A2DP Sink with output of the FFT result to the LED matrix
* For details see the FFT Wiki: https://github.com/pschatzmann/arduino-audio-tools/wiki/FFT
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include <FastLED.h> // to prevent conflicts introduced with 3.9
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioRealFFT.h" // or any other supported inplementation
#include "AudioTools/AudioLibs/LEDOutput.h"
#include "BluetoothA2DPSink.h"
#define PIN_LEDS 22
#define LED_X 32
#define LED_Y 8
BluetoothA2DPSink a2dp_sink;
AudioRealFFT fft; // or any other supported inplementation
FFTDisplay fft_dis(fft);
LEDOutput led(fft_dis); // output to LED matrix
// Provide data to FFT
void writeDataStream(const uint8_t *data, uint32_t length) {
fft.write(data, length);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// Setup FFT
auto tcfg = fft.defaultConfig();
tcfg.length = 1024;
tcfg.channels = 2;
tcfg.sample_rate = a2dp_sink.sample_rate();;
tcfg.bits_per_sample = 16;
fft.begin(tcfg);
// Setup LED matrix output
auto lcfg = led.defaultConfig();
lcfg.x = LED_X;
lcfg.y = LED_Y;
led.begin(lcfg);
fft_dis.fft_group_bin = 3;
fft_dis.fft_start_bin = 0;
fft_dis.fft_max_magnitude = 40000;
fft_dis.begin();
// add LEDs
FastLED.addLeds<WS2812B, PIN_LEDS, GRB>(led.ledData(), led.ledCount());
// register A2DP callback
a2dp_sink.set_stream_reader(writeDataStream, false);
// Start Bluetooth Audio Receiver
Serial.print("starting a2dp-fft...");
a2dp_sink.set_auto_reconnect(false);
a2dp_sink.start("a2dp-fft");
}
void loop() {
led.update();
delay(50);
}

View File

@@ -0,0 +1,59 @@
/**
* @file basic-a2dp-fft.ino
* @brief A2DP Sink with output to FFT.
* For details see the FFT Wiki: https://github.com/pschatzmann/arduino-audio-tools/wiki/FFT
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioRealFFT.h" // or any other supported inplementation
#include "BluetoothA2DPSink.h"
BluetoothA2DPSink a2dp_sink;
AudioRealFFT fft; // or any other supported inplementation
// Provide data to FFT
void writeDataStream(const uint8_t *data, uint32_t length) {
fft.write(data, length);
}
// display fft result
void fftResult(AudioFFTBase &fft){
float diff;
auto result = fft.result();
if (result.magnitude>100){
Serial.print(result.frequency);
Serial.print(" ");
Serial.print(result.magnitude);
Serial.print(" => ");
Serial.print(result.frequencyAsNote(diff));
Serial.print( " diff: ");
Serial.println(diff);
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// Setup FFT
auto tcfg = fft.defaultConfig();
tcfg.length = 4096;
tcfg.channels = 2;
tcfg.sample_rate = a2dp_sink.sample_rate();;
tcfg.bits_per_sample = 16;
tcfg.callback = &fftResult;
fft.begin(tcfg);
// register callback
a2dp_sink.set_stream_reader(writeDataStream, false);
// Start Bluetooth Audio Receiver
Serial.print("starting a2dp-fft...");
a2dp_sink.set_auto_reconnect(false);
a2dp_sink.start("a2dp-fft");
}
void loop() { delay(100); }

View File

@@ -0,0 +1,43 @@
/**
* @file basic-a2dp-audioi2s.ino
* @brief A2DP Sink with output to I2SStream. This example is of small value
* since my Bluetooth Library already provides I2S output out of the box.
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "BluetoothA2DPSink.h"
BluetoothA2DPSink a2dp_sink;
I2SStream i2s;
// Write data to I2S
void read_data_stream(const uint8_t *data, uint32_t length) {
i2s.write(data, length);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// register callback
a2dp_sink.set_stream_reader(read_data_stream, false);
// Start Bluetooth Audio Receiver
a2dp_sink.set_auto_reconnect(false);
a2dp_sink.start("a2dp-i2s");
// setup output
auto cfg = i2s.defaultConfig();
cfg.pin_data = 23;
cfg.sample_rate = a2dp_sink.sample_rate();
cfg.channels = 2;
cfg.bits_per_sample = 16;
cfg.buffer_count = 8;
cfg.buffer_size = 256;
i2s.begin(cfg);
}
void loop() { delay(100); }

View File

@@ -0,0 +1,73 @@
/**
* @file basic-a2dp-mixer-i2s.ino
* @brief A2DP Sink with output to mixer: I think this is the most efficient way
* of mixing a signal that is coming from A2DP which requires only 160 byte of additional RAM.
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "BluetoothA2DPSink.h"
AudioInfo info(44100, 2, 16);
BluetoothA2DPSink a2dp_sink;
I2SStream i2s;
SineWaveGenerator<int16_t> sineWave(10000); // subclass of SoundGenerator with max amplitude of 10000
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
OutputMixer<int16_t> mixer(i2s, 2); // output mixer with 2 outputs
const int buffer_size = 80; // split up the output into small chunks
uint8_t sound_buffer[buffer_size];
// Write data to mixer
void read_data_stream(const uint8_t *data, uint32_t length) {
// To keep the mixing buffer small we split up the output into small chunks
int count = length / buffer_size + 1;
for (int j = 0; j < count; j++) {
const uint8_t *start = data + (j * buffer_size);
const uint8_t *end = min(data + length, start + buffer_size);
int len = end - start;
if (len > 0) {
// write a2dp
mixer.write(start, len);
// write sine tone with identical length
sound.readBytes(sound_buffer, len);
mixer.write(sound_buffer, len);
// We could flush to force the output but this is not necessary because we
// were already writing all 2 streams mixer.flushMixer();
}
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup Output mixer with min necessary memory
mixer.begin(buffer_size);
// Register data callback
a2dp_sink.set_stream_reader(read_data_stream, false);
// Start Bluetooth Audio Receiver
a2dp_sink.set_auto_reconnect(false);
a2dp_sink.start("a2dp-i2s");
// Update sample rate
info.sample_rate = a2dp_sink.sample_rate();
// start sine wave
sineWave.begin(info, N_B4);
// setup output
auto cfg = i2s.defaultConfig();
cfg.copyFrom(info);
// cfg.pin_data = 23;
cfg.buffer_count = 8;
cfg.buffer_size = 256;
i2s.begin(cfg);
}
void loop() { delay(100); }

View File

@@ -0,0 +1,23 @@
# Stream Analog input to A2DP Bluetooth
We can read an analog signal from a microphone and and send it to a Bluetooth A2DP device. To test the functionality I am using a MCP6022 microphone module.
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022.jpeg)
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022-1.jpeg)
The MCP6022 is a anlog microphone which operates at 3.3 V
We sample the sound signal with the help of the ESP32 I2S ADC input functionality.
### Pins:
| MCP6022 | ESP32
|---------|---------------
| VCC | 3.3
| GND | GND
| OUT | GPIO34
### Dependencies
- https://github.com/pschatzmann/ESP32-A2DP.git

View File

@@ -0,0 +1,47 @@
/**
* @file basic-adc-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-communication/a2dp/basic-adc-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "BluetoothA2DPSource.h"
/**
* @brief We use a mcp6022 analog microphone as input and send the data to A2DP
*/
AnalogAudioStream adc;
BluetoothA2DPSource a2dp_source;
// callback used by A2DP to provide the sound data
int32_t get_sound_data(Frame* frames, int32_t frameCount) {
uint8_t *data = (uint8_t*)frames;
int frameSize = 4;
size_t resultBytes = adc.readBytes(data, frameCount*frameSize);
return resultBytes/frameSize;
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
// start i2s input with default configuration
Serial.println("starting I2S-ADC...");
adc.begin(adc.defaultConfig(RX_MODE));
// start the bluetooth
Serial.println("starting A2DP...");
a2dp_source.set_auto_reconnect(false);
a2dp_source.set_data_callback_in_frames(get_sound_data);
a2dp_source.start("MyMusic");
}
// Arduino loop - repeated processing
void loop() {
delay(1000);
}

View File

@@ -0,0 +1,44 @@
/**
* @file base-audiokit-a2dp.ino
* @author Phil Schatzmann
* @brief We play the input from the ADC to an A2DP speaker
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/Communication/A2DPStream.h"
AudioInfo info(44100, 2, 16);
BluetoothA2DPSource a2dp_source;
AudioBoardStream i2s(AudioKitEs8388V1);
const int16_t BYTES_PER_FRAME = 4;
// callback used by A2DP to provide the sound data - usually len is 128 2 channel int16 frames
int32_t get_sound_data(Frame* data, int32_t frameCount) {
return i2s.readBytes((uint8_t*)data, frameCount*BYTES_PER_FRAME)/BYTES_PER_FRAME;
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start i2s input with default configuration
Serial.println("starting I2S...");
auto cfg = i2s.defaultConfig(RX_MODE);
cfg.i2s_format = I2S_STD_FORMAT; // or try with I2S_LSB_FORMAT
cfg.copyFrom(info);
cfg.input_device = ADC_INPUT_LINE2; // microphone
i2s.begin(cfg);
// start the bluetooth
Serial.println("starting A2DP...");
a2dp_source.set_data_callback_in_frames(get_sound_data);
a2dp_source.start("LEXON MINO L");
}
// Arduino loop - repeated processing
void loop() {
delay(1000);
}

View File

@@ -0,0 +1,53 @@
// We use the decoding on the input side to provid pcm data
#include "SPI.h"
#include "SD.h"
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
//#include "AudioTools/AudioLibs/AudioBoardStream.h" // for SPI pins
File file;
MP3DecoderHelix mp3; // or change to MP3DecoderMAD
EncodedAudioStream decoder(&file, &mp3);
BluetoothA2DPSource a2dp_source;
const int chipSelect = SS; //PIN_AUDIO_KIT_SD_CARD_CS;
// callback used by A2DP to provide the sound data - usually len is 128 2 channel int16 frames
int32_t get_sound_data(uint8_t* data, int32_t size) {
int32_t result = decoder.readBytes((uint8_t*)data, size);
delay(1); // feed the dog
return result;
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// open file
//SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
SD.begin(chipSelect);
file = SD.open("/test.mp3", FILE_READ);
if (!file) {
Serial.println("file failed");
stop();
}
// make sure we have enough space for the pcm data
decoder.transformationReader().resizeResultQueue(1024 * 8);
if (!decoder.begin()) {
Serial.println("decoder failed");
stop();
}
// start the bluetooth
Serial.println("starting A2DP...");
a2dp_source.set_data_callback(get_sound_data);
a2dp_source.start("LEXON MINO L");
}
// Arduino loop - repeated processing
void loop() {
delay(1000);
}

View File

@@ -0,0 +1,45 @@
/**
* @file basic-generator-a2dp.ino
* @author Phil Schatzmann
* @brief We send a test sine signal to a bluetooth speaker
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
const char* name = "LEXON MINO L"; // Replace with your bluetooth speaker name
SineWaveGenerator<int16_t> sineWave(15000); // subclass of SoundGenerator, set max amplitude (=volume)
GeneratedSoundStream<int16_t> in_stream(sineWave); // Stream generated from sine wave
BluetoothA2DPSource a2dp_source; // A2DP Sender
// callback used by A2DP to provide the sound data - usually len is 128 * 2 channel int16 frames
int32_t get_sound_data(uint8_t * data, int32_t len) {
return in_stream.readBytes((uint8_t*)data, len);
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start input
auto cfg = in_stream.defaultConfig();
cfg.bits_per_sample = 16;
cfg.channels = 2;
cfg.sample_rate = 44100;
in_stream.begin(cfg);
sineWave.begin(cfg, N_B4);
// start the bluetooth
Serial.println("starting A2DP...");
a2dp_source.set_auto_reconnect(false);
a2dp_source.set_data_callback(get_sound_data);
a2dp_source.start(name);
}
// Arduino loop - repeated processing
void loop() {
delay(1000);
}

View File

@@ -0,0 +1,35 @@
# Stream I2S Input to A2DP Bluetooth
## General Description:
We implement a A2DP source: We stream the sound input which we read in from the I2S interface to a A2DP sink. We can use any device which provides the sound data via I2S. In order to test the functionality we use the INMP441 microphone.
![INMP441](https://pschatzmann.github.io/Resources/img/inmp441.jpeg)
The INMP441 is a high-performance, low power, digital-output, omnidirectional MEMS microphone with a bottom port. The complete INMP441 solution consists of a MEMS sensor, signal conditioning, an analog-to-digital converter, anti-aliasing filters, power management, and an industry-standard 24-bit I²S interface. The I²S interface allows the INMP441 to connect directly to digital processors, such as DSPs and microcontrollers, without the need for an audio codec in the system.
## Pins
| INMP441 | ESP32
| --------| ---------------
| VDD | 3.3
| GND | GND
| SD | IN (GPIO32)
| L/R | GND
| WS | WS (GPIO15)
| SCK | BCK (GPIO14)
SCK: Serial data clock for I²S interface
WS: Select serial data words for the I²S interface
L/R: Left / right channel selection
When set to low, the microphone emits signals on one channel of the I²S frame.
When the high level is set, the microphone will send signals on the other channel.
ExSD: Serial data output of the I²S interface
VCC: input power 1.8V to 3.3V
GND: Power groundHigh PSR: -75 dBFS.
### Dependencies
- https://github.com/pschatzmann/ESP32-A2DP.git

View File

@@ -0,0 +1,51 @@
/**
* @file basic-i2s-a2dp.ino
* @author Phil Schatzmann
* @brief We use a INMP441 I2S microphone as input and send the data to A2DP
* Unfortunatly the data type from the microphone (int32_t) does not match with
* the required data type by A2DP (int16_t), so we need to convert.
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
AudioInfo info32(44100, 2, 32);
AudioInfo info16(44100, 2, 16);
BluetoothA2DPSource a2dp_source;
I2SStream i2s;
FormatConverterStream conv(i2s);
const int BYTES_PER_FRAME = 4;
int32_t get_sound_data(Frame* data, int32_t frameCount) {
return conv.readBytes((uint8_t*)data, frameCount*BYTES_PER_FRAME)/BYTES_PER_FRAME;
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup conversion
conv.begin(info32, info16);
// start i2s input with default configuration
Serial.println("starting I2S...");
auto cfg = i2s.defaultConfig(RX_MODE);
cfg.i2s_format = I2S_STD_FORMAT; // or try with I2S_LSB_FORMAT
cfg.copyFrom(info32);
cfg.is_master = true;
i2s.begin(cfg);
// start the bluetooth
Serial.println("starting A2DP...");
// a2dp_source.set_auto_reconnect(false);
a2dp_source.set_data_callback_in_frames(get_sound_data);
a2dp_source.start("LEXON MINO L");
Serial.println("A2DP started");
}
// Arduino loop - repeated processing
void loop() { delay(1000); }

View File

@@ -0,0 +1,66 @@
/**
* @file basic-player-a2dp.ino
* @author Phil Schatzmann
* @brief Sketch which uses the A2DP callback to provide data from the AudioPlayer via a Queue
* The queue is filled by the Arduino loop.
* @version 0.1
* @date 2022-12-04
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/Disk/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
//#include "AudioTools/AudioLibs/AudioBoardStream.h" // for SD Pins
const int cs = 33; //PIN_AUDIO_KIT_SD_CARD_CS;
const int buffer_size = 15*1024;
const char *startFilePath = "/";
const char *ext = "mp3";
AudioSourceSDFAT source(startFilePath, ext, cs);
MP3DecoderHelix decoder;
//Setup of synchronized buffer
BufferRTOS<uint8_t> buffer(0);
QueueStream<uint8_t> out(buffer); // convert Buffer to Stream
AudioPlayer player(source, out, decoder);
BluetoothA2DPSource a2dp;
// Provide data to A2DP
int32_t get_data(uint8_t *data, int32_t bytes) {
size_t result_bytes = buffer.readArray(data, bytes);
//LOGI("get_data_channels %d -> %d of (%d)", bytes, result_bytes , buffer.available());
return result_bytes;
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// allocate in PSRAM only possible in setup or loop
buffer.resize(buffer_size);
// sd_active is setting up SPI with the right SD pins by calling
// SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
// start QueueStream when 95% full
out.begin(95);
// setup player
player.setDelayIfOutputFull(0);
player.setVolume(0.1);
player.begin();
// start a2dp source
Serial.println("starting A2DP...");
a2dp.set_data_callback(get_data);
a2dp.start("LEXON MINO L");
Serial.println("Started!");
}
void loop() {
// decode data to buffer
player.copy();
}

View File

@@ -0,0 +1,87 @@
/**
* @file player-sdfat_a2dp-audiokit.ino
* @author Phil Schatzmann
* @brief Swithcing between Player and A2DP
* @version 0.1
* @date 2022-04-21
*
* @copyright Copyright (c) 2022
*
*/
// install https://github.com/greiman/SdFat.git
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/Disk/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const char *startFilePath="/";
const char* ext="mp3";
AudioBoardStream kit(AudioKitEs8388V1);
SdSpiConfig sdcfg(PIN_AUDIO_KIT_SD_CARD_CS, DEDICATED_SPI, SD_SCK_MHZ(10) , &SPI);
AudioSourceSDFAT source(startFilePath, ext, sdcfg);
MP3DecoderHelix decoder;
AudioPlayer player(source, kit, decoder);
BluetoothA2DPSink a2dp_sink;
bool player_active = true;
// Write data to AudioKit in callback
void read_data_stream(const uint8_t *data, uint32_t length) {
kit.write(data, length);
}
// switch between a2dp and sd player
void mode(bool, int, void*) {
player_active = !player_active;
if (player_active){
Serial.println("Stopping A2DP");
a2dp_sink.end();
// setup player
player.setVolume(0.7);
player.begin();
Serial.println("Player started");
} else {
Serial.println("Stopping player..");
player.end();
// start sink
a2dp_sink.start("AudioKit");
// update sample rate
auto cfg = kit.defaultConfig();
cfg.sample_rate = a2dp_sink.sample_rate();
kit.setAudioInfo(cfg);
Serial.println("A2DP started");
}
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// provide a2dp data
a2dp_sink.set_stream_reader(read_data_stream, false);
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
kit.setVolume(40);
kit.begin(cfg);
// setup additional buttons
kit.addDefaultActions();
kit.addAction(kit.getKey(4), mode);
// setup player
player.setVolume(0.7);
player.begin();
}
void loop() {
if (player) {
player.copy();
} else {
// feed watchdog
delay(10);
}
kit.processActions();
}

View File

@@ -0,0 +1,28 @@
# A Simple SdFat Audio Player
The example demonstrates how to implement an __MP3 Player__: which provides the data from a SD drive and provides the audio via A2DP (e.g. to a Bluetooth Speaker): The __AudioSourceSdFat class__ builds on the [SdFat Library](https://github.com/greiman/SdFat) from Bill Greiman which provides FAT16/FAT32 and exFAT support.
## SD Card
Here is the information how to wire the SD card to the ESP32
| SD | ESP32
|-------|-----------------------
| CS | VSPI-CS0 (GPIO 05)
| SCK | VSPI-CLK (GPIO 18)
| MOSI | VSPI-MOSI (GPIO 23)
| MISO | VSPI-MISO (GPIO 19)
| VCC | VIN (5V)
| GND | GND
![SD](https://www.pschatzmann.ch/wp-content/uploads/2021/04/sd-module.jpeg)
## Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-libhelix
- https://github.com/greiman/SdFat
- https://github.com/pschatzmann/ESP32-A2DP

View File

@@ -0,0 +1,46 @@
/**
* @file player-sdfat-a2dp.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
//remove this, to find issues regarding mp3 decoding
#define HELIX_LOGGING_ACTIVE false
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/Disk/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const char *startFilePath="/";
const char* ext="mp3";
AudioSourceSDFAT source(startFilePath, ext); // , PIN_AUDIO_KIT_SD_CARD_CS);
A2DPStream out;
MP3DecoderHelix decoder;
AudioPlayer player(source, out, decoder);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup player
// Setting up SPI if necessary with the right SD pins by calling
// SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
player.setVolume(0.1);
player.begin();
// setup output - We send the test signal via A2DP - so we conect to a Bluetooth Speaker
auto cfg = out.defaultConfig(TX_MODE);
cfg.silence_on_nodata = true; // prevent disconnect when there is no audio data
cfg.name = "LEXON MINO L"; // set the device here. Otherwise the first available device is used for output
//cfg.auto_reconnect = true; // if this is use we just quickly connect to the last device ignoring cfg.name
out.begin(cfg);
}
void loop() {
player.copy();
}

View File

@@ -0,0 +1,41 @@
/**
* @file streams-a2dp-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-a2dp-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
A2DPStream in;
AudioBoardStream kit(AudioKitEs8388V1);
StreamCopy copier(kit, in); // copy in to out
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start the bluetooth audio receiver
Serial.println("starting A2DP...");
auto cfg = in.defaultConfig(RX_MODE);
cfg.name = "AudioKit";
in.begin(cfg);
// setup the audioKit
auto cfgk = kit.defaultConfig(TX_MODE);
cfgk.copyFrom(in.audioInfo());
kit.begin(cfgk);
}
// Arduino loop
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,3 @@
# Receive Sound Data from Bluetooth A2DP
We receive some music via Bluetooth e.g. from your mobile phone and display it as CSV

View File

@@ -0,0 +1,33 @@
/**
* @file streams-a2dp-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-a2dp-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
A2DPStream in;
CsvOutput<int16_t> out(Serial, 2); // ASCII stream as csv
StreamCopy copier(out, in); // copy in to out
// Arduino Setup
void setup(void) {
Serial.begin(115200);
// start the bluetooth audio receiver
Serial.println("starting A2DP...");
auto cfg = in.defaultConfig(RX_MODE);
cfg.name = "MyReceiver";
in.begin(cfg);
}
// Arduino loop
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,35 @@
/**
* @file basic-a2dp-audiospdif.ino
* @brief A2DP Sink with output to SPDIFOutput
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/SPDIFOutput.h"
#include "BluetoothA2DPSink.h"
AudioInfo info(44100, 2, 16);
SPDIFOutput spdif;
BluetoothA2DPSink a2dp_sink(spdif);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup output
auto cfg = spdif.defaultConfig();
cfg.copyFrom(info);
cfg.buffer_size = 384;
cfg.buffer_count = 30;
cfg.pin_data = 23;
spdif.begin(cfg);
// Start Bluetooth Audio Receiver
a2dp_sink.start("a2dp-spdif");
}
void loop() {
delay(100);
}

View File

@@ -0,0 +1,10 @@
# Test Signal to Bluetooth Speaker
Sometimes it is quite useful to be able to generate a test tone.
We can use the GeneratedSoundStream class together with a SoundGenerator class. In my example I use a SineWaveGenerator.
To test the output I'm using this generated signal and write it to A2DP (e.g. a Bluetooth Speaker).
### Dependencies
- https://github.com/pschatzmann/ESP32-A2DP.git

View File

@@ -0,0 +1,48 @@
/**
* @file streams-generator-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-generator-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
const char* name = "LEXON MINO L"; // Replace with your device name
AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
A2DPStream out; // A2DP output
StreamCopy copier(out, in); // copy in to out
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// set the frequency
sineWave.setFrequency(N_B4);
// Setup sine wave
auto cfg = in.defaultConfig();
cfg.copyFrom(info);
in.addNotifyAudioChange(out);
in.begin(cfg);
// We send the test signal via A2DP - so we conect to the MyMusic Bluetooth Speaker
auto cfgA2DP = out.defaultConfig(TX_MODE);
cfgA2DP.name = name;
//cfgA2DP.auto_reconnect = false;
out.begin(cfgA2DP);
out.setVolume(0.3);
Serial.println("A2DP is connected now...");
}
// Arduino loop
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,34 @@
# Stream I2S Input to A2DP Bluetooth
## General Description:
We implement a A2DP source: We stream the sound input which we read in from the I2S interface to a A2DP sink. We can use any device which provides the sound data via I2S. In order to test the functionality we use the INMP441 microphone. Because the Microphone only provides data on one channel, we the ConverterFillLeftAndRight class to copy the data to the other channel as well.
In this Sketch we are using Streams!
![INMP441](https://pschatzmann.github.io/Resources/img/inmp441.jpeg)
The INMP441 is a high-performance, low power, digital-output, omnidirectional MEMS microphone with a bottom port. The complete INMP441 solution consists of a MEMS sensor, signal conditioning, an analog-to-digital converter, anti-aliasing filters, power management, and an industry-standard 24-bit I²S interface. The I²S interface allows the INMP441 to connect directly to digital processors, such as DSPs and microcontrollers, without the need for an audio codec in the system.
## Pins
| INMP441 | ESP32
| --------| ---------------
| VDD | 3.3
| GND | GND
| SD | IN (GPIO32)
| L/R | GND
| WS | WS (GPIO15)
| SCK | BCK (GPIO14)
- SCK: Serial data clock for I²S interface
- WS: Select serial data words for the I²S interface
- L/R: Left / right channel selection
When set to low, the microphone emits signals on the left channel of the I²S frame.
When the high level is set, the microphone will send signals on the right channel.
- ExSD: Serial data output of the I²S interface
- VCC: input power 1.8V to 3.3V
- GND: Power groundHigh PSR: -75 dBFS.

View File

@@ -0,0 +1,43 @@
/**
* @file streams-i2s-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-i2s-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
I2SStream i2sStream; // Access I2S as stream
A2DPStream a2dpStream; // access A2DP as stream
StreamCopy copier(a2dpStream, i2sStream); // copy i2sStream to a2dpStream
ConverterFillLeftAndRight<int16_t> filler(LeftIsEmpty); // fill both channels
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start bluetooth
Serial.println("starting A2DP...");
auto cfgA2DP = a2dpStream.defaultConfig(TX_MODE);
cfgA2DP.name = "LEXON MINO L";
a2dpStream.begin(cfgA2DP);
// set intial volume
a2dpStream.setVolume(0.3);
// start i2s input with default configuration
Serial.println("starting I2S...");
a2dpStream.addNotifyAudioChange(i2sStream); // i2s is using the info from a2dp
i2sStream.begin(i2sStream.defaultConfig(RX_MODE));
}
// Arduino loop - copy data
void loop() {
// copier.copy(filler);
copier.copy();
}

View File

@@ -0,0 +1,15 @@
# A Simple Synthesizer for the AI Thinker AudioKit to A2DP Bluetooth Speaker
I was taking the streams-synth-audiokit example and converted the output to go to A2DP. In order to minimize the lag
I am not using the Stream API but directly the A2DP Callbacks - which avoids any buffers.
The delay howver is still too big to be really useful...
### Dependencies
You need to install the following libraries:
- [Arduino Audio Tools](https://github.com/pschatzmann/arduino-audio-tools)
- [Midi](https://github.com/pschatzmann/arduino-midi)
- [ESP32-A2DP](https://github.com/pschatzmann/ESP32-A2DP)

View File

@@ -0,0 +1,52 @@
/**
* @file streams-synth-audiokit.ino
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#define USE_MIDI
#include "AudioTools.h" // must be first
#include "AudioTools/AudioLibs/AudioBoardStream.h" // https://github.com/pschatzmann/arduino-audio-driver
#include "BluetoothA2DPSource.h" // https://github.com/pschatzmann/ESP32-A2DP
BluetoothA2DPSource a2dp_source;
int channels = 2;
AudioBoardStream kit(AudioKitEs8388V1);
Synthesizer synthesizer;
GeneratedSoundStream<int16_t> in(synthesizer);
SynthesizerKey keys[] = {{kit.getKey(1), N_C3},{kit.getKey(2), N_D3},{kit.getKey(3), N_E3},{kit.getKey(4), N_F3},{kit.getKey(5), N_G3},{kit.getKey(6), N_A3},{0,0}};
int32_t get_sound_data(Frame *data, int32_t frameCount) {
int frame_size = sizeof(int16_t)*channels;
int16_t samples = synthesizer.readBytes((uint8_t*)data,frameCount*frame_size);
//esp_task_wdt_reset();
delay(1);
return samples/frame_size;
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// setup synthezizer keys
synthesizer.setKeys(kit.audioActions(), keys, AudioActions::ActiveLow);
// define synthesizer keys for AudioKit
synthesizer.setKeys(kit.audioActions(), keys, AudioActions::ActiveLow);
synthesizer.setMidiName("AudioKit Synthesizer");
auto cfg = in.defaultConfig();
cfg.channels = channels;
cfg.sample_rate = 44100;
in.begin(cfg);
a2dp_source.set_data_callback_in_frames(get_sound_data);
a2dp_source.start("LEXON MINO L");
a2dp_source.set_volume(20);
}
void loop() {
kit.processActions();
delay(1);
}

View File

@@ -0,0 +1,47 @@
/**
* @file example-serial-receive.ino
* @author Phil Schatzmann
* @brief Receiving audio via ESPNow and decoding data to I2S
* @version 0.1
* @date 2022-03-09
*
* @copyright Copyright (c) 2022
*/
#include "AudioTools.h"
#include "AudioTools/Communication/ESPNowStream.h"
#include "AudioTools/AudioCodecs/CodecSBC.h"
// #include "AudioTools/AudioLibs/AudioBoardStream.h"
ESPNowStream now;
I2SStream out; // or AudioBoardStream
EncodedAudioStream decoder(&out, new SBCDecoder(256)); // decode and write to I2S - ESP Now is limited to 256 bytes
StreamCopy copier(decoder, now);
const char *peers[] = {"A8:48:FA:0B:93:02"};
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup esp-now
auto cfg = now.defaultConfig();
cfg.mac_address = "A8:48:FA:0B:93:01";
now.begin(cfg);
now.addPeers(peers);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
out.begin(config);
// start decoder
decoder.begin();
Serial.println("Receiver started...");
}
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,41 @@
/**
* @file example-serial-receive_measure.ino
* @author Phil Schatzmann
* @brief Receiving audio via ESPNow with max speed to measure thruput
* @version 0.1
* @date 2022-03-09
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/ESPNowStream.h"
#include "AudioTools/AudioCodecs/CodecSBC.h"
ESPNowStream now;
MeasuringStream out(1000, &Serial);
EncodedAudioStream decoder(&out, new SBCDecoder()); // decode and write to I2S
StreamCopy copier(decoder, now);
const char *peers[] = {"A8:48:FA:0B:93:02"};
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start esp-now
auto cfg = now.defaultConfig();
cfg.mac_address = "A8:48:FA:0B:93:01";
now.begin(cfg);
now.addPeers(peers);
// start output
decoder.begin();
out.begin();
Serial.println("Receiver started...");
}
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,44 @@
/**
* @file example-serial-send.ino
* @author Phil Schatzmann
* @brief Sending encoded audio over ESPNow
* @version 0.1
* @date 2022-03-09
*
* @copyright Copyright (c) 2022
*/
#include "AudioTools.h"
#include "AudioTools/Communication/ESPNowStream.h"
#include "AudioTools/AudioCodecs/CodecSBC.h"
AudioInfo info(32000,1,16);
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave
ESPNowStream now;
SBCEncoder sbc;
EncodedAudioStream encoder(&now, &sbc); // encode and write to ESP-now
StreamCopy copier(encoder, sound); // copies sound into i2s
const char *peers[] = {"A8:48:FA:0B:93:01"};
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
auto cfg = now.defaultConfig();
cfg.mac_address = "A8:48:FA:0B:93:02";
now.begin(cfg);
now.addPeers(peers);
// Setup sine wave
sineWave.begin(info, N_B4);
// start encoder
encoder.begin(info);
Serial.println("Sender started...");
}
void loop() {
copier.copy();
}

Some files were not shown because too many files have changed in this diff Show More