Small fixes and tests.

pull/4/head
Holger Wirtz 7 years ago
parent d18b6bf1aa
commit 4660200948
  1. 97
      MicroDexed.ino
  2. 4
      dexed.cpp
  3. 16
      dexed.h
  4. 3
      dx7note.cpp
  5. 4
      synth.h

@ -6,7 +6,8 @@
#define RATE 128 #define RATE 128
#define TEENSY 1 #define TEENSY 1
#define TEST_MIDI 1 #define TEST_MIDI 1
#define TEST_NOTE 32 #define TEST_NOTE1 59
#define TEST_NOTE2 60
#ifdef TEENSY #ifdef TEENSY
#include <Audio.h> #include <Audio.h>
@ -16,15 +17,28 @@
#include <SerialFlash.h> #include <SerialFlash.h>
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=811,259 AudioPlayQueue queue1; //xy=266,484
AudioOutputI2S i2s1; //xy=1185,252 AudioEffectReverb reverb1; //xy=486,545
AudioConnection patchCord1(queue1, 0, i2s1, 0); AudioOutputI2S i2s1; //xy=739,486
AudioConnection patchCord2(queue1, 0, i2s1, 1); AudioConnection patchCord1(queue1, reverb1);
AudioControlSGTL5000 sgtl5000_1; //xy=830,376 AudioConnection patchCord2(reverb1, 0, i2s1, 0);
AudioConnection patchCord3(reverb1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=384,610
// GUItool: end automatically generated code // GUItool: end automatically generated code
/*
// GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=811,259
AudioOutputI2S i2s1; //xy=1185,252
AudioConnection patchCord1(queue1, 0, i2s1, 0);
AudioConnection patchCord2(queue1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=830,376
// GUItool: end automatically generated code
*/
#endif #endif
MIDI_CREATE_DEFAULT_INSTANCE(); MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
Dexed* dexed = new Dexed(RATE); Dexed* dexed = new Dexed(RATE);
@ -40,10 +54,10 @@ void setup()
#ifdef TEENSY #ifdef TEENSY
// Audio connections require memory to work. For more // Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example // detailed information, see the MemoryAndCpuUsage example
AudioMemory(8); AudioMemory(16);
sgtl5000_1.enable(); sgtl5000_1.enable();
sgtl5000_1.volume(0.3); sgtl5000_1.volume(0.6);
// Initialize processor and memory measurements // Initialize processor and memory measurements
//AudioProcessorUsageMaxReset(); //AudioProcessorUsageMaxReset();
@ -52,18 +66,24 @@ void setup()
// initial fill audio buffer // initial fill audio buffer
while (queue1.available()) while (queue1.available())
{ {
queue1.getBuffer(); int16_t* audio_buffer = queue1.getBuffer();
queue1.playBuffer(); if (audio_buffer != NULL)
{
memset(audio_buffer,0,RATE);
queue1.playBuffer();
}
} }
#endif #endif
dexed->activate(); dexed->activate();
#ifdef TEST_MIDI #ifdef TEST_MIDI
dexed->ProcessMidiMessage(0x90, TEST_NOTE, 100); dexed->ProcessMidiMessage(0x90, TEST_NOTE1, 100);
//dexed->ProcessMidiMessage(0x90, 66, 127); dexed->ProcessMidiMessage(0x90, TEST_NOTE2, 60);
#endif #endif
reverb1.reverbTime(5.0);
Serial.println("Go"); Serial.println("Go");
} }
@ -73,7 +93,9 @@ void loop()
#ifdef TEST_MIDI #ifdef TEST_MIDI
if (millis() > 3000 && millis() < 3050) if (millis() > 3000 && millis() < 3050)
dexed->ProcessMidiMessage(0x80, TEST_NOTE, 0); dexed->ProcessMidiMessage(0x80, TEST_NOTE1, 0);
if (millis() > 5000 && millis() < 5050)
dexed->ProcessMidiMessage(0x80, TEST_NOTE2, 0);
#endif #endif
#ifdef TEENSY #ifdef TEENSY
@ -88,28 +110,35 @@ void loop()
// process midi->audio // process midi->audio
if (MIDI.read()) if (MIDI.read())
{ {
Serial.print("Type: ");
Serial.print(MIDI.getType(), DEC);
Serial.print(" Data1: ");
Serial.print(MIDI.getData1(), DEC);
Serial.print(" Data2: ");
Serial.println(MIDI.getData2(), DEC);
dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2()); dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2());
} }
else
dexed->GetSamples(RATE, audio_buffer);
dexed->GetSamples(RATE, audio_buffer);
/* uint8_t i = 0;
for (i = 0; i < 128; i++) /* uint8_t i = 0;
{ for (i = 0; i < 128; i++)
if ((i % 16) == 0) {
Serial.println(); if ((i % 16) == 0)
Serial.println();
if (i < 10)
Serial.print(" "); if (i < 10)
if (i > 9 && i < 100) Serial.print(" ");
Serial.print(" "); if (i > 9 && i < 100)
Serial.print("["); Serial.print(" ");
Serial.print(i, DEC); Serial.print("[");
Serial.print("]:"); Serial.print(i, DEC);
Serial.print(audio_buffer[i]); Serial.print("]:");
Serial.print(" "); Serial.print(audio_buffer[i]);
} Serial.print(" ");
Serial.println();*/ }
Serial.println();*/
#ifdef TEENSY #ifdef TEENSY
queue1.playBuffer(); queue1.playBuffer();

