|
|
@ -26,12 +26,12 @@ |
|
|
|
#include <Audio.h> |
|
|
|
#include <Audio.h> |
|
|
|
#include <Wire.h> |
|
|
|
#include <Wire.h> |
|
|
|
#include <SPI.h> |
|
|
|
#include <SPI.h> |
|
|
|
#include <SD.h> |
|
|
|
|
|
|
|
#include <MIDI.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include <EEPROM.h> |
|
|
|
#include <EEPROM.h> |
|
|
|
#include <limits.h> |
|
|
|
#include <limits.h> |
|
|
|
#include "mdaEPiano.h" |
|
|
|
#include "mdaEPiano.h" |
|
|
|
#include "mdaEPianoData.h" |
|
|
|
//#include "mdaEPianoData.h"
|
|
|
|
|
|
|
|
#include "mdaEPianoDataXfade.h" |
|
|
|
#if defined(USBCON) |
|
|
|
#if defined(USBCON) |
|
|
|
#include <midi_UsbTransport.h> |
|
|
|
#include <midi_UsbTransport.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -44,7 +44,6 @@ |
|
|
|
#include "LiquidCrystalPlus_I2C.h" |
|
|
|
#include "LiquidCrystalPlus_I2C.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
|
|
|
|
// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
|
|
|
|
#define LCD_I2C_ADDRESS 0x27 |
|
|
|
#define LCD_I2C_ADDRESS 0x27 |
|
|
|
#define LCD_CHARS 16 |
|
|
|
#define LCD_CHARS 16 |
|
|
@ -52,52 +51,44 @@ |
|
|
|
LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); |
|
|
|
LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); |
|
|
|
Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); |
|
|
|
Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); |
|
|
|
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
|
|
|
|
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
AudioPlayQueue queue_r; //xy=494,404
|
|
|
|
AudioPlayQueue queue_r; //xy=494,404
|
|
|
|
AudioPlayQueue queue_l; //xy=494,404
|
|
|
|
AudioPlayQueue queue_l; //xy=494,404
|
|
|
|
AudioAnalyzePeak peak_r; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_r; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_l; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_l; //xy=695,491
|
|
|
|
|
|
|
|
AudioConnection patchCord0(queue_l, peak_l); |
|
|
|
|
|
|
|
AudioConnection patchCord1(queue_r, peak_r); |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
AudioOutputI2S i2s1; //xy=1072,364
|
|
|
|
AudioOutputI2S i2s1; //xy=1072,364
|
|
|
|
AudioConnection patchCord1(queue_r, peak_r); |
|
|
|
AudioConnection patchCord2(queue_l, 0, i2s1, 0); |
|
|
|
AudioConnection patchCord2(queue_l, peak_l); |
|
|
|
AudioConnection patchCord3(queue_r, 0, i2s1, 1); |
|
|
|
AudioConnection patchCord3(queue_r, 0, i2s1, 0); |
|
|
|
|
|
|
|
AudioConnection patchCord4(queue_l, 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_r; //xy=818,370
|
|
|
|
AudioAmplifier volume_r; //xy=818,370
|
|
|
|
AudioAmplifier volume_l; //xy=818,411
|
|
|
|
AudioAmplifier volume_l; //xy=818,411
|
|
|
|
AudioConnection patchCord1(queue_r, volume_r); |
|
|
|
AudioConnection patchCord2(queue_l, volume_r); |
|
|
|
AudioConnection patchCord2(queue_l, volume_l); |
|
|
|
AudioConnection patchCord3(queue_r, volume_l); |
|
|
|
AudioConnection patchCord3(volume_r, peak_r); |
|
|
|
AudioConnection patchCord4(volume_r, peak_r); |
|
|
|
AudioConnection patchCord4(volume_l, peak_l); |
|
|
|
AudioConnection patchCord5(volume_l, peak_l); |
|
|
|
AudioConnection patchCord5(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord6(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord6(volume_l, 0, pt8211_1, 0); |
|
|
|
AudioConnection patchCord7(volume_l, 0, pt8211_1, 0); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
// GUItool: end automatically generated code
|
|
|
|
// GUItool: end automatically generated code
|
|
|
|
|
|
|
|
|
|
|
|
mdaEPiano* ep; |
|
|
|
mdaEPiano* ep; |
|
|
|
bool sd_card_available = false; |
|
|
|
|
|
|
|
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; |
|
|
|
uint32_t peak = 0; |
|
|
|
uint32_t peak = 0; |
|
|
|
uint16_t render_time_max = 0; |
|
|
|
uint16_t render_time_max = 0; |
|
|
|
uint8_t bank = 0; |
|
|
|
|
|
|
|
uint8_t voice = 0; |
|
|
|
|
|
|
|
float vol = VOLUME; |
|
|
|
float vol = VOLUME; |
|
|
|
float vol_right = 1.0; |
|
|
|
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 MASTER_KEY_MIDI |
|
|
|
|
|
|
|
bool master_key_enabled = false; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
elapsedMillis cpu_mem_millis; |
|
|
|
elapsedMillis cpu_mem_millis; |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -129,7 +120,6 @@ 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); |
|
|
|
#ifndef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
lcd.init(); |
|
|
|
lcd.init(); |
|
|
|
lcd.blink_off(); |
|
|
|
lcd.blink_off(); |
|
|
|
lcd.cursor_off(); |
|
|
|
lcd.cursor_off(); |
|
|
@ -140,13 +130,12 @@ void setup() |
|
|
|
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); |
|
|
|
enc1.write(INITIAL_ENC1_VALUE); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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://about.teahub.io/dcoredump/MicroMDAEpiano")); |
|
|
|
Serial.print(F("Data in PROGMEM: ")); |
|
|
|
Serial.print(F("Data in PROGMEM: ")); |
|
|
|
Serial.print(sizeof(epianoData), 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>")); |
|
|
@ -175,6 +164,7 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
// start audio card
|
|
|
|
// start audio card
|
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
sgtl5000_1.enable(); |
|
|
|
sgtl5000_1.enable(); |
|
|
|
//sgtl5000_1.dacVolumeRamp();
|
|
|
|
//sgtl5000_1.dacVolumeRamp();
|
|
|
@ -187,19 +177,6 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
set_volume(vol, vol_left, vol_right); |
|
|
|
set_volume(vol, vol_left, vol_right); |
|
|
|
|
|
|
|
|
|
|
|
// start SD card
|
|
|
|
|
|
|
|
SPI.setMOSI(SDCARD_MOSI_PIN); |
|
|
|
|
|
|
|
SPI.setSCK(SDCARD_SCK_PIN); |
|
|
|
|
|
|
|
if (!SD.begin(SDCARD_CS_PIN)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.println(F("SD card not accessable")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.println(F("SD card found.")); |
|
|
|
|
|
|
|
sd_card_available = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
// Initialize processor and memory measurements
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
@ -238,8 +215,8 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
void loop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * int16_t
|
|
|
|
int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t)
|
|
|
|
int16_t* audio_buffer_l; // pointer to AUDIO_BLOCK_SAMPLES * int16_t
|
|
|
|
int16_t* audio_buffer_l; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(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); |
|
|
|
|
|
|
|
|
|
|
|
// Main sound calculation
|
|
|
|
// Main sound calculation
|
|
|
@ -333,14 +310,12 @@ void handle_input(void) |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
int enc1_val = enc1.read(); |
|
|
|
int enc1_val = enc1.read(); |
|
|
|
|
|
|
|
|
|
|
|
if (but1.update()) |
|
|
|
if (but1.update()) |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -364,69 +339,6 @@ void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
bool handle_master_key(uint8_t data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int8_t num = num_key_base_c(data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Master-Key: ")); |
|
|
|
|
|
|
|
Serial.println(num, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (num > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// a white key!
|
|
|
|
|
|
|
|
if (num <= 32) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (load_sysex(bank, num)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Loading voice number ")); |
|
|
|
|
|
|
|
Serial.println(num, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOICE_ADDR, num); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("E: cannot load voice number ")); |
|
|
|
|
|
|
|
Serial.println(num, DEC); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// a black key!
|
|
|
|
|
|
|
|
num = abs(num); |
|
|
|
|
|
|
|
if (num <= 10) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
set_volume(float(num * 0.1), vol_left, vol_right); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (num > 10 && num <= 20) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bank = num - 10; |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Bank switch to: ")); |
|
|
|
|
|
|
|
Serial.println(bank, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool load_sysex(uint8_t bank, uint8_t num) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool ret = false; |
|
|
|
bool ret = false; |
|
|
@ -455,94 +367,11 @@ bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
// now throw away the MIDI channel information
|
|
|
|
// now throw away the MIDI channel information
|
|
|
|
type &= 0xf0; |
|
|
|
type &= 0xf0; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
ret = ep->processMidiMessage(type, data1, data2); |
|
|
|
if (type == 0x80 && data1 == MASTER_KEY_MIDI) // Master key released
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
master_key_enabled = false; |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Master key disabled")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (type == 0x90 && data1 == MASTER_KEY_MIDI) // Master key pressed
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
master_key_enabled = true; |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Master key enabled")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (master_key_enabled) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (type == 0x80) // handle when note is released
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//dexed->notesOff();
|
|
|
|
|
|
|
|
handle_master_key(data1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
ret = ep->processMidiMessage(type, data1, data2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return (ret); |
|
|
|
return (ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
|
|
|
|
int8_t num_key_base_c(uint8_t midi_note) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int8_t num = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (midi_note % 12) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// positive numbers are white keys, negative black ones
|
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
num = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
num = -1; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
num = 2; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
num = -2; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
num = 3; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 5: |
|
|
|
|
|
|
|
num = 4; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 6: |
|
|
|
|
|
|
|
num = -3; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 7: |
|
|
|
|
|
|
|
num = 5; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 8: |
|
|
|
|
|
|
|
num = -4; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 9: |
|
|
|
|
|
|
|
num = 6; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 10: |
|
|
|
|
|
|
|
num = -5; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 11: |
|
|
|
|
|
|
|
num = 7; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (num > 0) |
|
|
|
|
|
|
|
return (num + (((midi_note - MASTER_NUM1) / 12) * 7)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return (num + ((((midi_note - MASTER_NUM1) / 12) * 5) * -1)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void set_volume(float v, float vr, float vl) |
|
|
|
void set_volume(float v, float vr, float vl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vol = v; |
|
|
|
vol = v; |
|
|
@ -588,73 +417,6 @@ void set_volume(float v, float vr, float vl) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (sysex[1] != 0x43) // check for Yamaha sysex
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("E: SysEx vendor not Yamaha.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parse parameter change
|
|
|
|
|
|
|
|
if (len == 7) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((sysex[3] & 0x7c) != 0 || (sysex[3] & 0x7c) != 2) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("E: Not a SysEx parameter or function parameter change.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sysex[6] != 0xf7) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("E: SysEx end status byte not detected.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ((sysex[3] & 0x7c) == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dexed->data[sysex[4]] = sysex[5]; // set parameter
|
|
|
|
|
|
|
|
dexed->doRefreshVoice(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET - 63 + sysex[4]] = sysex[5]; // set function parameter
|
|
|
|
|
|
|
|
dexed->controllers.values_[kControllerPitchRange] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE]; |
|
|
|
|
|
|
|
dexed->controllers.values_[kControllerPitchStep] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP]; |
|
|
|
|
|
|
|
dexed->controllers.wheel.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE]); |
|
|
|
|
|
|
|
dexed->controllers.wheel.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN]); |
|
|
|
|
|
|
|
dexed->controllers.foot.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE]); |
|
|
|
|
|
|
|
dexed->controllers.foot.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN]); |
|
|
|
|
|
|
|
dexed->controllers.breath.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE]); |
|
|
|
|
|
|
|
dexed->controllers.breath.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN]); |
|
|
|
|
|
|
|
dexed->controllers.at.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE]); |
|
|
|
|
|
|
|
dexed->controllers.at.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN]); |
|
|
|
|
|
|
|
dexed->controllers.masterTune = (dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] * 0x4000 << 11) * (1.0 / 12); |
|
|
|
|
|
|
|
dexed->controllers.refresh(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("SysEx")); |
|
|
|
|
|
|
|
if ((sysex[3] & 0x7c) == 0) |
|
|
|
|
|
|
|
Serial.print(F(" function")); |
|
|
|
|
|
|
|
Serial.print(F(" parameter ")); |
|
|
|
|
|
|
|
Serial.print(sysex[4], DEC); |
|
|
|
|
|
|
|
Serial.print(F(" = ")); |
|
|
|
|
|
|
|
Serial.println(sysex[5], DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Serial.println(F("E: SysEx parameter length wrong.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
@ -671,8 +433,6 @@ void initial_values_from_eeprom(void) |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F(" - mismatch -> initializing EEPROM!")); |
|
|
|
Serial.print(F(" - mismatch -> initializing EEPROM!")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOICE_ADDR, voice); |
|
|
|
|
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
@ -680,8 +440,6 @@ void initial_values_from_eeprom(void) |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
bank = EEPROM.read(EEPROM_OFFSET + EEPROM_BANK_ADDR); |
|
|
|
|
|
|
|
voice = EEPROM.read(EEPROM_OFFSET + EEPROM_VOICE_ADDR); |
|
|
|
|
|
|
|
vol = float(EEPROM.read(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR)) / UCHAR_MAX; |
|
|
|
vol = float(EEPROM.read(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR)) / UCHAR_MAX; |
|
|
|
vol_right = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_right = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_left = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR)) / UCHAR_MAX; |
|
|
|
vol_left = float(EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR)) / UCHAR_MAX; |