#include #include #include #include Oscil aSin(SIN2048_DATA); #include EventDelay KTriggerDelay; int vol; float freq; int seqStep; int stepGain; int interval; // float stepValue[8] = {261.63, 293.66, 329.62, 349.22, 391.99, 440, 493.88, 523.25}; // float stepValue[8] = {60, 62, 64, 65, 67, 69, 71, 72}; //MIDI // float stepValue[8] = {36, 40, 43, 47, 51, 55, 58, 62}; //MIDI // float stepValue[8] = {36, 43, 40, 51, 47, 58, 55, 62}; //MIDI float stepValue[8] = {53, 58, 55, 60, 53, 58, 55, 62}; //MIDI #define CONTROL_RATE 64 void setup() { startMozzi(CONTROL_RATE); KTriggerDelay.set(125); Serial.begin(115200); } void updateControl(){ stepGain = mozziAnalogRead(0)/60; interval = mozziAnalogRead(1); if(KTriggerDelay.ready()){ seqStep +=1; if(seqStep>=8){ seqStep = 0; } KTriggerDelay.start(interval); } aSin.setFreq(mtof(stepValue[seqStep]+stepGain)); Serial.print("stepGain: "); Serial.print(stepGain); Serial.print(", interval: "); Serial.println(interval); } int updateAudio(){ return aSin.next(); } void loop() { // This is only for experiment audioHook(); }