pull/4/head
Holger Wirtz 7 years ago
parent dcff54c92a
commit c7626929a9
  1. 58
      MicroDexed.ino
  2. 11
      dexed.cpp
  3. 5
      dexed.h

@ -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,8 +99,8 @@ 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());
@ -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

@ -89,10 +89,6 @@ Dexed::Dexed(int rate)
controllers.opSwitch = 0x3f; // enable all operators controllers.opSwitch = 0x3f; // enable all operators
//controllers.opSwitch=0x00; //controllers.opSwitch=0x00;
bufsize_ = 256;
outbuf_ = new float[bufsize_];
lfo.reset(data + 137); lfo.reset(data + 137);
setMonoMode(false); setMonoMode(false);
@ -108,8 +104,6 @@ Dexed::Dexed(int rate)
Dexed::~Dexed() Dexed::~Dexed()
{ {
delete [] outbuf_;
currentNote = -1; currentNote = -1;
for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note)
@ -238,14 +232,13 @@ void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
TRACE("Shutted down Voice[%2d]", i); TRACE("Shutted down Voice[%2d]", i);
} }
} }
// TRACE("Voice[%2d] live=%d keydown=%d",i,voices[i].live,voices[i].keydown);
} }
} }
} }
bool Dexed::ProcessMidiMessage(uint8_t cmd, uint8_t data1, uint8_t data2) bool Dexed::ProcessMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)
{ {
switch (cmd & 0xf0) { switch (type & 0xf0) {
case 0x80 : case 0x80 :
//TRACE("MIDI keyup event: %d", data1); //TRACE("MIDI keyup event: %d", data1);
keyup(data1); keyup(data1);

@ -65,7 +65,7 @@ class Dexed
void setMonoMode(bool mode); void setMonoMode(bool mode);
void set_params(void); void set_params(void);
void GetSamples(uint16_t n_samples, int16_t* buffer); void GetSamples(uint16_t n_samples, int16_t* buffer);
bool ProcessMidiMessage(uint8_t cmd, uint8_t data1, uint8_t data2); bool ProcessMidiMessage(uint8_t type, uint8_t data1, uint8_t data2);
Controllers controllers; Controllers controllers;
VoiceStatus voiceStatus; VoiceStatus voiceStatus;
@ -85,13 +85,10 @@ class Dexed
bool monoMode; bool monoMode;
bool refreshVoice; bool refreshVoice;
uint8_t engineType; uint8_t engineType;
//PluginFx fx;
Lfo lfo; Lfo lfo;
FmCore* engineMsfa; FmCore* engineMsfa;
EngineMkI* engineMkI; EngineMkI* engineMkI;
EngineOpl* engineOpl; EngineOpl* engineOpl;
float* outbuf_;
uint32_t bufsize_;
int16_t extra_buf_[_N_]; int16_t extra_buf_[_N_];
uint32_t extra_buf_size_; uint32_t extra_buf_size_;

Loading…
Cancel
Save