|
|
@ -24,7 +24,6 @@ |
|
|
|
#include <limits.h> |
|
|
|
#include <limits.h> |
|
|
|
#include "config.h" |
|
|
|
#include "config.h" |
|
|
|
#include <Audio.h> |
|
|
|
#include <Audio.h> |
|
|
|
#include <OpenAudio_ArduinoLibrary.h> |
|
|
|
|
|
|
|
#include <Wire.h> |
|
|
|
#include <Wire.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include <EEPROM.h> |
|
|
|
#include <EEPROM.h> |
|
|
@ -44,9 +43,7 @@ |
|
|
|
#include "UI.hpp" |
|
|
|
#include "UI.hpp" |
|
|
|
|
|
|
|
|
|
|
|
// Audio engines
|
|
|
|
// Audio engines
|
|
|
|
//AudioSynthDexed* MicroDexed[NUM_DEXED];
|
|
|
|
AudioSynthDexed* MicroDexed[NUM_DEXED]; |
|
|
|
AudioSynthDexed_F32* MicroDexed[NUM_DEXED]; |
|
|
|
|
|
|
|
AudioConvert_F32toI16* convertf32toi16[NUM_DEXED]; |
|
|
|
|
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
|
AudioSynthWaveform* chorus_modulator[NUM_DEXED]; |
|
|
|
AudioSynthWaveform* chorus_modulator[NUM_DEXED]; |
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
@ -179,9 +176,7 @@ AudioConnection * dynamicConnections[NUM_DEXED * 5]; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//MicroDexed[instance_id] = new AudioSynthDexed(SAMPLE_RATE);
|
|
|
|
MicroDexed[instance_id] = new AudioSynthDexed(SAMPLE_RATE); |
|
|
|
MicroDexed[instance_id] = new AudioSynthDexed_F32(SAMPLE_RATE); |
|
|
|
|
|
|
|
convertf32toi16[instance_id] = new AudioConvert_F32toI16(); |
|
|
|
|
|
|
|
mono2stereo[instance_id] = new AudioEffectMonoStereo(); |
|
|
|
mono2stereo[instance_id] = new AudioEffectMonoStereo(); |
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
|
chorus_modulator[instance_id] = new AudioSynthWaveform(); |
|
|
|
chorus_modulator[instance_id] = new AudioSynthWaveform(); |
|
|
@ -196,14 +191,10 @@ void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id); |
|
|
|
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *convertf32toi16[instance_id], 0);
|
|
|
|
|
|
|
|
//dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, microdexed_peak_mixer, instance_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0); |
|
|
|
//dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *chorus_mixer[instance_id], 0);
|
|
|
|
|
|
|
|
//dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *modchorus[instance_id], 0);
|
|
|
|
|
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*chorus_modulator[instance_id], 0, *modchorus_filter[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*chorus_modulator[instance_id], 0, *modchorus_filter[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*modchorus_filter[instance_id], 0, *modchorus[instance_id], 1); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*modchorus_filter[instance_id], 0, *modchorus[instance_id], 1); |
|
|
@ -220,8 +211,7 @@ void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, reverb_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, reverb_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, reverb_mixer_l, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, reverb_mixer_l, instance_id); |
|
|
|
#else |
|
|
|
#else |
|
|
|
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *mono2stereo[instance_id], 0);
|
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); |
|
|
@ -230,9 +220,13 @@ void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
uint8_t sd_card = 0; |
|
|
|
uint8_t sd_card = 0; |
|
|
|
Sd2Card card; |
|
|
|
Sd2Card card; |
|
|
|
SdVolume volume; |
|
|
|
SdVolume volume; |
|
|
|
uint8_t midi_timing_counter = 0; // 24 per qarter
|
|
|
|
uint8_t midi_ticks[10] = {0, 6, 9, 12, 18, 24, 36, 48, 72, 96}; |
|
|
|
elapsedMillis midi_timing_timestep; |
|
|
|
uint8_t midi_bpm_counter = 0; |
|
|
|
uint16_t midi_timing_quarter = 0; |
|
|
|
elapsedMillis midi_bpm; |
|
|
|
|
|
|
|
#ifdef USE_FX |
|
|
|
|
|
|
|
uint8_t midi_timing_counter[NUM_DEXED]; |
|
|
|
|
|
|
|
elapsedMillis midi_timing_timer[NUM_DEXED]; |
|
|
|
|
|
|
|
#endif |
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
elapsedMillis control_rate; |
|
|
|
elapsedMillis control_rate; |
|
|
|
uint8_t active_voices[NUM_DEXED]; |
|
|
|
uint8_t active_voices[NUM_DEXED]; |
|
|
@ -327,7 +321,6 @@ void setup() |
|
|
|
setup_midi_devices(); |
|
|
|
setup_midi_devices(); |
|
|
|
|
|
|
|
|
|
|
|
// Start audio system
|
|
|
|
// Start audio system
|
|
|
|
AudioMemory_F32(AUDIO_MEM_F32, {44117.0, 128}); |
|
|
|
|
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
@ -467,7 +460,6 @@ void setup() |
|
|
|
// Initialize processor and memory measurements
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset_F32(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
@ -1382,21 +1374,49 @@ void handleTuneRequest(void) |
|
|
|
|
|
|
|
|
|
|
|
void handleClock(void) |
|
|
|
void handleClock(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
midi_timing_counter++; |
|
|
|
|
|
|
|
if (midi_timing_counter % 24 == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
midi_timing_quarter = midi_timing_timestep; |
|
|
|
|
|
|
|
midi_timing_counter = 0; |
|
|
|
|
|
|
|
midi_timing_timestep = 0; |
|
|
|
|
|
|
|
// Adjust delay control here
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
if (midi_bpm_counter % 24 == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
Serial.print(F("MIDI Clock: ")); |
|
|
|
Serial.print(F("MIDI Clock: ")); |
|
|
|
Serial.print(60000 / midi_timing_quarter, DEC); |
|
|
|
Serial.print(60000.0f / midi_bpm, 2); |
|
|
|
Serial.print(F("bpm (")); |
|
|
|
Serial.print(F("bpm (")); |
|
|
|
Serial.print(midi_timing_quarter, DEC); |
|
|
|
Serial.print(midi_bpm, DEC); |
|
|
|
Serial.println(F("ms per quarter)")); |
|
|
|
Serial.println(F("ms per quarter)")); |
|
|
|
|
|
|
|
midi_bpm = 0; |
|
|
|
|
|
|
|
midi_bpm_counter = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
midi_bpm_counter++; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_FX |
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (midi_ticks[configuration.fx.delay_sync[instance_id]] > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1 1/16 = 6 ticks |
|
|
|
|
|
|
|
2 1/16T = 9 ticks |
|
|
|
|
|
|
|
3 1/8 = 12 ticks |
|
|
|
|
|
|
|
4 1/8T = 18 ticks |
|
|
|
|
|
|
|
5 1/4 = 24 ticks |
|
|
|
|
|
|
|
6 1/4T = 36 ticks |
|
|
|
|
|
|
|
7 1/2 = 48 ticks |
|
|
|
|
|
|
|
8 1/2T = 72 ticks |
|
|
|
|
|
|
|
9 1/1 = 96 ticks |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (midi_timing_counter[instance_id] % midi_ticks[configuration.fx.delay_sync[instance_id]] == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int32_t t = midi_timing_timer[instance_id]; |
|
|
|
|
|
|
|
delay_fx[instance_id]->delay(0, constrain(t, DELAY_TIME_MIN, DELAY_TIME_MAX)); |
|
|
|
|
|
|
|
midi_timing_counter[instance_id] = 0; |
|
|
|
|
|
|
|
midi_timing_timer[instance_id] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
midi_timing_counter[instance_id]++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleStart(void) |
|
|
|
void handleStart(void) |
|
|
@ -1645,6 +1665,7 @@ void check_configuration(void) |
|
|
|
configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); |
|
|
|
configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); |
|
|
|
configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); |
|
|
|
configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); |
|
|
|
configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); |
|
|
|
configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); |
|
|
|
|
|
|
|
configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX); |
|
|
|
configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX); |
|
|
|
configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1721,6 +1742,7 @@ void init_configuration(void) |
|
|
|
configuration.fx.delay_time[instance_id] = DELAY_TIME_DEFAULT / 10; |
|
|
|
configuration.fx.delay_time[instance_id] = DELAY_TIME_DEFAULT / 10; |
|
|
|
configuration.fx.delay_feedback[instance_id] = DELAY_FEEDBACK_DEFAULT; |
|
|
|
configuration.fx.delay_feedback[instance_id] = DELAY_FEEDBACK_DEFAULT; |
|
|
|
configuration.fx.delay_level[instance_id] = DELAY_LEVEL_DEFAULT; |
|
|
|
configuration.fx.delay_level[instance_id] = DELAY_LEVEL_DEFAULT; |
|
|
|
|
|
|
|
configuration.fx.delay_sync[instance_id] = DELAY_SYNC_DEFAULT; |
|
|
|
configuration.fx.reverb_send[instance_id] = REVERB_SEND_DEFAULT; |
|
|
|
configuration.fx.reverb_send[instance_id] = REVERB_SEND_DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
configuration.performance.bank[instance_id] = SYSEXBANK_DEFAULT; |
|
|
|
configuration.performance.bank[instance_id] = SYSEXBANK_DEFAULT; |
|
|
@ -2241,12 +2263,6 @@ void show_cpu_and_mem_usage(void) |
|
|
|
Serial.print(AudioProcessorUsageMax(), 2); |
|
|
|
Serial.print(AudioProcessorUsageMax(), 2); |
|
|
|
Serial.print(F("%|CPUMAXCNT:")); |
|
|
|
Serial.print(F("%|CPUMAXCNT:")); |
|
|
|
Serial.print(cpumax, DEC); |
|
|
|
Serial.print(cpumax, DEC); |
|
|
|
Serial.print(F("|MEM_F32:")); |
|
|
|
|
|
|
|
Serial.print(AudioMemoryUsage_F32(), DEC); |
|
|
|
|
|
|
|
Serial.print(F("|MEMMAX_F32:")); |
|
|
|
|
|
|
|
Serial.print(AudioMemoryUsageMax_F32(), DEC); |
|
|
|
|
|
|
|
Serial.print(F("|AUDIO_MEM_MAX_F32:")); |
|
|
|
|
|
|
|
Serial.print(AUDIO_MEM_F32, DEC); |
|
|
|
|
|
|
|
Serial.print(F("|MEM:")); |
|
|
|
Serial.print(F("|MEM:")); |
|
|
|
Serial.print(AudioMemoryUsage(), DEC); |
|
|
|
Serial.print(AudioMemoryUsage(), DEC); |
|
|
|
Serial.print(F("|MEMMAX:")); |
|
|
|
Serial.print(F("|MEMMAX:")); |
|
|
@ -2283,7 +2299,6 @@ void show_cpu_and_mem_usage(void) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset_F32(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -2325,6 +2340,7 @@ void show_configuration(void) |
|
|
|
Serial.print(F(" Delay Time ")); Serial.println(configuration.fx.delay_time[instance_id], DEC); |
|
|
|
Serial.print(F(" Delay Time ")); Serial.println(configuration.fx.delay_time[instance_id], DEC); |
|
|
|
Serial.print(F(" Delay Feedback ")); Serial.println(configuration.fx.delay_feedback[instance_id], DEC); |
|
|
|
Serial.print(F(" Delay Feedback ")); Serial.println(configuration.fx.delay_feedback[instance_id], DEC); |
|
|
|
Serial.print(F(" Delay Level ")); Serial.println(configuration.fx.delay_level[instance_id], DEC); |
|
|
|
Serial.print(F(" Delay Level ")); Serial.println(configuration.fx.delay_level[instance_id], DEC); |
|
|
|
|
|
|
|
Serial.print(F(" Delay Sync ")); Serial.println(configuration.fx.delay_sync[instance_id], DEC); |
|
|
|
Serial.print(F(" Reverb Send ")); Serial.println(configuration.fx.reverb_send[instance_id], DEC); |
|
|
|
Serial.print(F(" Reverb Send ")); Serial.println(configuration.fx.reverb_send[instance_id], DEC); |
|
|
|
Serial.print(F(" Sound Intensity ")); Serial.println(configuration.dexed[instance_id].sound_intensity, DEC); |
|
|
|
Serial.print(F(" Sound Intensity ")); Serial.println(configuration.dexed[instance_id].sound_intensity, DEC); |
|
|
|
Serial.print(F(" Panorama ")); Serial.println(configuration.dexed[instance_id].pan, DEC); |
|
|
|
Serial.print(F(" Panorama ")); Serial.println(configuration.dexed[instance_id].pan, DEC); |
|
|
|