|
|
|
@ -21,14 +21,12 @@ |
|
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "config.h" |
|
|
|
|
#include <Audio.h> |
|
|
|
|
#include <Wire.h> |
|
|
|
|
#include <SPI.h> |
|
|
|
|
#include <MIDI.h> |
|
|
|
|
#include <EEPROM.h> |
|
|
|
|
#include "EEPROMAnything.h" |
|
|
|
|
#include <limits.h> |
|
|
|
|
#include "mdaEPiano.h" |
|
|
|
|
#include "effect_modulated_chorus.h" |
|
|
|
|
#ifdef USE_XFADE_DATA |
|
|
|
@ -38,6 +36,7 @@ |
|
|
|
|
#endif |
|
|
|
|
#include "UI.hpp" |
|
|
|
|
#include "midi_devices.hpp" |
|
|
|
|
#include "config.h" |
|
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
//* GLOBAL VARIABLES
|
|
|
|
@ -213,7 +212,7 @@ void setup() |
|
|
|
|
Serial.println(F("PT8211 enabled.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
#if defined (SHOW_DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
@ -242,10 +241,12 @@ void setup() |
|
|
|
|
modulator.frequency(1.0); |
|
|
|
|
modulator.phase(0); |
|
|
|
|
modulator.offset(0.0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// internal mixing of original signal(0), reverb(1) and chorus(2)
|
|
|
|
|
mixer_r.gain(0, 1.0); |
|
|
|
|
mixer_l.gain(0, 1.0); |
|
|
|
|
mixer_r.gain(1, 0.5); |
|
|
|
|
mixer_l.gain(1, 0.5); |
|
|
|
|
mixer_r.gain(2, 0.5); |
|
|
|
|
mixer_l.gain(2, 0.5); |
|
|
|
|
|
|
|
|
@ -254,7 +255,7 @@ void setup() |
|
|
|
|
|
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
#if defined (SHOW_DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
Serial.println(); |
|
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
|
cpu_mem_millis = 0; |
|
|
|
@ -275,7 +276,7 @@ void loop() |
|
|
|
|
{ |
|
|
|
|
fill_audio_buffer = 0; |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
#if defined (SHOW_DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
if (cpu_mem_millis > SHOW_CPU_LOAD_MSEC) |
|
|
|
|
{ |
|
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
@ -474,7 +475,7 @@ bool checkMidiChannel(byte inChannel) |
|
|
|
|
} |
|
|
|
|
else if (inChannel != configuration.midi_channel) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
Serial.print(F("Ignoring MIDI data on channel ")); |
|
|
|
|
Serial.print(inChannel); |
|
|
|
|
Serial.print(F("(listening on ")); |
|
|
|
@ -492,7 +493,7 @@ void set_master_volume(uint8_t value) |
|
|
|
|
uint16_t tmp = map(value, ENC_MASTER_VOLUME_MIN, ENC_MASTER_VOLUME_MAX, 0, 0x3ff); |
|
|
|
|
float tmp2 = mapfloat(configuration.pan, ENC_MASTER_PAN_MIN, ENC_MASTER_PAN_MAX, 0.0, 1.0); |
|
|
|
|
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
Serial.print(F("Setting volume: VOL=")); |
|
|
|
|
Serial.print(value, DEC); |
|
|
|
|
Serial.print(F("[")); |
|
|
|
@ -531,7 +532,7 @@ void config_from_eeprom(void) |
|
|
|
|
EEPROM_readAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), tmp_conf); |
|
|
|
|
checksum = crc32((byte*)&tmp_conf + 4, sizeof(tmp_conf) - 4); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
Serial.print(F("Reading sound ")); |
|
|
|
|
Serial.print(sound, DEC); |
|
|
|
|
Serial.print(F(" from 0x")); |
|
|
|
@ -545,17 +546,22 @@ void config_from_eeprom(void) |
|
|
|
|
if (checksum == tmp_conf.checksum) |
|
|
|
|
{ |
|
|
|
|
EEPROM_readAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), configuration); |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
Serial.print(F(" - OK")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
Serial.println(F(" - mismatch -> loading initial configuration.")); |
|
|
|
|
#endif |
|
|
|
|
set_complete_configuration(); |
|
|
|
|
EEPROM.update(EEPROM_SOUND, sound); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
show_sound(); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void initial_values_from_eeprom(void) |
|
|
|
@ -621,7 +627,7 @@ uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https:/ |
|
|
|
|
//* DEBUG FUNCTIONS
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
#if defined (SHOW_DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
void show_cpu_and_mem_usage(void) |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("CPU: ")); |
|
|
|
|