Removed freeverb and mixer due to latency problems.

Replaced mixer with amp.
Showing maximum timing for the last n secs when showing CPU usage.
pull/4/head
Holger Wirtz 6 years ago
parent 54252dd92d
commit d2052dc28f
  1. 44
      MicroDexed.ino
  2. 9
      config.h
  3. 16
      dexed.cpp
  4. 4
      dexed_sysex.cpp

@ -51,27 +51,25 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
#endif #endif
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=637,396 AudioPlayQueue queue1; //xy=708,349
AudioEffectFreeverbStereo freeverbs1; //xy=815,506 AudioAmplifier amp1; //xy=904,314
AudioMixer4 mixer2; //xy=1014,461 AudioAmplifier amp2; //xy=909,373
AudioMixer4 mixer1; //xy=1016,376 AudioOutputI2S i2s1; //xy=1055,343
AudioOutputI2S i2s1; //xy=1214,414 AudioConnection patchCord1(queue1, amp1);
AudioConnection patchCord1(queue1, freeverbs1); AudioConnection patchCord2(queue1, amp2);
AudioConnection patchCord2(queue1, 0, mixer1, 0); AudioConnection patchCord3(amp1, 0, i2s1, 0);
AudioConnection patchCord3(queue1, 0, mixer2, 0); AudioConnection patchCord4(amp2, 0, i2s1, 1);
AudioConnection patchCord4(freeverbs1, 0, mixer1, 1); AudioControlSGTL5000 sgtl5000_1; //xy=1055,398
AudioConnection patchCord5(freeverbs1, 1, mixer2, 1);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
AudioConnection patchCord7(mixer1, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=1214,469
// GUItool: end automatically generated code // GUItool: end automatically generated code
Dexed* dexed = new Dexed(SAMPLE_RATE); Dexed* dexed = new Dexed(SAMPLE_RATE);
bool sd_card_available = false; bool sd_card_available = false;
uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR); uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR);
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; uint8_t midi_channel = DEFAULT_MIDI_CHANNEL;
uint32_t xrun = 0; uint32_t xrun = 0;
uint32_t overload = 0; uint32_t overload = 0;
uint16_t render_time_max = 0;
#ifdef MASTER_KEY_MIDI #ifdef MASTER_KEY_MIDI
bool master_key_enabled = false; bool master_key_enabled = false;
@ -133,16 +131,8 @@ void setup()
AudioMemory(AUDIO_MEM); AudioMemory(AUDIO_MEM);
sgtl5000_1.enable(); sgtl5000_1.enable();
sgtl5000_1.volume(VOLUME); sgtl5000_1.volume(VOLUME);
amp1.gain(1.0); // normal audio
// configure mixer amp2.gain(1.0); // normal audio
mixer1.gain(0,1.0); // normal audio
mixer2.gain(0,0.2); // reverb audio
mixer1.gain(0,1.0); // normal audio
mixer2.gain(0,0.2); // reverb audio
// configure reverb
freeverbs1.roomsize(DEFAULT_REVERB_ROOMSIZE);
freeverbs1.damping(DEFAULT_REVERB_DAMPING);
// start SD card // start SD card
SPI.setMOSI(SDCARD_MOSI_PIN); SPI.setMOSI(SDCARD_MOSI_PIN);
@ -230,9 +220,8 @@ void loop()
uint32_t t2 = t1; uint32_t t2 = t1;
if (t2 > 2900) // everything greater 2.9ms is a buffer underrun! if (t2 > 2900) // everything greater 2.9ms is a buffer underrun!
xrun++; xrun++;
#ifdef SHOW_DEXED_TIMING if (t2 > render_time_max)
Serial.println(t1, DEC); render_time_max = t2;
#endif
queue1.playBuffer(); queue1.playBuffer();
} }
} }
@ -607,6 +596,8 @@ void show_cpu_and_mem_usage(void)
Serial.print(AudioMemoryUsage(), DEC); Serial.print(AudioMemoryUsage(), DEC);
Serial.print(F(" MEM MAX: ")); Serial.print(F(" MEM MAX: "));
Serial.print(AudioMemoryUsageMax(), DEC); Serial.print(AudioMemoryUsageMax(), DEC);
Serial.print(F(" RENDER_TIME_MAX: "));
Serial.print(render_time_max, DEC);
Serial.print(F(" XRUN: ")); Serial.print(F(" XRUN: "));
Serial.print(xrun, DEC); Serial.print(xrun, DEC);
Serial.print(F(" OVERLOAD: ")); Serial.print(F(" OVERLOAD: "));
@ -614,6 +605,7 @@ void show_cpu_and_mem_usage(void)
Serial.println(); Serial.println();
AudioProcessorUsageMaxReset(); AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset(); AudioMemoryUsageMaxReset();
render_time_max=0;
} }
#endif #endif

