|
|
@ -14,14 +14,14 @@ |
|
|
|
#include <MIDI.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include "dexed.h" |
|
|
|
#include "dexed.h" |
|
|
|
|
|
|
|
|
|
|
|
#define AUDIO_MEM 32 |
|
|
|
#define AUDIO_MEM 2 |
|
|
|
#define AUDIO_BUFFER_SIZE 128 |
|
|
|
#define AUDIO_BUFFER_SIZE 128 |
|
|
|
#define SAMPLEAUDIO_BUFFER_SIZE 44100 |
|
|
|
#define SAMPLEAUDIO_BUFFER_SIZE 44100 |
|
|
|
#define INIT_AUDIO_QUEUE 1 |
|
|
|
#define INIT_AUDIO_QUEUE 1 |
|
|
|
//#define SHOW_DEXED_TIMING 1
|
|
|
|
//#define SHOW_DEXED_TIMING 1
|
|
|
|
#define SHOW_XRUN 1 |
|
|
|
#define SHOW_XRUN 1 |
|
|
|
#define SHOW_CPU_LOAD |
|
|
|
|
|
|
|
#define SHOW_CPU_LOAD_MSEC 5000 |
|
|
|
#define SHOW_CPU_LOAD_MSEC 5000 |
|
|
|
|
|
|
|
#define MAX_NOTES 10 |
|
|
|
#define TEST_MIDI 1 |
|
|
|
#define TEST_MIDI 1 |
|
|
|
#define TEST_NOTE 40 |
|
|
|
#define TEST_NOTE 40 |
|
|
|
#define TEST_VEL 60 |
|
|
|
#define TEST_VEL 60 |
|
|
@ -40,7 +40,7 @@ IntervalTimer sched; |
|
|
|
|
|
|
|
|
|
|
|
void setup() |
|
|
|
void setup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (!Serial) ; // wait for Arduino Serial Monitor
|
|
|
|
//while (!Serial) ; // wait for Arduino Serial Monitor
|
|
|
|
Serial.begin(115200); |
|
|
|
Serial.begin(115200); |
|
|
|
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed")); |
|
|
|
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed")); |
|
|
|
Serial.println(F("(c)2018 H. Wirtz")); |
|
|
|
Serial.println(F("(c)2018 H. Wirtz")); |
|
|
@ -56,7 +56,7 @@ void setup() |
|
|
|
sgtl5000_1.volume(0.2); |
|
|
|
sgtl5000_1.volume(0.2); |
|
|
|
|
|
|
|
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
#ifdef SHOW_CPU_LOAD |
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -75,6 +75,7 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
dexed->activate(); |
|
|
|
dexed->activate(); |
|
|
|
|
|
|
|
dexed->setMaxNotes(MAX_NOTES); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEST_MIDI |
|
|
|
#ifdef TEST_MIDI |
|
|
|
|
|
|
|
|
|
|
@ -89,17 +90,18 @@ void setup() |
|
|
|
queue_midi_event(0x90, TEST_NOTE + 32, TEST_VEL); // 9
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 32, TEST_VEL); // 9
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 37, TEST_VEL); // 10
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 37, TEST_VEL); // 10
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 40, TEST_VEL); // 11
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 40, TEST_VEL); // 11
|
|
|
|
//queue_midi_event(0x90, TEST_NOTE + 44, TEST_VEL); // 12
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 44, TEST_VEL); // 12
|
|
|
|
//queue_midi_event(0x90, TEST_NOTE + 49, TEST_VEL); // 13
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 49, TEST_VEL); // 13
|
|
|
|
//queue_midi_event(0x90, TEST_NOTE + 52, TEST_VEL); // 14
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 52, TEST_VEL); // 14
|
|
|
|
//queue_midi_event(0x90, TEST_NOTE + 57, TEST_VEL); // 15
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 57, TEST_VEL); // 15
|
|
|
|
//queue_midi_event(0x90, TEST_NOTE + 60, TEST_VEL); // 16
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 60, TEST_VEL); // 16
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_CPU_LOAD |
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
sched.begin(cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000); |
|
|
|
sched.begin(cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
Serial.println(F("setup end")); |
|
|
|
Serial.println(F("setup end")); |
|
|
|
|
|
|
|
cpu_and_mem_usage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
void loop() |
|
|
@ -107,6 +109,8 @@ void loop() |
|
|
|
int16_t* audio_buffer; // pointer to 128 * int16_t
|
|
|
|
int16_t* audio_buffer; // pointer to 128 * int16_t
|
|
|
|
bool break_for_calculation; |
|
|
|
bool break_for_calculation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (42 == 42) // DON'T PANIC!
|
|
|
|
|
|
|
|
{ |
|
|
|
audio_buffer = queue1.getBuffer(); |
|
|
|
audio_buffer = queue1.getBuffer(); |
|
|
|
if (audio_buffer == NULL) |
|
|
|
if (audio_buffer == NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -134,13 +138,14 @@ void loop() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
queue1.playBuffer(); |
|
|
|
queue1.playBuffer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return (dexed->ProcessMidiMessage(type, data1, data2)); |
|
|
|
return (dexed->ProcessMidiMessage(type, data1, data2)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_CPU_LOAD |
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
void cpu_and_mem_usage(void) |
|
|
|
void cpu_and_mem_usage(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.print(F("CPU:")); |
|
|
|
Serial.print(F("CPU:")); |
|
|
|