From 6c14711c6fcc2f9b3e1b609552edeeb7c106c810 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 28 Aug 2018 11:20:24 +0200 Subject: [PATCH] Save current state. --- MicroMDAPiano.ino | 54 +++++++++++++++++++++-------------------------- config.h | 13 +++++------- mdaEPiano.h | 3 ++- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/MicroMDAPiano.ino b/MicroMDAPiano.ino index a2ff248..e2ea00f 100644 --- a/MicroMDAPiano.ino +++ b/MicroMDAPiano.ino @@ -28,25 +28,25 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce #endif // 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 +AudioPlayQueue queue_r; //xy=494,404 +AudioPlayQueue queue_l; //xy=494,404 +AudioAnalyzePeak peak_r; //xy=695,491 +AudioAnalyzePeak peak_l; //xy=695,491 #ifdef TEENSY_AUDIO_BOARD AudioOutputI2S i2s1; //xy=1072,364 -AudioConnection patchCord1(queue1, peak1); -AudioConnection patchCord2(queue2, peak2); -AudioConnection patchCord5(queue1, 0, i2s1, 0); -AudioConnection patchCord6(queue2, 0, i2s1, 1); +AudioConnection patchCord1(queue_r, peak_r); +AudioConnection patchCord2(queue_l, peak_l); +AudioConnection patchCord3(queue_r, 0, i2s1, 0); +AudioConnection patchCord4(queue_l, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; //xy=700,536 #else AudioOutputPT8211 pt8211_1; //xy=1079,320 AudioAmplifier volume_r; //xy=818,370 AudioAmplifier volume_l; //xy=818,411 -AudioConnection patchCord1(queue1, volume_r); -AudioConnection patchCord2(queue2, volume_l); -AudioConnection patchCord3(volume_r, peak1); -AudioConnection patchCord4(volume_l, peak2); +AudioConnection patchCord1(queue_r, volume_r); +AudioConnection patchCord2(queue_l, volume_l); +AudioConnection patchCord3(volume_r, peak_r); +AudioConnection patchCord4(volume_l, peak_l); AudioConnection patchCord5(volume_r, 0, pt8211_1, 0); AudioConnection patchCord6(volume_l, 0, pt8211_1, 1); #endif @@ -105,6 +105,7 @@ 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 ")); Serial.println(F("https://about.teahub.io/dcoredump/MicroMDAEpiano")); @@ -113,6 +114,7 @@ void setup() Serial.println(F(" bytes")); Serial.println(); Serial.println(F("")); + delay(1000); initial_values_from_eeprom(); @@ -195,35 +197,35 @@ void loop() handle_input(); - audio_buffer_r = queue1.getBuffer(); + audio_buffer_r = queue_r.getBuffer(); if (audio_buffer_r == NULL) { Serial.println(F("E: audio_buffer_r allocation problems!")); } - audio_buffer_l = queue2.getBuffer(); + audio_buffer_l = queue_l.getBuffer(); if (audio_buffer_l == NULL) { Serial.println(F("E: audio_buffer_l allocation problems!")); } - if (!queue1.available() || !queue2.available()) + if (!queue_r.available() || !queue_l.available()) continue; elapsedMicros t1; - //ep->process(AUDIO_BLOCK_SAMPLES, audio_buffer); + 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++; if (t2 > render_time_max) render_time_max = t2; - if (peak1.available()) + if (peak_r.available()) { - if (peak1.read() > 0.99) + if (peak_r.read() > 0.99) peak++; } - if (peak2.available()) + if (peak_l.available()) { - if (peak2.read() > 0.99) + if (peak_l.read() > 0.99) peak++; } #ifndef TEENSY_AUDIO_BOARD @@ -231,8 +233,8 @@ void loop() audio_buffer_r[i] *= vol_r; audio_buffer_l[i] *= vol_l; #endif - queue1.playBuffer(); - queue2.playBuffer(); + queue_r.playBuffer(); + queue_l.playBuffer(); } } void handle_input(void) @@ -739,14 +741,6 @@ void note_off(void) queue_midi_event(0x80, TEST_NOTE + 52, 0); // 14 queue_midi_event(0x80, TEST_NOTE + 57, 0); // 15 queue_midi_event(0x80, TEST_NOTE + 60, 0); // 16 - - bool success = load_sysex(DEFAULT_SYSEXBANK, (++_voice_counter) - 1); - if (success == false) -#ifdef DEBUG - Serial.println(F("E: Cannot load SYSEX data")); -#endif - else - show_patch(); } #endif diff --git a/config.h b/config.h index 84b2f1f..335baef 100644 --- a/config.h +++ b/config.h @@ -30,21 +30,18 @@ // Initial values #define MIDI_DEVICE Serial1 -#define USE_ONBOARD_USB_HOST 1 +//#define USE_ONBOARD_USB_HOST 1 #define TEENSY_AUDIO_BOARD 1 #define VOLUME 0.6 #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI -#define DEFAULT_SYSEXBANK 0 -#define DEFAULT_SYSEXSOUND 0 -//#define DEXED_ENGINE DEXED_ENGINE_MODERN -#define AUDIO_MEM 2 +#define AUDIO_MEM 4 #define SAMPLE_RATE 44100 #if !defined(__MK66FX1M0__) // check for Teensy-3.6 -#define MAX_NOTES 11 // No? +#define NVOCIES 11 // No? #undef USE_ONBOARD_USB_HOST #else -#define MAX_NOTES 16 // Yes +#define NVOICES 16 // Yes #endif // Master key handling (comment for disabling) @@ -59,7 +56,7 @@ #define SHOW_CPU_LOAD_MSEC 5000 // Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard -//#define TEST_NOTE MIDI_E2 +#define TEST_NOTE MIDI_E2 #define TEST_VEL_MIN 60 #define TEST_VEL_MAX 110 diff --git a/mdaEPiano.h b/mdaEPiano.h index d6d5ee4..83e150b 100644 --- a/mdaEPiano.h +++ b/mdaEPiano.h @@ -5,11 +5,12 @@ #include #include +#include "config.h" #define NPARAMS 12 //number of parameters #define NPROGS 8 //number of programs #define NOUTS 2 //number of outputs -#define NVOICES 32 //max polyphony +//#define NVOICES 32 //max polyphony #define SUSTAIN 128 #define SILENCE 0.0001f //voice choking #define WAVELEN 422414 //wave data bytes