|
|
@ -34,29 +34,26 @@ |
|
|
|
#else |
|
|
|
#else |
|
|
|
#include "mdaEPianoData.h" |
|
|
|
#include "mdaEPianoData.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if defined(USBCON) |
|
|
|
#if defined(MIDI_DEVICE_USB) |
|
|
|
#include <midi_UsbTransport.h> |
|
|
|
#include <midi_UsbTransport.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
|
#ifdef MIDI_DEVICE_USB_HOST |
|
|
|
#include <USBHost_t36.h> |
|
|
|
#include <USBHost_t36.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#include <Bounce.h> |
|
|
|
#include <Bounce.h> |
|
|
|
#include <Encoder.h> |
|
|
|
#include "Encoder4.h" |
|
|
|
#include "LiquidCrystalPlus_I2C.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 |
|
|
|
//* GLOBAL VARIABLES
|
|
|
|
#define LCD_LINES 2 |
|
|
|
//*************************************************************************************************
|
|
|
|
LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); |
|
|
|
|
|
|
|
Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); |
|
|
|
// Audio configuration
|
|
|
|
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
|
|
|
|
AudioPlayQueue queue_r; |
|
|
|
|
|
|
|
AudioPlayQueue queue_l; |
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
AudioAnalyzePeak peak_r; |
|
|
|
AudioPlayQueue queue_r; //xy=494,404
|
|
|
|
AudioAnalyzePeak peak_l; |
|
|
|
AudioPlayQueue queue_l; //xy=494,404
|
|
|
|
|
|
|
|
AudioAnalyzePeak peak_r; //xy=695,491
|
|
|
|
|
|
|
|
AudioAnalyzePeak peak_l; //xy=695,491
|
|
|
|
|
|
|
|
AudioEffectFreeverb freeverb_r; |
|
|
|
AudioEffectFreeverb freeverb_r; |
|
|
|
AudioEffectFreeverb freeverb_l; |
|
|
|
AudioEffectFreeverb freeverb_l; |
|
|
|
AudioMixer4 mixer_r; |
|
|
|
AudioMixer4 mixer_r; |
|
|
@ -70,22 +67,41 @@ AudioConnection patchCord7(queue_l, 0, mixer_l, 0); |
|
|
|
AudioConnection patchCord8(freeverb_r, 0, mixer_r, 1); |
|
|
|
AudioConnection patchCord8(freeverb_r, 0, mixer_r, 1); |
|
|
|
AudioConnection patchCord9(freeverb_l, 0, mixer_l, 1); |
|
|
|
AudioConnection patchCord9(freeverb_l, 0, mixer_l, 1); |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
AudioOutputI2S i2s1; //xy=1072,364
|
|
|
|
AudioOutputI2S i2s1; |
|
|
|
AudioConnection patchCord110(mixer_r, 0, i2s1, 0); |
|
|
|
AudioConnection patchCord110(mixer_r, 0, i2s1, 0); |
|
|
|
AudioConnection patchCord111(mixer_l, 0, i2s1, 1); |
|
|
|
AudioConnection patchCord111(mixer_l, 0, i2s1, 1); |
|
|
|
AudioControlSGTL5000 sgtl5000_1; //xy=700,536
|
|
|
|
AudioControlSGTL5000 sgtl5000_1; |
|
|
|
#else |
|
|
|
#else |
|
|
|
AudioOutputPT8211 pt8211_1; //xy=1079,320
|
|
|
|
AudioOutputPT8211 pt8211_1; |
|
|
|
AudioAmplifier volume_r; //xy=818,370
|
|
|
|
AudioAmplifier volume_r; |
|
|
|
AudioAmplifier volume_l; //xy=818,411
|
|
|
|
AudioAmplifier volume_l; |
|
|
|
AudioConnection patchCord10(mixer_r, volume_r); |
|
|
|
AudioConnection patchCord10(mixer_r, volume_r); |
|
|
|
AudioConnection patchCord11(mixer_l, volume_l); |
|
|
|
AudioConnection patchCord11(mixer_l, volume_l); |
|
|
|
AudioConnection patchCord12(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord12(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord13(volume_l, 0, pt8211_1, 0); |
|
|
|
AudioConnection patchCord13(volume_l, 0, pt8211_1, 0); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
// GUItool: end automatically generated code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Objects
|
|
|
|
mdaEPiano* ep; |
|
|
|
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<sUsbTransportBufferSize> UsbTransport; |
|
|
|
|
|
|
|
UsbTransport sUsbTransport; |
|
|
|
|
|
|
|
MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, midi_onboard_usb); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Variables
|
|
|
|
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; |
|
|
|
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; |
|
|
|
uint32_t xrun = 0; |
|
|
|
uint32_t xrun = 0; |
|
|
|
uint32_t overload = 0; |
|
|
|
uint32_t overload = 0; |
|
|
@ -96,38 +112,24 @@ float vol_right = 1.0; |
|
|
|
float vol_left = 1.0; |
|
|
|
float vol_left = 1.0; |
|
|
|
elapsedMicros fill_audio_buffer; |
|
|
|
elapsedMicros fill_audio_buffer; |
|
|
|
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); |
|
|
|
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
elapsedMillis cpu_mem_millis; |
|
|
|
elapsedMillis cpu_mem_millis; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MIDI_DEVICE |
|
|
|
enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE }; |
|
|
|
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<sUsbTransportBufferSize> UsbTransport; |
|
|
|
|
|
|
|
UsbTransport sUsbTransport; |
|
|
|
|
|
|
|
MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, midi_onboard_usb); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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() |
|
|
|
void setup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
//while (!Serial) ; // wait for Arduino Serial Monitor
|
|
|
|
//while (!Serial) ; // wait for Arduino Serial Monitor
|
|
|
|
Serial.begin(SERIAL_SPEED); |
|
|
|
Serial.begin(SERIAL_SPEED); |
|
|
|
delay(220); |
|
|
|
delay(220); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LCD display setup
|
|
|
|
lcd.init(); |
|
|
|
lcd.init(); |
|
|
|
lcd.blink_off(); |
|
|
|
lcd.blink_off(); |
|
|
|
lcd.cursor_off(); |
|
|
|
lcd.cursor_off(); |
|
|
@ -137,37 +139,47 @@ void setup() |
|
|
|
lcd.display(); |
|
|
|
lcd.display(); |
|
|
|
lcd.show(0, 0, 20, " MicroMDAEPiano"); |
|
|
|
lcd.show(0, 0, 20, " MicroMDAEPiano"); |
|
|
|
lcd.show(1, 0, 16, "(c)parasiTstudio"); |
|
|
|
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("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst")); |
|
|
|
Serial.println(F("(c)2018 H. Wirtz <wirtz@parasitstudio.de>")); |
|
|
|
Serial.println(F("(c)2018 H. Wirtz <wirtz@parasitstudio.de>")); |
|
|
|
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(F("Data in PROGMEM: ")); |
|
|
|
Serial.print(sizeof(epianoDataXfade), DEC); |
|
|
|
Serial.print(sizeof(epianoDataXfade), DEC); |
|
|
|
Serial.println(F(" bytes")); |
|
|
|
Serial.println(F(" bytes")); |
|
|
|
Serial.println(); |
|
|
|
Serial.println(); |
|
|
|
Serial.println(F("<setup start>")); |
|
|
|
Serial.println(F("<setup start>")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create EPiano object
|
|
|
|
ep = new mdaEPiano(); |
|
|
|
ep = new mdaEPiano(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read initial EEPROM variables
|
|
|
|
initial_values_from_eeprom(); |
|
|
|
initial_values_from_eeprom(); |
|
|
|
|
|
|
|
|
|
|
|
// start up USB host
|
|
|
|
// start up USB host
|
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
|
#ifdef MIDI_DEVICE_USB_HOST |
|
|
|
usb_host.begin(); |
|
|
|
usb_host.begin(); |
|
|
|
Serial.println(F("USB-MIDI enabled.")); |
|
|
|
Serial.println(F("MIDI_DEVICE_USB_HOST enabled.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// check for onboard USB-MIDI
|
|
|
|
// check for onboard USB-MIDI
|
|
|
|
#if defined(USBCON) |
|
|
|
#ifdef MIDI_DEVICE_USB |
|
|
|
midi_onboard_usb.begin(); |
|
|
|
midi_onboard_usb.begin(); |
|
|
|
Serial.println(F("Onboard USB-MIDI enabled.")); |
|
|
|
Serial.println(F("MIDI_DEVICE_USB enabled.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MIDI_DEVICE |
|
|
|
#ifdef MIDI_DEVICE_DIN |
|
|
|
// Start serial MIDI
|
|
|
|
// Start serial MIDI
|
|
|
|
midi_serial.begin(DEFAULT_MIDI_CHANNEL); |
|
|
|
midi_serial.begin(DEFAULT_MIDI_CHANNEL); |
|
|
|
Serial.println(F("Serial MIDI enabled")); |
|
|
|
Serial.println(F("MIDI_DEVICE_DIN enabled")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// start audio card
|
|
|
|
// start audio card
|
|
|
@ -198,12 +210,6 @@ void setup() |
|
|
|
Serial.print(1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES)); |
|
|
|
Serial.print(1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES)); |
|
|
|
Serial.println(F("ms)")); |
|
|
|
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(DECAY, 0.5); |
|
|
|
ep->setParameter(RELEASE, 0.5); |
|
|
|
ep->setParameter(RELEASE, 0.5); |
|
|
|
ep->setParameter(HARDNESS, 0.7); |
|
|
|
ep->setParameter(HARDNESS, 0.7); |
|
|
@ -230,6 +236,11 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
//* MAIN LOOP
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
void loop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t)
|
|
|
|
int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t)
|
|
|
@ -293,66 +304,42 @@ void loop() |
|
|
|
handle_input(); |
|
|
|
handle_input(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
//* PROGRAM FUNCTIONS
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
void handle_input(void) |
|
|
|
void handle_input(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
|
#ifdef MIDI_DEVICE_DIN |
|
|
|
usb_host.Task(); |
|
|
|
while (midi_serial.read()) |
|
|
|
while (midi_usb.read()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("[MIDI-USB]")); |
|
|
|
Serial.println(F("[MIDI-Serial]")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
/* if (midi_usb.getType() >= 0xf0) // SysEX
|
|
|
|
queue_midi_event(midi_serial.getType(), midi_serial.getData1(), midi_serial.getData2()); |
|
|
|
{ |
|
|
|
|
|
|
|
handle_sysex_parameter(midi_usb.getSysExArray(), midi_usb.getSysExArrayLength()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else */ if (queue_midi_event(midi_usb.getType(), midi_usb.getData1(), midi_usb.getData2())) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#ifdef MIDI_DEVICE |
|
|
|
#ifdef MIDI_DEVICE_USB_HOST |
|
|
|
while (midi_serial.read()) |
|
|
|
usb_host.Task(); |
|
|
|
|
|
|
|
while (midi_usb.read()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("[MIDI-Serial] ")); |
|
|
|
Serial.println(F("[MIDI-USB-HOST]")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
/* if (midi_serial.getType() >= 0xf0) // SYSEX
|
|
|
|
queue_midi_event(midi_usb.getType(), midi_usb.getData1(), midi_usb.getData2()); |
|
|
|
{ |
|
|
|
|
|
|
|
handle_sysex_parameter(midi_serial.getSysExArray(), midi_serial.getSysExArrayLength()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else */ if (queue_midi_event(midi_serial.getType(), midi_serial.getData1(), midi_serial.getData2())) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef MIDI_DEVICE_USB |
|
|
|
int enc1_val = enc1.read(); |
|
|
|
while (midi_onboard_usb.read()) |
|
|
|
|
|
|
|
{ |
|
|
|
if (but1.update()) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef SHOW_MIDI_EVENT |
|
|
|
Serial.println(F("[MIDI-USB]")); |
|
|
|
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 |
|
|
|
|
|
|
|
queue_midi_event(midi_onboard_usb.getType(), midi_onboard_usb.getData1(), midi_onboard_usb.getData2()); |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
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 |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
//* EEPROM FUNCTIONS
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
void initial_values_from_eeprom(void) |
|
|
|
void initial_values_from_eeprom(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t crc_eeprom = read_eeprom_checksum(); |
|
|
|
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); |
|
|
|
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) |
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
void show_cpu_and_mem_usage(void) |
|
|
|
void show_cpu_and_mem_usage(void) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -531,47 +549,3 @@ void show_cpu_and_mem_usage(void) |
|
|
|
render_time_max = 0; |
|
|
|
render_time_max = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#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 |
|
|
|
|
|
|
|