diff --git a/README.md b/README.md index 08457e5..b07f99b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Teensy Audio processes 128 16 bit integer samples at a time and uses a pool of s In contrast, DaisySP processes one sample at a time using floating point and each function allocates its memory statically. Simple, but uses a lot of memory for things like reverbs and delays and its pretty CPU intensive. -To use DaisySP with Teensy Audio we process 128 samples at a time, convert the floating point results to integer and pass them to the next Teensy audio object in the patch. The DaisySP audio object has a callback function called AudioSynthDaisySP::update which does this. You must have this function in your sketch and this is where you call DaisySP library functions. Look at the example sketch to see how this works. +To use DaisySP with Teensy Audio we process 128 samples at a time, convert the floating point results to integer and pass them to the next Teensy audio object in the patch. The DaisySP audio object has a callback function called AudioSynthDaisySP::update which does this. You must have this function in your sketch and this is where you call DaisySP library functions. Look at the example sketches to see how this works. Installing the library: @@ -39,7 +39,7 @@ Copy the contents of the DaisySP folder to your arduino/library folder Copy the file Teensy/Audio/synth_daisysp.h (the DaisySP audio object) to your Teensy audio library - usually this will be your_Arduino_installation_directory/hardware/teensy/avr/libraries/audio. -Teensy/Audio/Audio.h has been modified to include synth_daisysp.h. You may want to do this manually since I can't guarantee I will be tracking changes to the Teensy Audio library. +Teensy/Audio/Audio.h has a #include synth_daisysp.h so you can replace your Teensy audio library Audio.h with this file. Its probably better edit your existing Audio.h file - I can't guarantee I will be tracking future changes to the Teensy Audio library. I decided to structure the library so you have to manually include the DaisySP *.cpp files you are using in your sketch vs compiling the whole library into the sketch. This is a bit of a pain but including the whole library uses almost 500k of program memory and close to 500k of RAM which leaves very little RAM for the rest of your code. There is currently no provision for using the optional PSRAM on the Teensy 4.1. diff --git a/examples/modal/modal.ino b/examples/modal/modal.ino index 636653b..7dd316b 100644 --- a/examples/modal/modal.ino +++ b/examples/modal/modal.ino @@ -46,7 +46,7 @@ void AudioSynthDaisySP::update(void) return; } - for (int i=0; i < AUDIO_BLOCK_SAMPLES; i++) { + for (int s=0; s < AUDIO_BLOCK_SAMPLES; s++) { //**** insert daisySP generators here @@ -62,7 +62,7 @@ void AudioSynthDaisySP::update(void) // convert generated float value -1.0 to +1.0 to int16 used by Teensy Audio int32_t val = out*MULT_16; - block->data[i] = val >> 16; + block->data[s] = val >> 16; } transmit(block); release(block); diff --git a/examples/polysynth/polysynth.ino b/examples/polysynth/polysynth.ino index e21a06c..12f0c6f 100644 --- a/examples/polysynth/polysynth.ino +++ b/examples/polysynth/polysynth.ino @@ -7,7 +7,7 @@ #include #include -//#define DEBUG // comment out to remove debug code +#define DEBUG // comment out to remove debug code #ifdef DEBUG Metro five_sec=Metro(5000); // Set up a 5 second Metro for performance stats @@ -46,7 +46,7 @@ float lfofreqdepth=0; float lfofilterdepth=0; // create daisySP processing objects -#define OSCSPERVOICE 3 // note - the detune code is set up for 3 oscillators +#define OSCSPERVOICE 4 // note - the detune code is set up for 3 oscillators Oscillator osc[VOICES * OSCSPERVOICE]; Oscillator lfo; @@ -66,7 +66,7 @@ void AudioSynthDaisySP::update(void) return; } - for (int i=0; i < AUDIO_BLOCK_SAMPLES; i++) { + for (int s=0; s < AUDIO_BLOCK_SAMPLES; s++) { //**** insert daisySP generators here @@ -94,7 +94,7 @@ void AudioSynthDaisySP::update(void) // convert generated float value -1.0 to +1.0 to int16 used by Teensy Audio int32_t val = out*MULT_16; - block->data[i] = val >> 16; + block->data[s] = val >> 16; } transmit(block); release(block); diff --git a/examples/teensyaudio/teensyaudio.ino b/examples/teensyaudio/teensyaudio.ino index 96aeb78..f30e825 100644 --- a/examples/teensyaudio/teensyaudio.ino +++ b/examples/teensyaudio/teensyaudio.ino @@ -35,15 +35,15 @@ ReverbSc verb; AudioOutputI2S out; -AudioOutputUSB outUSB; +//AudioOutputUSB outUSB; AudioControlSGTL5000 audioShield; AudioSynthDaisySP synth; // create the daisysp synth audio object AudioConnection patchCord20(synth,0,out,0); AudioConnection patchCord21(synth,0,out,1); -AudioConnection patchCord22(synth,0,outUSB,0); -AudioConnection patchCord23(synth,0,outUSB,1); +//AudioConnection patchCord22(synth,0,outUSB,0); +//AudioConnection patchCord23(synth,0,outUSB,1); @@ -58,7 +58,7 @@ void AudioSynthDaisySP::update(void) return; } - for (int i=0; i < AUDIO_BLOCK_SAMPLES; i++) { + for (int s=0; s < AUDIO_BLOCK_SAMPLES; s++) { //**** insert daisySP generators here @@ -80,7 +80,7 @@ void AudioSynthDaisySP::update(void) // convert generated float value -1.0 to +1.0 to int16 used by Teensy Audio int32_t val = out*MULT_16; - block->data[i] = val >> 16; + block->data[s] = val >> 16; } transmit(block); release(block);