From e3c0a2dae2f3cb88285c0738fed9e46742bb1195 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Feb 2017 09:14:16 +0100 Subject: [PATCH] There was a bigger problem with a SEGV which I can't fix. So I decided to got back to a1f53457f89d60c0f022e98b40e2ee85b3ee004e and start again with implementing the feature of configuring in realtime how much voices (1..32) you may want to use. Also made some cleanup. --- src/Makefile | 2 +- src/dexed.cpp | 43 +++++++++++++++++++++++++------------------ src/dexed.h | 6 +++--- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9529d76..86ead0e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ BUNDLE=dexed.lv2 TARGET=dexed.so -DEBUG=1 +#DEBUG=1 #FILETRACE=1 INSTALL_DIR=/zynthian/zynthian-plugins/lv2 diff --git a/src/dexed.cpp b/src/dexed.cpp index 7ec3cfb..22a8225 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -65,8 +65,8 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) TRACE("%d->%f",i,data_float[i]); } - currentNote = 0; max_notes=16; + currentNote = 0; controllers.values_[kControllerPitch] = 0x2000; controllers.values_[kControllerPitchRange] = 0; controllers.values_[kControllerPitchStep] = 0; @@ -83,7 +83,7 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) lfo.reset(data+137); - normalizeDxVelocity = false; + //normalizeDxVelocity = false; setMonoMode(false); @@ -419,8 +419,9 @@ void Dexed::run (uint32_t sample_count) void Dexed::GetSamples(uint32_t n_samples, float* buffer) { uint32_t i; + if(refreshVoice) { - for(i=0;i < MAX_ACTIVE_NOTES;i++) { + for(i=0;i < max_notes;i++) { if ( voices[i].live ) voices[i].dx7_note->update(data, voices[i].midi_note, feedback_bitdepth); } @@ -454,7 +455,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) int32_t lfovalue = lfo.getsample(); int32_t lfodelay = lfo.getdelay(); - for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) { + for (uint8_t note = 0; note < max_notes; ++note) { if (voices[note].live) { voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers); for (uint32_t j=0; j < N; ++j) { @@ -487,7 +488,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) { uint8_t op_carrier=controllers.core->get_carrier_operators(data[134]); // look for carriers - for(i=0;i < MAX_ACTIVE_NOTES;i++) + for(i=0;i < max_notes;i++) { if(voices[i].live==true) { @@ -565,7 +566,7 @@ void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) { TRACE("MIDI sustain event: %d %d",ctrl,value); sustain = value > 63; if (!sustain) { - for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; note++) { + for (uint8_t note = 0; note < max_notes; note++) { if (voices[note].sustained && !voices[note].keydown) { voices[note].dx7_note->keyup(); voices[note].sustained = false; @@ -619,9 +620,9 @@ TRACE("pitch=%d, velo=%d\n",pitch,velo); uint8_t note = currentNote; uint8_t keydown_counter=0; - for (uint8_t i=0; i= MAX_ACTIVE_NOTES ) { + if ( note >= max_notes ) { TRACE("note-off not found???"); return; } @@ -683,7 +685,7 @@ TRACE("pitch=%d\n",pitch); if ( monoMode ) { int8_t highNote = -1; int8_t target = 0; - for (int8_t i=0; i highNote ) { target = i; highNote = voices[i].midi_note; @@ -707,6 +709,7 @@ TRACE("Bye"); void Dexed::onParam(uint8_t param_num,float param_val) { + int32_t tune; if(param_val!=data_float[param_num]) { @@ -756,6 +759,10 @@ void Dexed::onParam(uint8_t param_num,float param_val) case 164: controllers.at.setTarget(data[param_num]); break; + case 165: + tune=param_val*0x4000; + controllers.masterTune=(tune<<11)*(1.0/12); + break; case 166: case 167: case 168: @@ -764,10 +771,9 @@ void Dexed::onParam(uint8_t param_num,float param_val) case 171: controllers.opSwitch=(data[166]<<5)|(data[167]<<4)|(data[168]<<3)|(data[169]<<2)|(data[170]<<1)|data[171]; break; - case 165: - int32_t tune=param_val*0x4000; - controllers.masterTune=(tune<<11)*(1.0/12); - break; + case 172: + max_notes=data[param_num]; + break; } TRACE("Done: Parameter %d changed from %d to %d",param_num, tmp, data[param_num]); @@ -820,6 +826,7 @@ void Dexed::panic(void) { for(uint8_t i=0;ioscSync(); } diff --git a/src/dexed.h b/src/dexed.h index dff38ec..8a12249 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -97,14 +97,14 @@ class Dexed : public lvtk::Synth void keydown(uint8_t pitch, uint8_t velo); void panic(void); - static const uint8_t MAX_ACTIVE_NOTES = 16; + static const uint8_t MAX_ACTIVE_NOTES = 32; + uint8_t max_notes=MAX_ACTIVE_NOTES; ProcessorVoice voices[MAX_ACTIVE_NOTES]; - uint8_t max_notes; uint8_t currentNote; bool sustain; bool monoMode; bool refreshVoice; - bool normalizeDxVelocity; + //bool normalizeDxVelocity; uint8_t engineType; uint8_t feedback_bitdepth; PluginFx fx;