From 299b8dc33f4ec2f828d9efea8acbf01b841f954a Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 13 Jan 2019 10:41:13 +0100 Subject: [PATCH] Code cleanup. --- Encoder4.h | 47 +++++++ LiquidCrystalPlus_I2C.h | 3 +- MicroMDAEPiano.ino | 270 ++++++++++++++++++---------------------- config.h | 100 +++++++++++---- mdaEPiano.cpp | 4 - mdaEPiano.h | 10 +- mdaEPianoData.h | 4 + mdaEPianoDataXfade.h | 4 + 8 files changed, 258 insertions(+), 184 deletions(-) create mode 100644 Encoder4.h diff --git a/Encoder4.h b/Encoder4.h new file mode 100644 index 0000000..d9053f8 --- /dev/null +++ b/Encoder4.h @@ -0,0 +1,47 @@ +/* + MicroMDAEPiano + + MicroMDAEPiano is a port of the MDA-EPiano sound engine + (https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield. + + (c)2019 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +#ifndef ENCODER4_H_INCLUDED +#define ENCODER4_H_INCLUDED + +class Encoder4 : public Encoder +{ + public: + + using Encoder::Encoder; + + int32_t read() + { + return (Encoder::read() / 4); + } + + void write(int32_t p) + { + Encoder::write(p * 4); + } +}; + +#endif diff --git a/LiquidCrystalPlus_I2C.h b/LiquidCrystalPlus_I2C.h index 6026b33..9aea0d0 100644 --- a/LiquidCrystalPlus_I2C.h +++ b/LiquidCrystalPlus_I2C.h @@ -20,11 +20,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include // https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c #ifndef LIQUIDCRYSTALPLUS_I2C_H_INCLUDED #define LIQUIDCRYSTALPLUS_I2C_H_INCLUDED +#include // https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c + #define STRING_BUF_SIZE 21 class LiquidCrystalPlus_I2C : public LiquidCrystal_I2C diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index 45622be..f297606 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -34,31 +34,28 @@ #else #include "mdaEPianoData.h" #endif -#if defined(USBCON) +#if defined(MIDI_DEVICE_USB) #include #endif -#ifdef USE_ONBOARD_USB_HOST +#ifdef MIDI_DEVICE_USB_HOST #include #endif #include -#include +#include "Encoder4.h" #include "LiquidCrystalPlus_I2C.h" -// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html) -#define LCD_I2C_ADDRESS 0x27 -#define LCD_CHARS 16 -#define LCD_LINES 2 -LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); -Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); -Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce - -// GUItool: begin automatically generated code -AudioPlayQueue queue_r; //xy=494,404 -AudioPlayQueue queue_l; //xy=494,404 -AudioAnalyzePeak peak_r; //xy=695,491 -AudioAnalyzePeak peak_l; //xy=695,491 -AudioEffectFreeverb freeverb_r; -AudioEffectFreeverb freeverb_l; + +//************************************************************************************************* +//* GLOBAL VARIABLES +//************************************************************************************************* + +// Audio configuration +AudioPlayQueue queue_r; +AudioPlayQueue queue_l; +AudioAnalyzePeak peak_r; +AudioAnalyzePeak peak_l; +AudioEffectFreeverb freeverb_r; +AudioEffectFreeverb freeverb_l; AudioMixer4 mixer_r; AudioMixer4 mixer_l; AudioConnection patchCord0(queue_r, peak_r); @@ -70,22 +67,41 @@ AudioConnection patchCord7(queue_l, 0, mixer_l, 0); AudioConnection patchCord8(freeverb_r, 0, mixer_r, 1); AudioConnection patchCord9(freeverb_l, 0, mixer_l, 1); #ifdef TEENSY_AUDIO_BOARD -AudioOutputI2S i2s1; //xy=1072,364 +AudioOutputI2S i2s1; AudioConnection patchCord110(mixer_r, 0, i2s1, 0); AudioConnection patchCord111(mixer_l, 0, i2s1, 1); -AudioControlSGTL5000 sgtl5000_1; //xy=700,536 +AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputPT8211 pt8211_1; //xy=1079,320 -AudioAmplifier volume_r; //xy=818,370 -AudioAmplifier volume_l; //xy=818,411 +AudioOutputPT8211 pt8211_1; +AudioAmplifier volume_r; +AudioAmplifier volume_l; AudioConnection patchCord10(mixer_r, volume_r); AudioConnection patchCord11(mixer_l, volume_l); AudioConnection patchCord12(volume_r, 0, pt8211_1, 1); AudioConnection patchCord13(volume_l, 0, pt8211_1, 0); #endif -// GUItool: end automatically generated code +// Objects mdaEPiano* ep; +LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); +Encoder4 enc[2] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)}; +int32_t enc_val[2] = {INITIAL_ENC_L_VALUE, INITIAL_ENC_R_VALUE}; +Bounce but[2] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)}; +#ifdef MIDI_DEVICE_DIN +MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE_DIN, midi_serial); +#endif +#ifdef MIDI_DEVICE_USB_HOST +USBHost usb_host; +MIDIDevice midi_usb(usb_host); +#endif +#ifdef MIDI_DEVICE_USB +static const unsigned sUsbTransportBufferSize = 16; +typedef midi::UsbTransport UsbTransport; +UsbTransport sUsbTransport; +MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, midi_onboard_usb); +#endif + +// Variables uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; uint32_t xrun = 0; uint32_t overload = 0; @@ -96,38 +112,24 @@ float vol_right = 1.0; float vol_left = 1.0; elapsedMicros fill_audio_buffer; const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); - #ifdef SHOW_CPU_LOAD_MSEC elapsedMillis cpu_mem_millis; #endif -#ifdef MIDI_DEVICE -MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE, midi_serial); -#endif -#ifdef USE_ONBOARD_USB_HOST -USBHost usb_host; -MIDIDevice midi_usb(usb_host); -#endif -#if defined(USBCON) -static const unsigned sUsbTransportBufferSize = 16; -typedef midi::UsbTransport UsbTransport; -UsbTransport sUsbTransport; -MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, midi_onboard_usb); -#endif +enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE }; -#ifdef TEST_NOTE -IntervalTimer sched_note_on; -IntervalTimer sched_note_off; -uint8_t _voice_counter = 0; -#endif -enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE }; +//************************************************************************************************* +//* SETUP FUNCTION +//************************************************************************************************* void setup() { //while (!Serial) ; // wait for Arduino Serial Monitor Serial.begin(SERIAL_SPEED); delay(220); + + // LCD display setup lcd.init(); lcd.blink_off(); lcd.cursor_off(); @@ -137,37 +139,47 @@ void setup() lcd.display(); lcd.show(0, 0, 20, " MicroMDAEPiano"); lcd.show(1, 0, 16, "(c)parasiTstudio"); - enc1.write(INITIAL_ENC1_VALUE); + // Encoder setup + enc[0].write(INITIAL_ENC_L_VALUE); + enc_val[0] = enc[0].read(); + enc[1].write(INITIAL_ENC_R_VALUE); + enc_val[1] = enc[1].read(); + but[0].update(); + but[1].update(); + + // Debug output 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")); + Serial.println(F("https://codeberg.org/dcoredump/MicroMDAEpiano")); Serial.print(F("Data in PROGMEM: ")); Serial.print(sizeof(epianoDataXfade), DEC); Serial.println(F(" bytes")); Serial.println(); Serial.println(F("")); + // create EPiano object ep = new mdaEPiano(); + // read initial EEPROM variables initial_values_from_eeprom(); // start up USB host -#ifdef USE_ONBOARD_USB_HOST +#ifdef MIDI_DEVICE_USB_HOST usb_host.begin(); - Serial.println(F("USB-MIDI enabled.")); + Serial.println(F("MIDI_DEVICE_USB_HOST enabled.")); #endif // check for onboard USB-MIDI -#if defined(USBCON) +#ifdef MIDI_DEVICE_USB midi_onboard_usb.begin(); - Serial.println(F("Onboard USB-MIDI enabled.")); + Serial.println(F("MIDI_DEVICE_USB enabled.")); #endif -#ifdef MIDI_DEVICE +#ifdef MIDI_DEVICE_DIN // Start serial MIDI midi_serial.begin(DEFAULT_MIDI_CHANNEL); - Serial.println(F("Serial MIDI enabled")); + Serial.println(F("MIDI_DEVICE_DIN enabled")); #endif // start audio card @@ -198,12 +210,6 @@ void setup() Serial.print(1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES)); Serial.println(F("ms)")); -#ifdef TEST_NOTE - Serial.println(F("MIDI test enabled")); - sched_note_on.begin(note_on, 2000000); - sched_note_off.begin(note_off, 6333333); -#endif - ep->setParameter(DECAY, 0.5); ep->setParameter(RELEASE, 0.5); ep->setParameter(HARDNESS, 0.7); @@ -230,6 +236,11 @@ void setup() #endif } + +//************************************************************************************************* +//* MAIN LOOP +//************************************************************************************************* + void loop() { int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t) @@ -293,66 +304,42 @@ void loop() handle_input(); } + +//************************************************************************************************* +//* PROGRAM FUNCTIONS +//************************************************************************************************* + void handle_input(void) { -#ifdef USE_ONBOARD_USB_HOST - usb_host.Task(); - while (midi_usb.read()) +#ifdef MIDI_DEVICE_DIN + while (midi_serial.read()) { #ifdef DEBUG - Serial.println(F("[MIDI-USB]")); + Serial.println(F("[MIDI-Serial]")); #endif - /* if (midi_usb.getType() >= 0xf0) // SysEX - { - handle_sysex_parameter(midi_usb.getSysExArray(), midi_usb.getSysExArrayLength()); - } - else */ if (queue_midi_event(midi_usb.getType(), midi_usb.getData1(), midi_usb.getData2())) - return; + queue_midi_event(midi_serial.getType(), midi_serial.getData1(), midi_serial.getData2()); } #endif -#ifdef MIDI_DEVICE - while (midi_serial.read()) +#ifdef MIDI_DEVICE_USB_HOST + usb_host.Task(); + while (midi_usb.read()) { #ifdef DEBUG - Serial.print(F("[MIDI-Serial] ")); -#endif - /* if (midi_serial.getType() >= 0xf0) // SYSEX - { - handle_sysex_parameter(midi_serial.getSysExArray(), midi_serial.getSysExArrayLength()); - } - else */ if (queue_midi_event(midi_serial.getType(), midi_serial.getData1(), midi_serial.getData2())) - return; + Serial.println(F("[MIDI-USB-HOST]")); +#endif + queue_midi_event(midi_usb.getType(), midi_usb.getData1(), midi_usb.getData2()); } #endif - - int enc1_val = enc1.read(); - - if (but1.update()) - ; - // place handling of encoder and showing values on lcd here - -} - +#ifdef MIDI_DEVICE_USB + while (midi_onboard_usb.read()) + { #ifdef DEBUG -#ifdef SHOW_MIDI_EVENT -void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) -{ - Serial.print(F("MIDI-Channel: ")); - if (midi_channel == MIDI_CHANNEL_OMNI) - Serial.print(F("OMNI")); - else - Serial.print(midi_channel, DEC); - Serial.print(F(", MIDI event type: 0x")); - if (type < 16) - Serial.print(F("0")); - Serial.print(type, HEX); - Serial.print(F(", data1: ")); - Serial.print(data1, DEC); - Serial.print(F(", data2: ")); - Serial.println(data2, DEC); -} + Serial.println(F("[MIDI-USB]")); #endif + queue_midi_event(midi_onboard_usb.getType(), midi_onboard_usb.getData1(), midi_onboard_usb.getData2()); + } #endif +} bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2) { @@ -432,6 +419,11 @@ void set_volume(float v, float vr, float vl) #endif } + +//************************************************************************************************* +//* EEPROM FUNCTIONS +//************************************************************************************************* + void initial_values_from_eeprom(void) { uint32_t crc_eeprom = read_eeprom_checksum(); @@ -506,6 +498,32 @@ uint32_t eeprom_crc32(uint16_t calc_start, uint16_t calc_bytes) // base code fro return (crc); } + +//************************************************************************************************* +//* DEBUG FUNCTIONS +//************************************************************************************************* + +#ifdef DEBUG +#ifdef SHOW_MIDI_EVENT +void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) +{ + Serial.print(F("MIDI-Channel: ")); + if (midi_channel == MIDI_CHANNEL_OMNI) + Serial.print(F("OMNI")); + else + Serial.print(midi_channel, DEC); + Serial.print(F(", MIDI event type: 0x")); + if (type < 16) + Serial.print(F("0")); + Serial.print(type, HEX); + Serial.print(F(", data1: ")); + Serial.print(data1, DEC); + Serial.print(F(", data2: ")); + Serial.println(data2, DEC); +} +#endif +#endif + #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) void show_cpu_and_mem_usage(void) { @@ -531,47 +549,3 @@ void show_cpu_and_mem_usage(void) render_time_max = 0; } #endif - - -#ifdef TEST_NOTE -void note_on(void) -{ - randomSeed(analogRead(A0)); - queue_midi_event(0x90, TEST_NOTE, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 1 - queue_midi_event(0x90, TEST_NOTE + 5, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 2 - queue_midi_event(0x90, TEST_NOTE + 8, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 3 - queue_midi_event(0x90, TEST_NOTE + 12, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 4 - queue_midi_event(0x90, TEST_NOTE + 17, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 5 - queue_midi_event(0x90, TEST_NOTE + 20, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 6 - queue_midi_event(0x90, TEST_NOTE + 24, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 7 - queue_midi_event(0x90, TEST_NOTE + 29, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 8 - queue_midi_event(0x90, TEST_NOTE + 32, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 9 - queue_midi_event(0x90, TEST_NOTE + 37, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 10 - queue_midi_event(0x90, TEST_NOTE + 40, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 11 - queue_midi_event(0x90, TEST_NOTE + 46, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 12 - queue_midi_event(0x90, TEST_NOTE + 49, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 13 - queue_midi_event(0x90, TEST_NOTE + 52, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 14 - queue_midi_event(0x90, TEST_NOTE + 57, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 15 - queue_midi_event(0x90, TEST_NOTE + 60, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 16 -} - -void note_off(void) -{ - queue_midi_event(0x80, TEST_NOTE, 0); // 1 - queue_midi_event(0x80, TEST_NOTE + 5, 0); // 2 - queue_midi_event(0x80, TEST_NOTE + 8, 0); // 3 - queue_midi_event(0x80, TEST_NOTE + 12, 0); // 4 - queue_midi_event(0x80, TEST_NOTE + 17, 0); // 5 - queue_midi_event(0x80, TEST_NOTE + 20, 0); // 6 - queue_midi_event(0x80, TEST_NOTE + 24, 0); // 7 - queue_midi_event(0x80, TEST_NOTE + 29, 0); // 8 - queue_midi_event(0x80, TEST_NOTE + 32, 0); // 9 - queue_midi_event(0x80, TEST_NOTE + 37, 0); // 10 - queue_midi_event(0x80, TEST_NOTE + 40, 0); // 11 - queue_midi_event(0x80, TEST_NOTE + 46, 0); // 12 - queue_midi_event(0x80, TEST_NOTE + 49, 0); // 13 - 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 -} -#endif diff --git a/config.h b/config.h index f52ac76..798eb21 100644 --- a/config.h +++ b/config.h @@ -20,57 +20,85 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef CONFIG_H_INCLUDED +#define CONFIG_H_INCLUDED + #include "midinotes.h" // ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from // 128 to 64 in /cores/teensy3/AudioStream.h -// Initial values -#define MIDI_DEVICE Serial1 -#define USE_ONBOARD_USB_HOST 1 +//************************************************************************************************* +//* DEVICE SETTINGS +//************************************************************************************************* + +// MIDI +//#define MIDI_DEVICE_DIN Serial1 +#define MIDI_DEVICE_USB 1 +#define MIDI_DEVICE_USB_HOST 1 + +// AUDIO //#define TEENSY_AUDIO_BOARD 1 -#define VOLUME 0.8 + +//************************************************************************************************* +//* MIDI SETTINGS +//************************************************************************************************* + #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI +#define MIDI_MERGE_THRU 1 + +//************************************************************************************************* +//* AUDIO SETTINGS +//************************************************************************************************* + +#define VOLUME 0.8 #define AUDIO_MEM 128 #define SAMPLE_RATE 44100 #define REDUCE_LOUDNESS 1 #define USE_XFADE_DATA 1 -#if !defined(__MK66FX1M0__) // check for Teensy-3.6 -#undef USE_ONBOARD_USB_HOST -#define NVOICES 32 -#else -#define NVOICES 64 -#endif -#define USBCON 1 // enabling onboard MIDI via programing connector -#define MIDI_MERGE_THRU 1 +//************************************************************************************************* +//* DEBUG OUTPUT SETTINGS +//************************************************************************************************* -// Debug output -#define SERIAL_SPEED 38400 #define DEBUG 1 +#define SERIAL_SPEED 38400 //#define SHOW_MIDI_EVENT 1 #define SHOW_XRUN 1 #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_VEL_MIN 60 -#define TEST_VEL_MAX 110 +//************************************************************************************************* +//* HARDWARE SETTINGS +//************************************************************************************************* -// Use these with the Teensy Audio Shield +// Teensy Audio Shield: //#define SDCARD_CS_PIN 10 //#define SDCARD_MOSI_PIN 7 //#define SDCARD_SCK_PIN 14 -// Use these with the Teensy 3.5 & 3.6 SD card +// Teensy 3.5 & 3.6 SD card #define SDCARD_CS_PIN BUILTIN_SDCARD #define SDCARD_MOSI_PIN 11 // not actually used #define SDCARD_SCK_PIN 13 // not actually used // Encoder with button -#define ENC1_PIN_A 14 -#define ENC1_PIN_B 15 -#define BUT1_PIN 16 -#define INITIAL_ENC1_VALUE 0 +#define NUM_ENCODER 2 +#define ENC_L_PIN_A 3 +#define ENC_L_PIN_B 2 +#define BUT_L_PIN 4 +#define INITIAL_ENC_L_VALUE 0 +#define ENC_R_PIN_A 28 +#define ENC_R_PIN_B 29 +#define BUT_R_PIN 30 +#define INITIAL_ENC_R_VALUE 0 +#define BUT_DEBOUNCE_MS 20 +#define LONG_BUTTON_PRESS 500 + +// LCD display (I2C) +// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html) +#define LCD_I2C_ADDRESS 0x27 +#define LCD_CHARS 16 +#define LCD_LINES 2 // EEPROM address #define EEPROM_OFFSET 0 @@ -82,3 +110,27 @@ #define EEPROM_MASTER_VOLUME_ADDR 2 #define EEPROM_VOLUME_RIGHT_ADDR 3 #define EEPROM_VOLUME_LEFT_ADDR 4 + +//************************************************************************************************* +//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!! +//************************************************************************************************* +// MIDI +#ifdef MIDI_DEVICE_USB +#define USBCON 1 +#endif +#if defined(__MK66FX1M0__) +// Teensy-3.6 settings +#define MIDI_DEVICE_USB_HOST 1 +#else +// Teensy-3.5 settings +#undef MIDI_DEVICE_USB_HOST +#endif +// Engine +#if defined(__MK66FX1M0__) +// Teensy-3.6 settings +#define NVOICES 64 +#else +#define NVOICES 32 +#endif + +#endif diff --git a/mdaEPiano.cpp b/mdaEPiano.cpp index 2510ff1..4dae120 100644 --- a/mdaEPiano.cpp +++ b/mdaEPiano.cpp @@ -29,7 +29,6 @@ #include #include - mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS) { Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case... @@ -144,12 +143,9 @@ void mdaEPiano::update() //parameter change void mdaEPiano::resume() { - //Fs = getSampleRate(); Fs = SAMPLE_RATE; iFs = 1.0f / Fs; dlfo = 6.283f * iFs * (float)exp(6.22f * programs[curProgram].param[5] - 2.61f); //lfo rate - - //DECLARE_VST_DEPRECATED (wantEvents) (); } diff --git a/mdaEPiano.h b/mdaEPiano.h index 26d3ef6..26c51cf 100644 --- a/mdaEPiano.h +++ b/mdaEPiano.h @@ -72,10 +72,10 @@ struct KGRP //keygroup int32_t loop; }; -class mdaEPiano //: public AudioEffectX +class mdaEPiano { public: - mdaEPiano(); // mdaEPiano(audioMasterCallback audioMaster); + mdaEPiano(); ~mdaEPiano(); virtual void process(int16_t *outputs_r, int16_t *outputs_l); @@ -93,14 +93,10 @@ class mdaEPiano //: public AudioEffectX void noteOn(int32_t note, int32_t velocity); void fillpatch(int32_t p, char *name, float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8, float p9, float p10, float p11); - + mdaEPianoProgram* programs; float Fs, iFs; -#define EVENTBUFFER 120 -#define EVENTS_DONE 99999999 - int32_t notes[EVENTBUFFER + 8]; //list of delta|note|velocity for current block - ///global internal variables KGRP kgrp[34]; VOICE voice[NVOICES]; diff --git a/mdaEPianoData.h b/mdaEPianoData.h index 0c12bbf..cd68c33 100644 --- a/mdaEPianoData.h +++ b/mdaEPianoData.h @@ -19,6 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef MDAEPIANODATA_H_INCLUDED +#define MDAEPIANODATA_H_INCLUDED + #ifndef USE_XFADE_DATA #include @@ -21146,3 +21149,4 @@ const int16_t epianoData[] PROGMEM = { -4377,-2810,-829,1280,3190,4588,5216,4960,3821,0,1,1,0,-1,0,0,0,0 }; #endif +#endif diff --git a/mdaEPianoDataXfade.h b/mdaEPianoDataXfade.h index 5b19f8d..58ef907 100644 --- a/mdaEPianoDataXfade.h +++ b/mdaEPianoDataXfade.h @@ -21,6 +21,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef MDAEPIANODATA_H_INCLUDED +#define MDAEPIANODATA_H_INCLUDED + #ifdef USE_XFADE_DATA #include @@ -21148,3 +21151,4 @@ const int16_t epianoDataXfade[] PROGMEM = { -4377,-2810,-829,1280,3190,4588,5216,4960,3821,0,1,1,0,-1,0,0,0,0, }; #endif +#endif