Fixed MIDI test notes.

Added Teensy optimized 32bit DSP saturation code.
pull/4/head
Holger Wirtz 7 years ago
parent 16beb6b362
commit 0d26a425eb
  1. 11
      MicroDexed.ino
  2. 6
      config.h
  3. 7
      dexed.cpp

@ -221,7 +221,7 @@ void note_on(void)
queue_midi_event(0x90, TEST_NOTE + 32, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 9 queue_midi_event(0x90, TEST_NOTE + 32, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 9
queue_midi_event(0x90, TEST_NOTE + 37, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 10 queue_midi_event(0x90, TEST_NOTE + 37, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 10
queue_midi_event(0x90, TEST_NOTE + 40, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 11 queue_midi_event(0x90, TEST_NOTE + 40, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 11
queue_midi_event(0x90, TEST_NOTE + 44, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 12 queue_midi_event(0x90, TEST_NOTE + 46, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 12
queue_midi_event(0x90, TEST_NOTE + 49, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 13 queue_midi_event(0x90, TEST_NOTE + 49, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 13
queue_midi_event(0x90, TEST_NOTE + 52, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 14 queue_midi_event(0x90, TEST_NOTE + 52, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 14
queue_midi_event(0x90, TEST_NOTE + 57, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 15 queue_midi_event(0x90, TEST_NOTE + 57, random(TEST_VEL_MIN, TEST_VEL_MAX)); // 15
@ -241,18 +241,13 @@ void note_off(void)
queue_midi_event(0x80, TEST_NOTE + 32, 0); // 9 queue_midi_event(0x80, TEST_NOTE + 32, 0); // 9
queue_midi_event(0x80, TEST_NOTE + 37, 0); // 10 queue_midi_event(0x80, TEST_NOTE + 37, 0); // 10
queue_midi_event(0x80, TEST_NOTE + 40, 0); // 11 queue_midi_event(0x80, TEST_NOTE + 40, 0); // 11
queue_midi_event(0x80, TEST_NOTE + 44, 0); // 12 queue_midi_event(0x80, TEST_NOTE + 46, 0); // 12
queue_midi_event(0x80, TEST_NOTE + 49, 0); // 13 queue_midi_event(0x80, TEST_NOTE + 49, 0); // 13
queue_midi_event(0x80, TEST_NOTE + 52, 0); // 14 queue_midi_event(0x80, TEST_NOTE + 52, 0); // 14
queue_midi_event(0x80, TEST_NOTE + 57, 0); // 15 queue_midi_event(0x80, TEST_NOTE + 57, 0); // 15
queue_midi_event(0x80, TEST_NOTE + 60, 0); // 16 queue_midi_event(0x80, TEST_NOTE + 60, 0); // 16
//bool success=true; bool success = load_sysex(DEFAULT_SYSEXBANK, (++_voice_counter) - 1);
//bool success = load_sysex("ROM1A.SYX", (++_voice_counter)-1);
//bool success=load_sysex("ROM1B.SYX", (++_voice_counter)-1);
//bool success=load_sysex("RITCH01-32.SYX", (++_voice_counter)-1);
//bool success=load_sysex("RITCH33-64.SYX", (++_voice_counter)-1);
bool success = load_sysex(DEFAULT_SYSEXFILE, (++_voice_counter) - 1);
if (success == false) if (success == false)
Serial.println(F("E: Cannot load SYSEX data")); Serial.println(F("E: Cannot load SYSEX data"));
else else

@ -31,8 +31,8 @@
#define SERIAL_SPEED 38400 #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_DEXED_TIMING 1 //#define SHOW_DEXED_TIMING 1
#define SHOW_MIDI_EVENT 1 #define SHOW_MIDI_EVENT 1
#define SHOW_XRUN 1 #define SHOW_XRUN 1
@ -47,6 +47,8 @@
#define MASTER_NUM1 24 // C1 #define MASTER_NUM1 24 // C1
#define MASTER_BANK_SELECT 83 // B5 #define MASTER_BANK_SELECT 83 // B5
#define USE_TEENSY_DSP 1
// 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

@ -34,6 +34,9 @@
#include "controllers.h" #include "controllers.h"
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#ifdef USE_TEENSY_DSP
#include <Audio.h>
#endif
extern uint8_t bank; extern uint8_t bank;
extern bool load_sysex(uint8_t bank, uint8_t voice_number); extern bool load_sysex(uint8_t bank, uint8_t voice_number);
@ -140,7 +143,11 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
for (uint8_t j = 0; j < _N_; ++j) { for (uint8_t j = 0; j < _N_; ++j) {
int32_t val = audiobuf.get()[j]; int32_t val = audiobuf.get()[j];
val = val >> 4; val = val >> 4;
#ifdef USE_TEENSY_DSP
int32_t clip_val=signed_saturate_rshift(32,24,9);
#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
float f = static_cast<float>(clip_val >> 1) / 0x8000; float f = static_cast<float>(clip_val >> 1) / 0x8000;
if (f > 1) f = 1; if (f > 1) f = 1;
if (f < -1) f = -1; if (f < -1) f = -1;

Loading…
Cancel
Save