// test of DaisySP synth object for the Teensy audio library #include #include Metro five_sec=Metro(5000); // Set up a 5 second Metro Metro trigger=Metro(250); // envelope trigger #include "daisysp.h" using namespace daisysp; // including the source files is a pain but that way you compile in only the modules you need // DaisySP statically allocates memory and some modules e.g. reverb use a lot of ram #include "synthesis/oscillator.cpp" #include "control/adenv.cpp" #include "filters/moogladder.cpp" #include "effects/reverbsc.cpp" // uses a LOT of ram // constants for integer to float and float to integer conversion #define MULT_16 2147483647 #define DIV_16 4.6566129e-10 float samplerate=AUDIO_SAMPLE_RATE_EXACT; // create daisySP processing objects #define NUM_OSCS 4 Oscillator osc[NUM_OSCS]; Oscillator lfo; AdEnv env; MoogLadder filt; ReverbSc verb; AudioOutputI2S out; 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); // this is the function called by the AudioSynthDaisySP object when it needs a block of samples void AudioSynthDaisySP::update(void) { float out,sig, envelope, filtsig, sendsig, wetvl, wetvr; audio_block_t *block; block = allocate(); // grab an audio block if (!block) { return; } for (int i=0; i < AUDIO_BLOCK_SAMPLES; i++) { //**** insert daisySP generators here sig=0; // sum up oscillators for (int i=0; idata[i] = val >> 16; } transmit(block); release(block); } void setup() { // Init Serial Serial.begin(38400); // wait for Arduino Serial Monitor to be ready // while (!Serial); Serial.println("starting setup"); for (int i=0; i