|
|
@ -10,7 +10,6 @@ |
|
|
|
#include <SPI.h> |
|
|
|
#include <SPI.h> |
|
|
|
#include <SD.h> |
|
|
|
#include <SD.h> |
|
|
|
#include <SerialFlash.h> |
|
|
|
#include <SerialFlash.h> |
|
|
|
#include <TeensyThreads.h> |
|
|
|
|
|
|
|
#include <QueueArray.h> |
|
|
|
#include <QueueArray.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include <MIDI.h> |
|
|
|
#include "dexed.h" |
|
|
|
#include "dexed.h" |
|
|
@ -18,20 +17,11 @@ |
|
|
|
#define AUDIO_MEM 32 |
|
|
|
#define AUDIO_MEM 32 |
|
|
|
#define AUDIO_BUFFER_SIZE 128 |
|
|
|
#define AUDIO_BUFFER_SIZE 128 |
|
|
|
#define SAMPLEAUDIO_BUFFER_SIZE 44100 |
|
|
|
#define SAMPLEAUDIO_BUFFER_SIZE 44100 |
|
|
|
#define MIDI_QUEUE_LOCK_TIMEOUT_MS 0 |
|
|
|
|
|
|
|
#define INIT_AUDIO_QUEUE 1 |
|
|
|
#define INIT_AUDIO_QUEUE 1 |
|
|
|
#define SHOW_DEXED_TIMING 1 |
|
|
|
#define SHOW_DEXED_TIMING 1 |
|
|
|
|
|
|
|
#define SHOW_CPU_LOAD |
|
|
|
#define TEST_MIDI 1 |
|
|
|
#define TEST_MIDI 1 |
|
|
|
#define TEST_NOTE1 60 |
|
|
|
#define TEST_NOTE 60 |
|
|
|
#define TEST_NOTE2 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint8_t cmd; |
|
|
|
|
|
|
|
uint8_t data1; |
|
|
|
|
|
|
|
uint8_t data2; |
|
|
|
|
|
|
|
} midi_queue_t; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
AudioPlayQueue queue1; //xy=266,484
|
|
|
|
AudioPlayQueue queue1; //xy=266,484
|
|
|
@ -63,8 +53,10 @@ 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 |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef INIT_AUDIO_QUEUE |
|
|
|
#ifdef INIT_AUDIO_QUEUE |
|
|
|
// initial fill audio buffer with empty data
|
|
|
|
// initial fill audio buffer with empty data
|
|
|
@ -82,10 +74,19 @@ void setup() |
|
|
|
dexed->activate(); |
|
|
|
dexed->activate(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEST_MIDI |
|
|
|
#ifdef TEST_MIDI |
|
|
|
threads.addThread(midi_test_thread, 1); |
|
|
|
queue_midi_event(0x90, TEST_NOTE, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 5, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 8, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 12, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 12, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 17, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 20, 100); |
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE + 24, 100); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_CPU_LOAD |
|
|
|
sched.begin(cpu_and_mem_usage, 1000000); |
|
|
|
sched.begin(cpu_and_mem_usage, 1000000); |
|
|
|
|
|
|
|
#endif |
|
|
|
Serial.println(F("setup end")); |
|
|
|
Serial.println(F("setup end")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -98,13 +99,13 @@ void loop() |
|
|
|
if (audio_buffer == NULL) |
|
|
|
if (audio_buffer == NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.println(F("audio_buffer allocation problems!")); |
|
|
|
Serial.println(F("audio_buffer allocation problems!")); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (MIDI.read()) |
|
|
|
while (MIDI.read()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
break_for_calculation = dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2()); |
|
|
|
break_for_calculation = dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2()); |
|
|
|
if (break_for_calculation == true) |
|
|
|
if (break_for_calculation == true) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_DEXED_TIMING |
|
|
|
#ifdef SHOW_DEXED_TIMING |
|
|
@ -118,34 +119,12 @@ void loop() |
|
|
|
queue1.playBuffer(); |
|
|
|
queue1.playBuffer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void midi_test_thread(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delay(100); |
|
|
|
|
|
|
|
/*queue_midi_event(0x90, TEST_NOTE1, 100);
|
|
|
|
|
|
|
|
queue_midi_event(0x90, TEST_NOTE2, 100); |
|
|
|
|
|
|
|
delay(1000); |
|
|
|
|
|
|
|
queue_midi_event(0x80, TEST_NOTE1, 100); |
|
|
|
|
|
|
|
delay(1000); |
|
|
|
|
|
|
|
queue_midi_event(0x80, TEST_NOTE2, 100); |
|
|
|
|
|
|
|
delay(500);*/ |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < 16; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
queue_midi_event(0x90, 55 + i, 100); |
|
|
|
|
|
|
|
delay(1000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
delay(1000); |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < 16; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
queue_midi_event(0x80, 55 + i, 100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
threads.yield(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
void cpu_and_mem_usage(void) |
|
|
|
void cpu_and_mem_usage(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.print(F("CPU:")); |
|
|
|
Serial.print(F("CPU:")); |
|
|
@ -157,5 +136,8 @@ void cpu_and_mem_usage(void) |
|
|
|
Serial.print(F(" MEM MAX:")); |
|
|
|
Serial.print(F(" MEM MAX:")); |
|
|
|
Serial.print(AudioMemoryUsageMax(), DEC); |
|
|
|
Serial.print(AudioMemoryUsageMax(), DEC); |
|
|
|
Serial.println(); |
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|