@ -28,14 +28,12 @@
#define MIDI_DEVICE Serial1 #define MIDI_DEVICE Serial1
#define USE_ONBOARD_USB_HOST 1 #define USE_ONBOARD_USB_HOST 1
#define VOLUME 0.8 #define VOLUME 0.8
#define SAMPLE_RATE 44100
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
#define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXBANK 0
#define DEFAULT_SYSEXSOUND 0 #define DEFAULT_SYSEXSOUND 0
#define DEFAULT_REVERB_ROOMSIZE 0.5
#define DEFAULT_REVERB_DAMPING 0.5
//#define DEXED_ENGINE DEXED_ENGINE_MODERN //#define DEXED_ENGINE DEXED_ENGINE_MODERN
#define AUDIO_MEM 32 #define AUDIO_MEM 2
#define SAMPLE_RATE 44100
#if !defined(__MK66FX1M0__) // check for Teensy-3.6 #if !defined(__MK66FX1M0__) // check for Teensy-3.6
#define MAX_NOTES 11 // No? #define MAX_NOTES 11 // No?
@ -49,13 +47,12 @@
// Debug output // Debug output
#define SERIAL_SPEED 38400 #define SERIAL_SPEED 38400
//#define SHOW_DEXED_TIMING 1
#define DEBUG 1 #define DEBUG 1
#define SHOW_MIDI_EVENT 1 #define SHOW_MIDI_EVENT 1
#define SHOW_XRUN 1 #define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000 #define SHOW_CPU_LOAD_MSEC 5000
// Some optimizations in the code // Some optimizations
#define USE_TEENSY_DSP 1 #define USE_TEENSY_DSP 1
#define SUM_UP_AS_INT 1 #define SUM_UP_AS_INT 1
#define REDUCE_LOUDNESS 2 #define REDUCE_LOUDNESS 2

@ -45,8 +45,8 @@ extern AudioControlSGTL5000 sgtl5000_1;
extern AudioAmplifier amp1; extern AudioAmplifier amp1;
extern AudioAmplifier amp2; extern AudioAmplifier amp2;
extern AudioEffectFreeverbStereo freeverbs1; extern AudioEffectFreeverbStereo freeverbs1;
extern AudioMixer4 mixer2; extern AudioAmplifier amp1;
extern AudioMixer4 mixer1; extern AudioAmplifier amp2;
Dexed::Dexed(int rate) Dexed::Dexed(int rate)
{ {
@ -240,18 +240,18 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)
case 10: // Pan case 10: // Pan
if (value < 64) if (value < 64)
{ {
mixer1.gain(0, 1.0); amp1.gain(1.0);
mixer2.gain(0, float(value) / 0x40); amp2.gain(float(value) / 0x40);
} }
else if (value > 64) else if (value > 64)
{ {
mixer1.gain(0, float(0x7f - value) / 0x40); amp1.gain(float(0x7f - value) / 0x40);
mixer2.gain(0, 1.0); amp2.gain(1.0);
} }
else else
{ {
mixer1.gain(0, 1.0); amp1.gain(1.0);
mixer2.gain(0, 1.0); amp2.gain(1.0);
} }
break; break;
case 32: // BankSelect LSB case 32: // BankSelect LSB

@ -30,6 +30,8 @@
#include "dexed_sysex.h" #include "dexed_sysex.h"
#include "config.h" #include "config.h"
extern uint16_t render_time_max;
bool load_sysex(uint8_t bank, uint8_t voice_number) bool load_sysex(uint8_t bank, uint8_t voice_number)
{ {
File root; File root;
@ -194,5 +196,7 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data)
} }
#endif #endif
render_time_max=0;
return (true); return (true);
} }

Loading…
Cancel
Save