Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork327
Using the Framework w o Arduino
We support the use of this framework w/o the Arduino API. So you can use it e.g.
- with aSTM32 Cube IDE for STM32 programs
- Espressif IDF
- use it withJupyter in the xeus-cling kernel
Just compile your program after adding this library e.g. with the help of cmake and make sure that the preprocessor variable ARDUINO isnot defined!
The linker will notifiy you about any missing methods that you need to implement: They are declared in AudioLibs/NoArduino.h. Most likely you just need to provide:
- delay() - pause in milliseconds
- HardwareSerial:: write(const uint8_t *buffer, size_t size) - for the output of the logger
- millis() - milliseconds since start
We provide quite a few sound effects and it is a challenge to test them all. In order to make my life a little bit easier I decided to make my framework usable inJupyterlab.
xeus-cling is a Jupyter kernel for C++ based on the C++ interpreter cling and the native implementation of the Jupyter protocol xeus. So we can use the AudioTools directly in Jupyterlab with Xeus/Cling!
Further info can be foundhere
You can use the basic functionality of this framework in IDF. I was testing this in PlatformIO:Rename main.c to main.cpp:Example sketchmain.cpp:
#include"AudioTools.h"uint16_t sample_rate=44100;uint8_t channels =2;// The stream will have 2 channelsSineWaveGenerator<int16_t>sineWave(32000);// subclass of SoundGenerator with max amplitude of 32000GeneratedSoundStream<int16_t>sound(sineWave);// Stream generated from sine waveI2SStream out; StreamCopycopier(out, sound);// copies sound into i2s// Arduino Setupvoidsetup(void) {// start I2Sauto config = out.defaultConfig(TX_MODE); config.sample_rate = sample_rate; config.channels = channels; config.bits_per_sample =16; out.begin(config);// Setup sine wave sineWave.begin(channels, sample_rate, N_B4);}// Arduino loop - copy sound to outvoidloop() { copier.copy();}extern"C"voidapp_main() {setup();while(true)loop();}
platformio.ini
[env:esp32dev]platform = espressif32board = esp32devframework = espidfbuild_unflags = -Werror=allIn the Platfomio.ini file we just make sure that we do not treat warnings as errors!
CMakeLists.txt
# This file was automatically generated for projects# without default 'CMakeLists.txt' file.FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)idf_component_register(SRCS ${app_sources})# add arduino-audio-toolsadd_compile_definitions(-DESP32_CMAKE )- Change the file can be found in thesrc directory!
- Make sure that you check out this project to the components directory or define the location of the library with include_directories
- use -DESP32_CMAKE (which adds a costom implementation of the used Arduino functionality)
- make sure that all necessary pins and constants are defined e.g. with add_compile_definitions
You can configure IDF by opening a PlatformIO terminal and executepio run -t menuconfig