diff --git a/MicroMDAPiano.ino b/MicroMDAPiano.ino index 8ae5878..73905c5 100644 --- a/MicroMDAPiano.ino +++ b/MicroMDAPiano.ino @@ -29,22 +29,24 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce // GUItool: begin automatically generated code AudioPlayQueue queue1; //xy=494,404 +AudioPlayQueue queue2; //xy=494,404 AudioAnalyzePeak peak1; //xy=695,491 +AudioAnalyzePeak peak2; //xy=695,491 #ifdef TEENSY_AUDIO_BOARD AudioOutputI2S i2s1; //xy=1072,364 AudioConnection patchCord1(queue1, peak1); -AudioConnection patchCord2(queue1, 0, i2s1, 0); -AudioConnection patchCord3(queue1, 0, i2s1, 1); +AudioConnection patchCord2(queue2, peak2); +AudioConnection patchCord5(queue1, 0, i2s1, 0); +AudioConnection patchCord6(queue2, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; //xy=700,536 #else AudioOutputPT8211 pt8211_1; //xy=1079,320 -AudioAmplifier volume_master; //xy=678,393 AudioAmplifier volume_r; //xy=818,370 AudioAmplifier volume_l; //xy=818,411 -AudioConnection patchCord1(queue1, peak1); -AudioConnection patchCord2(queue1, volume_master); -AudioConnection patchCord3(volume_master, volume_r); -AudioConnection patchCord4(volume_master, volume_l); +AudioConnection patchCord1(queue1, volume_r); +AudioConnection patchCord2(queue2, volume_l); +AudioConnection patchCord3(volume_r, peak1); +AudioConnection patchCord4(volume_l, peak2); AudioConnection patchCord5(volume_r, 0, pt8211_1, 0); AudioConnection patchCord6(volume_l, 0, pt8211_1, 1); #endif @@ -177,7 +179,8 @@ void setup() void loop() { - int16_t* audio_buffer; // pointer to AUDIO_BLOCK_SAMPLES * int16_t + int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * int16_t + int16_t* audio_buffer_l; // pointer to AUDIO_BLOCK_SAMPLES * int16_t const uint16_t audio_block_time_ms = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); while (42 == 42) // DON'T PANIC! @@ -192,13 +195,18 @@ void loop() handle_input(); - audio_buffer = queue1.getBuffer(); - if (audio_buffer == NULL) + audio_buffer_r = queue1.getBuffer(); + if (audio_buffer_r == NULL) { - Serial.println(F("E: audio_buffer allocation problems!")); + Serial.println(F("E: audio_buffer_r allocation problems!")); } - - if (!queue1.available()) + audio_buffer_l = queue2.getBuffer(); + if (audio_buffer_l == NULL) + { + Serial.println(F("E: audio_buffer_l allocation problems!")); + } + + if (!queue1.available() || !queue2.available()) continue; elapsedMicros t1; @@ -213,11 +221,18 @@ void loop() if (peak1.read() > 0.99) peak++; } + if (peak2.available()) + { + if (peak2.read() > 0.99) + peak++; + } #ifndef TEENSY_AUDIO_BOARD for (uint8_t i = 0; i <= AUDIO_BLOCK_SAMPLES; i++) - audio_buffer[i] *= vol; + audio_buffer_r[i] *= vol_r; + audio_buffer_l[i] *= vol_l; #endif queue1.playBuffer(); + queue2.playBuffer(); } } void handle_input(void) @@ -407,9 +422,9 @@ bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2) #endif // ret = dexed->processMidiMessage(type, data1, data2); // TODO!!! ; - + #ifdef MASTER_KEY_MIDI - } + } #endif return (ret); } diff --git a/mdaEPiano.cpp b/mdaEPiano.cpp index 793c413..e9c1e6f 100644 --- a/mdaEPiano.cpp +++ b/mdaEPiano.cpp @@ -327,10 +327,10 @@ void mdaEPiano::guiGetDisplay(int32_t index, char *label) } */ -void mdaEPiano::process(float **inputs, float **outputs, int32_t sampleFrames) +void mdaEPiano::process(int16_t **outputs_r, int16_t **outputs_l, int32_t sampleFrames) { - float* out0 = outputs[0]; - float* out1 = outputs[1]; + int16_t* out_l = outputs_r[0]; + int16_t* out_r = outputs_l[0]; int32_t event=0, frame=0, frames, v; float x, l, r, od=overdrive; int32_t i; @@ -375,8 +375,8 @@ void mdaEPiano::process(float **inputs, float **outputs, int32_t sampleFrames) l += l * lmod * lfo1; r += r * rmod * lfo1; //worth making all these local variables? - *out0++ += l; - *out1++ += r; + *out_r++ += static_cast(l * 0x8000); + *out_l++ += static_cast(r * 0x8000); } if(frame