Small changes and fixes.

pull/4/head
Holger Wirtz 7 years ago
parent d22840823f
commit 06ffb961e9
  1. 14
      MicroDexed.ino
  2. 29
      config.h
  3. 10
      dexed.cpp
  4. 6
      dexed_sysex.cpp

@ -62,7 +62,7 @@ USBHost usb_host;
MIDIDevice midi_usb(usb_host); MIDIDevice midi_usb(usb_host);
#endif #endif
#ifdef TEST_MIDI #ifdef TEST_NOTE
IntervalTimer sched_note_on; IntervalTimer sched_note_on;
IntervalTimer sched_note_off; IntervalTimer sched_note_off;
uint8_t _voice_counter = 0; uint8_t _voice_counter = 0;
@ -120,7 +120,7 @@ void setup()
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.println(AUDIO_BLOCK_SAMPLES); Serial.println(AUDIO_BLOCK_SAMPLES);
#ifdef TEST_MIDI #ifdef TEST_NOTE
Serial.println(F("MIDI test enabled")); Serial.println(F("MIDI test enabled"));
sched_note_on.begin(note_on, 2000000); sched_note_on.begin(note_on, 2000000);
sched_note_off.begin(note_off, 6333333); sched_note_off.begin(note_off, 6333333);
@ -129,7 +129,7 @@ void setup()
Serial.println(F("setup end")); Serial.println(F("setup end"));
show_cpu_and_mem_usage(); show_cpu_and_mem_usage();
#ifdef TEST_MIDI #ifdef TEST_NOTE
//dexed->data[DEXED_VOICE_OFFSET+DEXED_LFO_PITCH_MOD_DEP] = 99; // full pitch mod depth //dexed->data[DEXED_VOICE_OFFSET+DEXED_LFO_PITCH_MOD_DEP] = 99; // full pitch mod depth
//dexed->data[DEXED_VOICE_OFFSET+DEXED_LFO_PITCH_MOD_SENS] = 99; // full pitch mod sense //dexed->data[DEXED_VOICE_OFFSET+DEXED_LFO_PITCH_MOD_SENS] = 99; // full pitch mod sense
//dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET+DEXED_MODWHEEL_ASSIGN] = 7; // mod wheel assign all //dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET+DEXED_MODWHEEL_ASSIGN] = 7; // mod wheel assign all
@ -202,7 +202,7 @@ void handle_midi_input(void)
} }
} }
#ifdef TEST_MIDI #ifdef TEST_NOTE
void note_on(void) void note_on(void)
{ {
randomSeed(analogRead(A0)); randomSeed(analogRead(A0));
@ -254,13 +254,13 @@ void note_off(void)
#ifdef SHOW_MIDI_EVENT #ifdef SHOW_MIDI_EVENT
void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2)
{ {
Serial.print("MIDI event type: 0x"); Serial.print(F("MIDI event type: 0x"));
if (type < 16) if (type < 16)
Serial.print(F("0")); Serial.print(F("0"));
Serial.print(type, HEX); Serial.print(type, HEX);
Serial.print(" data1: "); Serial.print(F(" data1: "));
Serial.print(data1, DEC); Serial.print(data1, DEC);
Serial.print(" data2: "); Serial.print(F(" data2: "));
Serial.println(data2, DEC); Serial.println(data2, DEC);
} }
#endif #endif

@ -21,36 +21,41 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "midinotes.h"
//#define TEST_MIDI 1 #include "midinotes.h"
#define TEST_NOTE MIDI_E2
#define TEST_VEL_MIN 60
#define TEST_VEL_MAX 110
//#define SHOW_DEXED_TIMING 1 // Initial values
#define DEBUG 1
#define SERIAL_SPEED 38400
#define VOLUME 0.1 #define VOLUME 0.1
#define SAMPLE_RATE 44100 #define SAMPLE_RATE 44100
//#define DEXED_ENGINE DEXED_ENGINE_MODERN //#define DEXED_ENGINE DEXED_ENGINE_MODERN
#define USE_ONBOARD_USB_HOST 1 #define USE_ONBOARD_USB_HOST 1
#define SHOW_MIDI_EVENT 1
#define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000
#define MAX_NOTES 16 #define MAX_NOTES 16
#define AUDIO_MEM 2 #define AUDIO_MEM 2
#define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXBANK 0
#define DEFAULT_SYSEXSOUND 0 #define DEFAULT_SYSEXSOUND 0
// Master key handling (comment out for disabling)
#define MASTER_KEY_MIDI MIDI_C6 #define MASTER_KEY_MIDI MIDI_C6
#define MASTER_NUM1 MIDI_C1 #define MASTER_NUM1 MIDI_C1
// Debug output
#define SERIAL_SPEED 38400
//#define SHOW_DEXED_TIMING 1
#define DEBUG 1
#define SHOW_MIDI_EVENT 1
#define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000
// Some optimizations in the code
#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
// Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard
//#define TEST_NOTE MIDI_E2
#define TEST_VEL_MIN 60
#define TEST_VEL_MAX 110
// Use these with the Teensy Audio Shield // Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10 #define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7 #define SDCARD_MOSI_PIN 7

@ -158,20 +158,18 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
#else #else
int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9;
#endif #endif
if (clip_val != (val>>9))
overload++;
#ifdef SUM_UP_AS_INT #ifdef SUM_UP_AS_INT
sum = buffer[i + j] + (clip_val >> REDUCE_LOUDNESS); sum = buffer[i + j] + (clip_val >> REDUCE_LOUDNESS);
/*
if (buffer[i + j] > 0 && clip_val > 0 && sum < 0) if (buffer[i + j] > 0 && clip_val > 0 && sum < 0)
{ {
sum = 0x8000; sum = INT_MAX;
overload++;
} }
else if (buffer[i + j] < 0 && clip_val < 0 && sum > 0) else if (buffer[i + j] < 0 && clip_val < 0 && sum > 0)
{ {
sum = 0x7FFF; sum = INT_MIN;
overload++;
} }
*/
buffer[i + j] = sum; buffer[i + j] = sum;
audiobuf.get()[j] = 0; audiobuf.get()[j] = 0;
#else #else

@ -70,11 +70,11 @@ bool load_sysex(uint8_t bank, uint8_t voice_number)
{ {
char n[11]; char n[11];
strncpy(n, (char*)&data[118], 10); strncpy(n, (char*)&data[118], 10);
Serial.print("<"); Serial.print(F("<"));
Serial.print(entry.name()); Serial.print(entry.name());
Serial.print("|'"); Serial.print(F("|'"));
Serial.print(n); Serial.print(n);
Serial.println("'>"); Serial.println(F("'>"));
return (dexed->loadSysexVoice(data)); return (dexed->loadSysexVoice(data));
} }
else else

Loading…
Cancel
Save