Trying to fix stopping of unheard notes.

pull/41/head
Holger Wirtz 3 years ago
parent 6fdce7fad2
commit bae8dbe1c9
  1. 12
      MicroDexed.ino
  2. 4
      config.h
  3. 4
      controllers.h
  4. 58
      dexed.cpp
  5. 5
      dexed.h
  6. 41
      fm_core.cpp
  7. 2
      source_microdexed.h

@ -175,7 +175,7 @@ AudioConnection * dynamicConnections[NUM_DEXED * 4];
#endif
void create_audio_engine_chain(uint8_t instance_id)
{
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE);
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE, instance_id);
mono2stereo[instance_id] = new AudioEffectMonoStereo();
#if defined(USE_FX)
chorus_modulator[instance_id] = new AudioSynthWaveform();
@ -2458,6 +2458,7 @@ void SerialPrintFormatInt3(uint8_t num)
Serial.print(buf);
}
#ifdef TEENSY3_6
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */
extern "C" char* sbrk(int incr);
uint32_t FreeMem(void)
@ -2465,6 +2466,15 @@ uint32_t FreeMem(void)
char top;
return &top - reinterpret_cast<char*>(sbrk(0));
}
#else
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */
extern unsigned long _heap_end;
extern char *__brkval;
int FreeMem(void)
{
return (char *)&_heap_end - __brkval;
}
#endif
/*
uint32_t FreeMem(void) { // for Teensy 3.0
uint32_t stackTop;

@ -59,7 +59,7 @@
// sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy4/usb_midi.h
//#define USB_MIDI_SYSEX_MAX 4104
#define VERSION "1.0.17"
#define VERSION "1.0.18"
//*************************************************************************************************
//* DEVICE SETTINGS
@ -335,7 +335,7 @@
#define TRANSPOSE_FIX 24
//#define VOICE_SILENCE_LEVEL 1069
#define VOICE_SILENCE_LEVEL 4000
#define VOICE_SILENCE_LEVEL 1100
// Audio
#ifdef TGA_AUDIO_BOARD

@ -52,12 +52,12 @@ class FmMod {
void setRange(uint8_t r)
{
range = r < 0 && r > 99 ? 0 : r;
range = r < 0 || r > 99 ? 0 : r;
}
void setTarget(uint8_t assign)
{
assign = assign < 0 && assign > 7 ? 0 : assign;
assign = assign < 0 || assign > 7 ? 0 : assign;
pitch = assign & 1; // PITCH
amp = assign & 2; // AMP
eg = assign & 4; // EG

@ -43,7 +43,7 @@
extern config_t configuration;
Dexed::Dexed(int rate)
Dexed::Dexed(uint16_t rate, uint8_t instance_id)
{
uint8_t i;
@ -89,6 +89,8 @@ Dexed::Dexed(int rate)
sustain = false;
setEngineType(DEXED_ENGINE);
id = instance_id;
}
Dexed::~Dexed()
@ -265,6 +267,12 @@ void Dexed::keydown(int16_t pitch, uint8_t velo) {
voices[note].dx7_note->oscSync();
voices[i].key_pressed_timer = millis();
keydown_counter++;
#ifdef DEBUG
Serial.print(F("Start voice: "));
Serial.print(note, DEC);
Serial.print(F(" pitch: "));
Serial.println(pitch, DEC);
#endif
break;
}
else
@ -309,13 +317,24 @@ void Dexed::keyup(int16_t pitch) {
if ( voices[note].midi_note == pitch && voices[note].keydown ) {
voices[note].keydown = false;
voices[note].key_pressed_timer = 0;
#ifdef DEBUG
Serial.print(F("Stop voice: "));
Serial.print(note, DEC);
Serial.print(F(" pitch: "));
Serial.println(pitch, DEC);
Serial.print(F(" id: "));
Serial.println(id, DEC);
#endif
break;
}
}
// note not found ?
if ( note >= max_notes ) {
#ifdef DEBUG
Serial.print(F("Note not found: "));
Serial.println(pitch, DEC);
#endif
return;
}
@ -472,6 +491,7 @@ uint8_t Dexed::getNumNotesPlaying(void)
uint8_t op_carrier = controllers.core->get_carrier_operators(data[134]); // look for carriers
uint8_t i;
uint8_t count_playing_voices = 0;
VoiceStatus voiceStatus;
for (i = 0; i < max_notes; i++)
{
@ -483,13 +503,29 @@ uint8_t Dexed::getNumNotesPlaying(void)
memset(&voiceStatus, 0, sizeof(VoiceStatus));
voices[i].dx7_note->peekVoiceStatus(voiceStatus);
#ifdef DEBUG
Serial.println(i);
Serial.print("ALG: ");
Serial.println(data[134]+1);
#endif
for (uint8_t op = 0; op < 6; op++)
{
if ((op_carrier & (1 << op)))
{
// this voice is a carrier!
op_carrier_num++;
if (voiceStatus.amp[op] <= VOICE_SILENCE_LEVEL && voiceStatus.ampStep[op] == 4)
#ifdef DEBUG
Serial.print("OP: ");
Serial.print(op);
Serial.print(" AMP_STEP: ");
Serial.print(voiceStatus.ampStep[op],DEC);
Serial.print(" AMP: ");
Serial.println(voiceStatus.amp[op],DEC);
#endif
if (voiceStatus.amp[op] < VOICE_SILENCE_LEVEL && voiceStatus.ampStep[op] >= 3)
{
// this voice produces no audio output
op_amp++;
@ -497,6 +533,22 @@ uint8_t Dexed::getNumNotesPlaying(void)
}
}
/*
Serial.print(F("ID="));
Serial.print(id, DEC);
Serial.print(F(" OP carrier="));
Serial.print(op_carrier_num, DEC);
Serial.print(F(" OP amp="));
Serial.println(op_amp, DEC);
*/
#ifdef DEBUG
Serial.print("OP_AMP: ");
Serial.print(op_amp);
Serial.print(" OP_CARRIER_NUM: ");
Serial.println(op_carrier_num);
#endif
if (op_amp == op_carrier_num)
{
// all carrier-operators are silent -> disable the voice

@ -141,7 +141,7 @@ enum DexedVoiceParameters {
class Dexed
{
public:
Dexed(int rate);
Dexed(uint16_t rate, uint8_t id);
~Dexed();
void activate(void);
void deactivate(void);
@ -202,6 +202,7 @@ class Dexed
protected:
//static const uint8_t MAX_ACTIVE_NOTES = MAX_NOTES;
//uint8_t max_notes = MAX_ACTIVE_NOTES;
uint8_t id;
uint8_t max_notes = 0;
int16_t currentNote;
bool sustain;
@ -210,7 +211,7 @@ class Dexed
bool refreshMode;
bool refreshVoice;
uint8_t engineType;
VoiceStatus voiceStatus;
//VoiceStatus voiceStatus;
Lfo lfo;
FmCore* engineMsfa;
EngineMkI* engineMkI;

@ -76,31 +76,40 @@ uint8_t FmCore::get_carrier_operators(uint8_t algorithm)
for (uint8_t i = 0; i < 6; i++)
{
if ((alg.ops[i]&OUT_BUS_ADD) == OUT_BUS_ADD)
if ((alg.ops[i] & 7) == OUT_BUS_ADD)
op_out |= 1 << i;
}
return op_out;
}
void FmCore::dump() {
#ifdef VERBOSE
for (int i = 0; i < 32; i++) {
cout << (i + 1) << ":";
void FmCore::dump(void)
{
#ifdef DEBUG
for (uint8_t i = 0; i < 32; i++)
{
Serial.print(i + 1);
Serial.print(":");
const FmAlgorithm &alg = algorithms[i];
for (int j = 0; j < 6; j++) {
int flags = alg.ops[j];
cout << " ";
if (flags & FB_IN) cout << "[";
cout << (flags & IN_BUS_ONE ? "1" : flags & IN_BUS_TWO ? "2" : "0") << "->";
cout << (flags & OUT_BUS_ONE ? "1" : flags & OUT_BUS_TWO ? "2" : "0");
if (flags & OUT_BUS_ADD) cout << "+";
//cout << alg.ops[j].in << "->" << alg.ops[j].out;
if (flags & FB_OUT) cout << "]";
for (uint8_t j = 0; j < 6; j++)
{
uint8_t flags = alg.ops[j];
Serial.print(" ");
if (flags & FB_IN)
Serial.print("[");
Serial.print(flags & IN_BUS_ONE ? "1" : flags & IN_BUS_TWO ? "2" : "0");
Serial.print("->");
Serial.print(flags & OUT_BUS_ONE ? "1" : flags & OUT_BUS_TWO ? "2" : "0");
if (flags & OUT_BUS_ADD)
Serial.print("+");
if (flags & FB_OUT)
Serial.print("]");
}
cout << " " << n_out(alg);
cout << endl;
Serial.print(" ");
Serial.println(n_out(alg));
}
#else
;
#endif
}

@ -10,7 +10,7 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed {
uint32_t xrun = 0;
uint16_t render_time_max = 0;
AudioSourceMicroDexed(int sample_rate) : AudioStream(0, NULL), Dexed(sample_rate) { };
AudioSourceMicroDexed(uint16_t sample_rate, uint8_t id) : AudioStream(0, NULL), Dexed(sample_rate,id) { };
void update(void)
{

Loading…
Cancel
Save