Several additions.

master
Holger Wirtz 6 years ago
parent 0a5735035f
commit 088070cf4c
  1. 43
      MicroMDAPiano.ino
  2. 10
      mdaEPiano.cpp
  3. 2
      mdaEPiano.h

@ -29,22 +29,24 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=494,404 AudioPlayQueue queue1; //xy=494,404
AudioPlayQueue queue2; //xy=494,404
AudioAnalyzePeak peak1; //xy=695,491 AudioAnalyzePeak peak1; //xy=695,491
AudioAnalyzePeak peak2; //xy=695,491
#ifdef TEENSY_AUDIO_BOARD #ifdef TEENSY_AUDIO_BOARD
AudioOutputI2S i2s1; //xy=1072,364 AudioOutputI2S i2s1; //xy=1072,364
AudioConnection patchCord1(queue1, peak1); AudioConnection patchCord1(queue1, peak1);
AudioConnection patchCord2(queue1, 0, i2s1, 0); AudioConnection patchCord2(queue2, peak2);
AudioConnection patchCord3(queue1, 0, i2s1, 1); AudioConnection patchCord5(queue1, 0, i2s1, 0);
AudioConnection patchCord6(queue2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=700,536 AudioControlSGTL5000 sgtl5000_1; //xy=700,536
#else #else
AudioOutputPT8211 pt8211_1; //xy=1079,320 AudioOutputPT8211 pt8211_1; //xy=1079,320
AudioAmplifier volume_master; //xy=678,393
AudioAmplifier volume_r; //xy=818,370 AudioAmplifier volume_r; //xy=818,370
AudioAmplifier volume_l; //xy=818,411 AudioAmplifier volume_l; //xy=818,411
AudioConnection patchCord1(queue1, peak1); AudioConnection patchCord1(queue1, volume_r);
AudioConnection patchCord2(queue1, volume_master); AudioConnection patchCord2(queue2, volume_l);
AudioConnection patchCord3(volume_master, volume_r); AudioConnection patchCord3(volume_r, peak1);
AudioConnection patchCord4(volume_master, volume_l); AudioConnection patchCord4(volume_l, peak2);
AudioConnection patchCord5(volume_r, 0, pt8211_1, 0); AudioConnection patchCord5(volume_r, 0, pt8211_1, 0);
AudioConnection patchCord6(volume_l, 0, pt8211_1, 1); AudioConnection patchCord6(volume_l, 0, pt8211_1, 1);
#endif #endif
@ -177,7 +179,8 @@ void setup()
void loop() 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); const uint16_t audio_block_time_ms = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
while (42 == 42) // DON'T PANIC! while (42 == 42) // DON'T PANIC!
@ -192,13 +195,18 @@ void loop()
handle_input(); handle_input();
audio_buffer = queue1.getBuffer(); audio_buffer_r = queue1.getBuffer();
if (audio_buffer == NULL) if (audio_buffer_r == NULL)
{
Serial.println(F("E: audio_buffer_r allocation problems!"));
}
audio_buffer_l = queue2.getBuffer();
if (audio_buffer_l == NULL)
{ {
Serial.println(F("E: audio_buffer allocation problems!")); Serial.println(F("E: audio_buffer_l allocation problems!"));
} }
if (!queue1.available()) if (!queue1.available() || !queue2.available())
continue; continue;
elapsedMicros t1; elapsedMicros t1;
@ -213,11 +221,18 @@ void loop()
if (peak1.read() > 0.99) if (peak1.read() > 0.99)
peak++; peak++;
} }
if (peak2.available())
{
if (peak2.read() > 0.99)
peak++;
}
#ifndef TEENSY_AUDIO_BOARD #ifndef TEENSY_AUDIO_BOARD
for (uint8_t i = 0; i <= AUDIO_BLOCK_SAMPLES; i++) 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 #endif
queue1.playBuffer(); queue1.playBuffer();
queue2.playBuffer();
} }
} }
void handle_input(void) void handle_input(void)
@ -409,7 +424,7 @@ bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2)
; ;
#ifdef MASTER_KEY_MIDI #ifdef MASTER_KEY_MIDI
} }
#endif #endif
return (ret); return (ret);
} }

@ -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]; int16_t* out_l = outputs_r[0];
float* out1 = outputs[1]; int16_t* out_r = outputs_l[0];
int32_t event=0, frame=0, frames, v; int32_t event=0, frame=0, frames, v;
float x, l, r, od=overdrive; float x, l, r, od=overdrive;
int32_t i; int32_t i;
@ -375,8 +375,8 @@ void mdaEPiano::process(float **inputs, float **outputs, int32_t sampleFrames)
l += l * lmod * lfo1; l += l * lmod * lfo1;
r += r * rmod * lfo1; //worth making all these local variables? r += r * rmod * lfo1; //worth making all these local variables?
*out0++ += l; *out_r++ += static_cast<int16_t>(l * 0x8000);
*out1++ += r; *out_l++ += static_cast<int16_t>(r * 0x8000);
} }
if(frame<sampleFrames) if(frame<sampleFrames)

@ -59,7 +59,7 @@ public:
mdaEPiano(); // mdaEPiano(audioMasterCallback audioMaster); mdaEPiano(); // mdaEPiano(audioMasterCallback audioMaster);
~mdaEPiano(); ~mdaEPiano();
virtual void process(float **inputs, float **outputs, int32_t sampleframes); virtual void process(int16_t **outputs_r, int16_t **outputs_l, int32_t sampleFrames);
virtual void processReplacing(float **inputs, float **outputs, int32_t sampleframes); virtual void processReplacing(float **inputs, float **outputs, int32_t sampleframes);
virtual int32_t processEvents(); // virtual int32_t processEvents(VstEvents* events); virtual int32_t processEvents(); // virtual int32_t processEvents(VstEvents* events);

Loading…
Cancel
Save