@ -195,7 +195,7 @@ void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
{ {
//buffer[i + j] = static_cast<int16_t>(sumbuf[j]*0x8000); //buffer[i + j] = static_cast<int16_t>(sumbuf[j]*0x8000);
buffer[i + j] = sumbuf[j]; buffer[i + j] = sumbuf[j];
Serial.println(buffer[i + j], DEC); //Serial.println(buffer[i + j], DEC);
} }
else else
extra_buf_[j - jmax] = sumbuf[j]; extra_buf_[j - jmax] = sumbuf[j];
@ -350,7 +350,7 @@ void Dexed::keydown(uint8_t pitch, uint8_t velo) {
voices[note].velocity = velo; voices[note].velocity = velo;
voices[note].sustained = sustain; voices[note].sustained = sustain;
voices[note].keydown = true; voices[note].keydown = true;
voices[note].dx7_note->init(data, pitch, velo); voices[note].dx7_note->init(data, (int)pitch, (int)velo);
if ( data[136] ) if ( data[136] )
voices[note].dx7_note->oscSync(); voices[note].dx7_note->oscSync();
break; break;

@ -99,13 +99,14 @@ class Dexed
uint16_t _rate; uint16_t _rate;
uint8_t _k_rate_counter; uint8_t _k_rate_counter;
uint8_t _param_change_counter; uint8_t _param_change_counter;
uint8_t data[173] = { uint8_t data[173] = {
95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, 95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, // OP
95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, // OP
95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, 95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, // OP
95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 07, 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 07, // OP
95, 50, 35, 78, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 07, 58, 00, 14, 00, 07, 95, 50, 35, 78, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 07, 58, 00, 14, 00, 07, // OP
96, 25, 25, 67, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 10, 96, 25, 25, 67, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 10, // OP
94, 67, 95, 60, 50, 50, 50, 50, 94, 67, 95, 60, 50, 50, 50, 50,
04, 06, 00, 04, 06, 00,
34, 33, 00, 00, 00, 04, 34, 33, 00, 00, 00, 04,
@ -115,7 +116,8 @@ class Dexed
00, 00,
01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01,
16 16
}; }; // INIT
}; };
#endif // PLUGINPROCESSOR_H_INCLUDED #endif // PLUGINPROCESSOR_H_INCLUDED

@ -144,7 +144,8 @@ Dx7Note::Dx7Note() {
} }
} }
void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity) { //void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity) {
void Dx7Note::init(const uint8_t patch[173], int midinote, int velocity) {
int rates[4]; int rates[4];
int levels[4]; int levels[4];
for (int op = 0; op < 6; op++) { for (int op = 0; op < 6; op++) {

@ -17,6 +17,8 @@
#ifndef __SYNTH_H #ifndef __SYNTH_H
#define __SYNTH_H #define __SYNTH_H
#include <Arduino.h>
// This IS not be present on MSVC. // This IS not be present on MSVC.
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
#include <stdint.h> #include <stdint.h>
@ -47,6 +49,7 @@ typedef __int16 SInt16;
#define SynthMemoryBarrier() #define SynthMemoryBarrier()
#endif #endif
/*
template<typename T> template<typename T>
inline static T min(const T& a, const T& b) { inline static T min(const T& a, const T& b) {
return a < b ? a : b; return a < b ? a : b;
@ -56,6 +59,7 @@ template<typename T>
inline static T max(const T& a, const T& b) { inline static T max(const T& a, const T& b) {
return a > b ? a : b; return a > b ? a : b;
} }
*/
#define QER(n,b) ( ((float)n)/(1<<b) ) #define QER(n,b) ( ((float)n)/(1<<b) )

Loading…
Cancel
Save