|
|
|
@ -52,7 +52,7 @@ AudioConnection patchCord6(volume_l, 0, pt8211_1, 1); |
|
|
|
|
#endif |
|
|
|
|
// GUItool: end automatically generated code
|
|
|
|
|
|
|
|
|
|
mdaEPiano* ep = new mdaEPiano(); |
|
|
|
|
mdaEPiano* ep; |
|
|
|
|
bool sd_card_available = false; |
|
|
|
|
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; |
|
|
|
|
uint32_t xrun = 0; |
|
|
|
@ -105,7 +105,6 @@ void setup() |
|
|
|
|
enc1.write(INITIAL_ENC1_VALUE); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
delay(500); |
|
|
|
|
Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst")); |
|
|
|
|
Serial.println(F("(c)2018 H. Wirtz <wirtz@parasitstudio.de>")); |
|
|
|
|
Serial.println(F("https://about.teahub.io/dcoredump/MicroMDAEpiano")); |
|
|
|
@ -114,7 +113,8 @@ void setup() |
|
|
|
|
Serial.println(F(" bytes")); |
|
|
|
|
Serial.println(); |
|
|
|
|
Serial.println(F("<setup start>")); |
|
|
|
|
delay(1000); |
|
|
|
|
|
|
|
|
|
ep = new mdaEPiano(); |
|
|
|
|
|
|
|
|
|
initial_values_from_eeprom(); |
|
|
|
|
|
|
|
|
@ -135,10 +135,12 @@ void setup() |
|
|
|
|
//sgtl5000_1.dacVolumeRamp();
|
|
|
|
|
sgtl5000_1.dacVolumeRampLinear(); |
|
|
|
|
sgtl5000_1.unmuteHeadphone(); |
|
|
|
|
sgtl5000_1.unmuteLineout(); |
|
|
|
|
sgtl5000_1.autoVolumeDisable(); // turn off AGC
|
|
|
|
|
sgtl5000_1.volume(1.0, 1.0); |
|
|
|
|
#endif |
|
|
|
|
//set_volume(vol, vol_left, vol_right);
|
|
|
|
|
|
|
|
|
|
set_volume(vol, vol_left, vol_right); |
|
|
|
|
|
|
|
|
|
// start SD card
|
|
|
|
|
SPI.setMOSI(SDCARD_MOSI_PIN); |
|
|
|
@ -185,8 +187,12 @@ void loop() |
|
|
|
|
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!
|
|
|
|
|
// Main sound calculation
|
|
|
|
|
if (queue_r.available() && queue_l.available()) |
|
|
|
|
{ |
|
|
|
|
audio_buffer_r = queue_r.getBuffer(); |
|
|
|
|
audio_buffer_l = queue_l.getBuffer(); |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
if (cpu_mem_millis > SHOW_CPU_LOAD_MSEC) |
|
|
|
|
{ |
|
|
|
@ -208,11 +214,8 @@ void loop() |
|
|
|
|
Serial.println(F("E: audio_buffer_l allocation problems!")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!queue_r.available() || !queue_l.available()) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
elapsedMicros t1; |
|
|
|
|
ep->process(&audio_buffer_l,&audio_buffer_r,AUDIO_BLOCK_SAMPLES); |
|
|
|
|
ep->process(audio_buffer_l, audio_buffer_r, AUDIO_BLOCK_SAMPLES); |
|
|
|
|
uint32_t t2 = t1; |
|
|
|
|
if (t2 > audio_block_time_ms) // everything greater 2.9ms is a buffer underrun!
|
|
|
|
|
xrun++; |
|
|
|
@ -229,14 +232,17 @@ void loop() |
|
|
|
|
peak++; |
|
|
|
|
} |
|
|
|
|
#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_r[i] *= vol_r; |
|
|
|
|
audio_buffer_l[i] *= vol_l; |
|
|
|
|
audio_buffer_l[i] *= vol_l; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
queue_r.playBuffer(); |
|
|
|
|
queue_l.playBuffer(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handle_input(void) |
|
|
|
|
{ |
|
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
|
@ -743,4 +749,3 @@ void note_off(void) |
|
|
|
|
queue_midi_event(0x80, TEST_NOTE + 60, 0); // 16
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|