Fixed several small errors and now Dexed is producing sound again.

pull/1/head
Holger Wirtz 8 years ago
parent 35071036e4
commit d02f6f623a
  1. 45
      src/dexed.cpp
  2. 9
      src/dexed.h
  3. 26
      src/msfa/dx7note.cc
  4. 2
      src/msfa/dx7note.h

@ -41,7 +41,7 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
voices[i].live = false; voices[i].live = false;
} }
for(i=0;i<156+4;++i) for(i=0;i<160;++i)
data_float[i]=static_cast<float>(data[i]); data_float[i]=static_cast<float>(data[i]);
currentNote = 0; currentNote = 0;
@ -50,6 +50,7 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
controllers.foot_cc = 0; controllers.foot_cc = 0;
controllers.breath_cc = 0; controllers.breath_cc = 0;
controllers.aftertouch_cc = 0; controllers.aftertouch_cc = 0;
controllers.masterTune=0;
bufsize_=256; bufsize_=256;
@ -70,6 +71,8 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
engineType=0xff; engineType=0xff;
setEngineType(DEXED_ENGINE_MARKI); setEngineType(DEXED_ENGINE_MARKI);
onParam(155,static_cast<float>(0x3f)); // operator on/off => All OPs on
//add_voices(new DexedVoice(rate)); //add_voices(new DexedVoice(rate));
add_audio_outputs(p_audio_out); add_audio_outputs(p_audio_out);
@ -126,6 +129,8 @@ void Dexed::set_params(void)
{ {
//TRACE("Hi"); //TRACE("Hi");
_param_change_counter=0;
bool unisono=bool(*p(p_unisono)); bool unisono=bool(*p(p_unisono));
uint8_t engine=uint8_t(*p(p_engine)); uint8_t engine=uint8_t(*p(p_engine));
float f_gain=*p(p_output); float f_gain=*p(p_output);
@ -313,11 +318,15 @@ void Dexed::set_params(void)
onParam(143,*p(p_pitch_mod_sensitivity)); onParam(143,*p(p_pitch_mod_sensitivity));
onParam(144,*p(p_transpose)); onParam(144,*p(p_transpose));
// 10 bytes (145-154) are the name of the patch // 10 bytes (145-154) are the name of the patch
onParam(155,0x3f); // operator on/off => All OPs on
// Pitch bend // Pitch bend (added at the end of the data[])
controllers.values_[kControllerPitchRange]=static_cast<int16_t>(*p(p_pitch_bend_range)); onParam(156,*p(p_pitch_bend_range));
controllers.values_[kControllerPitchStep]=static_cast<int16_t>(*p(p_pitch_bend_step)); onParam(157,*p(p_pitch_bend_step));
onParam(158,*p(p_mod_wheel_range));
onParam(159,*p(p_mod_wheel_step));
if(_param_change_counter>PARAM_CHANGE_LEVEL)
panic();
//TRACE("Bye"); //TRACE("Bye");
} }
@ -448,19 +457,21 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer)
if(++_param_counter%32) if(++_param_counter%32)
{ {
uint8_t op_out=controllers.core->op_out(data[134]); // look for carriers
for(i=0;i < MAX_ACTIVE_NOTES;i++) for(i=0;i < MAX_ACTIVE_NOTES;i++)
{ {
if(voices[i].live==true) if(voices[i].live==true)
{ {
uint8_t op_amp=0; uint8_t op_amp=0;
uint8_t op_out=controllers.core->op_out(data[134]);
uint8_t op_carrier_num=0; uint8_t op_carrier_num=0;
voices[i].dx7_note->peekVoiceStatus(voiceStatus); voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for(uint8_t op=0;op<6;op++) for(uint8_t op=0;op<6;op++)
{ {
if((op_out&op)==1) TRACE("op=%d op_out=%d 2^op=%d %d",op,op_out,static_cast<uint8_t>(pow(2,op)),op_out&static_cast<uint8_t>(pow(2,op)));
if((op_out&static_cast<uint8_t>(pow(2,op)))>0)
{ {
// this voice is a carrier! // this voice is a carrier!
op_carrier_num++; op_carrier_num++;
@ -663,13 +674,31 @@ void Dexed::onParam(uint8_t param_num,float param_val)
uint8_t tmp=data[param_num]; uint8_t tmp=data[param_num];
#endif #endif
if(param_num==144) _param_change_counter++;
if(param_num==144 || param_num==134)
panic(); panic();
refreshVoice=true; refreshVoice=true;
data[param_num]=static_cast<uint8_t>(param_val); data[param_num]=static_cast<uint8_t>(param_val);
data_float[param_num]=param_val; data_float[param_num]=param_val;
switch(param_num)
{
case 156:
controllers.values_[kControllerPitchRange]=data[param_num];
break;
case 157:
controllers.values_[kControllerPitchStep]=data[param_num];
break;
case 158:
//controllers.values_[kControllerModRange]=data[param_num];
break;
case 159:
//controllers.values_[kControllerModStep]=data[param_num];
break;
}
TRACE("Parameter %d change from %d to %d",param_num, tmp, data[param_num]); TRACE("Parameter %d change from %d to %d",param_num, tmp, data[param_num]);
} }
} }

@ -34,6 +34,8 @@
#include "trace.h" #include "trace.h"
#endif #endif
#define PARAM_CHANGE_LEVEL 10 // when a sound change is recognized
struct ProcessorVoice { struct ProcessorVoice {
uint8_t midi_note; uint8_t midi_note;
bool keydown; bool keydown;
@ -117,9 +119,10 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
private: private:
double _rate; double _rate;
uint8_t _param_counter; uint8_t _param_counter;
float data_float[156+4]; uint8_t _param_change_counter;
//uint8_t data[156]; float data_float[160];
uint8_t data[156+4]={ //uint8_t data[160];
uint8_t data[160]={
95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, 95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14,
95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00,
95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, 95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07,

@ -137,7 +137,7 @@ Dx7Note::Dx7Note() {
} }
//void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity, int fb_depth) { //void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity, int fb_depth) {
void Dx7Note::init(uint8_t patch[156], int midinote, int velocity, int fb_depth) { void Dx7Note::init(const uint8_t patch[160], int midinote, int velocity, int fb_depth) {
int rates[4]; int rates[4];
int levels[4]; int levels[4];
for (int op = 0; op < 6; op++) { for (int op = 0; op < 6; op++) {
@ -190,23 +190,8 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co
int32_t pitch_mod = max(pmod_1, pmod_2); int32_t pitch_mod = max(pmod_1, pmod_2);
pitch_mod = pitchenv_.getsample() + (pitch_mod * (senslfo < 0 ? -1 : 1)); pitch_mod = pitchenv_.getsample() + (pitch_mod * (senslfo < 0 ? -1 : 1));
#ifdef DEBUG /*
// ---- PITCH BEND ---- int pitchbend = ctrls->values_[kControllerPitch];
// hardcodes a pitchbend range of 3 semitones, TODO make configurable
int pitchbend = ctrls->values_[kControllerPitch];
int32_t pb = (pitchbend - 0x2000) << 9;
pitch_mod += pb;
for (int op = 0; op < 6; op++) {
params_[op].level_in = params_[op].gain_out;
int32_t level = env_[op].getsample();
int32_t gain = Exp2::lookup(level - (14 * (1 << 24)));
// int32_t gain = pow(2, 10 + level * (1.0 / (1 << 24)));
params_[op].freq = Freqlut::lookup(basepitch_[op] + pitch_mod);
params_[op].gain_out = gain;
}
#endif
/* int pitchbend = ctrls->values_[kControllerPitch];
int32_t pb = (pitchbend - 0x2000); int32_t pb = (pitchbend - 0x2000);
if (pb != 0) { if (pb != 0) {
if (ctrls->values_[kControllerPitchStep] == 0) { if (ctrls->values_[kControllerPitchStep] == 0) {
@ -218,8 +203,9 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co
} }
} }
pitch_mod += pb; pitch_mod += pb;
pitch_mod += ctrls->masterTune; */ pitch_mod += ctrls->masterTune;
TRACE("pitch_mod=%d pb=%d"); */
//TRACE("pitch_mod=%d pb=%d");
// ==== AMP MOD ==== // ==== AMP MOD ====
uint32_t amod_1 = ((int64_t) ampmoddepth_ * (int64_t) lfo_delay) >> 8; // Q24 :D uint32_t amod_1 = ((int64_t) ampmoddepth_ * (int64_t) lfo_delay) >> 8; // Q24 :D

@ -37,7 +37,7 @@ class Dx7Note {
public: public:
Dx7Note(); Dx7Note();
//void init(const uint8_t patch[156], int midinote, int velocity, int fb_depth); //void init(const uint8_t patch[156], int midinote, int velocity, int fb_depth);
void init(uint8_t patch[156], int midinote, int velocity, int fb_depth); void init(const uint8_t patch[160], int midinote, int velocity, int fb_depth);
// Note: this _adds_ to the buffer. Interesting question whether it's // Note: this _adds_ to the buffer. Interesting question whether it's
// worth it... // worth it...

Loading…
Cancel
Save