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

@ -89,10 +89,6 @@ Dexed::Dexed(int rate)
controllers.opSwitch = 0x3f; // enable all operators
//controllers.opSwitch=0x00;
bufsize_ = 256;
outbuf_ = new float[bufsize_];
lfo.reset(data + 137);
setMonoMode(false);
@ -108,8 +104,6 @@ Dexed::Dexed(int rate)
Dexed::~Dexed()
{
delete [] outbuf_;
currentNote = -1;
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("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 :
//TRACE("MIDI keyup event: %d", data1);
keyup(data1);

@ -65,7 +65,7 @@ class Dexed
void setMonoMode(bool mode);
void set_params(void);
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;
VoiceStatus voiceStatus;
@ -85,13 +85,10 @@ class Dexed
bool monoMode;
bool refreshVoice;
uint8_t engineType;
//PluginFx fx;
Lfo lfo;
FmCore* engineMsfa;
EngineMkI* engineMkI;
EngineOpl* engineOpl;
float* outbuf_;
uint32_t bufsize_;
int16_t extra_buf_[_N_];
uint32_t extra_buf_size_;

Loading…
Cancel
Save