diff --git a/dexed.mh b/dexed.mh deleted file mode 100644 index 7111787..0000000 --- a/dexed.mh +++ /dev/null @@ -1,12 +0,0 @@ -add https://github.com/dcoredump/dexed 0 -add http://gareus.org/oss/lv2/stepseq#s4n4 1 -add http://ll-plugins.nongnu.org/lv2/lv2pftci/beep2 2 -connect ttymidi:MIDI_in effect_0:lv2_events_in -connect effect_1:midiout effect_0:lv2_events_in -connect effect_1:midiout effect_2:midi -connect effect_0:lv2_audio_out_1 system:playback_1 -connect effect_0:lv2_audio_out_1 system:playback_2 -connect effect_2:right system:playback_1 -connect effect_2:left system:playback_2 -param_set 1 grid_1_1 1 -param_set 1 grid_2_3 1 diff --git a/src/Dexed.ttl b/src/Dexed.ttl index f50875e..4bbf1d3 100644 --- a/src/Dexed.ttl +++ b/src/Dexed.ttl @@ -62,8 +62,8 @@ lv2:symbol "algorithm_num" ; lv2:name "ALGORITHM" ; lv2:default 5 ; - lv2:minimum 1 ; - lv2:maximum 32 ; + lv2:minimum 0 ; + lv2:maximum 31 ; lv2:portProperty lv2:integer ; ] , [ diff --git a/src/dexed.cpp b/src/dexed.cpp index 075a532..f0fb5fb 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -19,7 +19,8 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) TRACE("Hi"); bufsize_=256; - outbuf16_=new int16_t[bufsize_]; + //outbuf_=new int16_t[bufsize_]; + outbuf_=new float[bufsize_]; Exp2::init(); Tanh::init(); @@ -69,7 +70,7 @@ Dexed::~Dexed() { TRACE("Hi"); - delete [] outbuf16_; + delete [] outbuf_; currentNote = -1; @@ -282,14 +283,14 @@ void Dexed::run (uint32_t sample_count) } // render audio from the last frame until the timestamp of this event - GetSamples (num_this_time, outbuf16_); + GetSamples (num_this_time, outbuf_); // i is the index of the engine's buf, which always starts at 0 (i think) // j is the index of the plugin's float output buffer which will be the timestamp // of the last processed atom event. for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j) - //output[j] = (static_cast (outbuf16_[i])) * *p(p_output); - output[j] = (static_cast (outbuf16_[i])); + //output[j] = (static_cast (outbuf_[i])) * *p(p_output); + output[j]=outbuf_[i]; last_frame = ev->time.frames; } @@ -302,16 +303,16 @@ void Dexed::run (uint32_t sample_count) // already been handled. num_this_time = sample_count - last_frame; - GetSamples (num_this_time, outbuf16_); + GetSamples (num_this_time, outbuf_); for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j) - //output[j] = (static_cast (outbuf16_[i])) * *p(p_output); - output[j] = (static_cast (outbuf16_[i])); + //output[j] = (static_cast (outbuf_[i])) * *p(p_output); + output[j] = outbuf_[i]; } fx.process(output, sample_count); } -void Dexed::GetSamples(int n_samples, int16_t *buffer) +void Dexed::GetSamples(int n_samples, float *buffer) { size_t input_offset; @@ -329,6 +330,7 @@ void Dexed::GetSamples(int n_samples, int16_t *buffer) int i; if ( refreshVoice ) { for(i=0;i < MAX_ACTIVE_NOTES;i++) { + TRACE("Voice[%d] live=%d keydown=%d",i,voices[i].live,voices[i].keydown); if ( voices[i].live ) voices[i].dx7_note->update(data, voices[i].midi_note, feedback_bitdepth); } @@ -352,11 +354,11 @@ void Dexed::GetSamples(int n_samples, int16_t *buffer) { for (; i < n_samples; i += N) { AlignedBuf audiobuf; - int16_t sumbuf[N]; + float sumbuf[N]; for (int j = 0; j < N; ++j) { audiobuf.get()[j] = 0; - sumbuf[j] = 0; + sumbuf[j] = 0.0; } int32_t lfovalue = lfo.getsample(); @@ -370,8 +372,13 @@ void Dexed::GetSamples(int n_samples, int16_t *buffer) val = val >> 4; int clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; - sumbuf[j] += clip_val; - audiobuf.get()[j] = 0; + float f = ((float) clip_val) / (float) 0x8000; + if(f>1.0) + f=1.0; + if(f<-1.0) + f=-1.0; + sumbuf[j]+=f; + audiobuf.get()[j]=0; } } } diff --git a/src/dexed.h b/src/dexed.h index 81942f9..e64d0dc 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -83,7 +83,7 @@ class Dexed : public lvtk::Synth void setEngineType(int rs); void setMonoMode(bool mode); void set_params(void); - void GetSamples(int n_samples, int16_t *buffer); + void GetSamples(int n_samples, float *buffer); //bool isMonoMode(); //void setMonoMode(bool mode); @@ -115,7 +115,8 @@ class Dexed : public lvtk::Synth EngineMkI engineMkI; EngineOpl engineOpl; RingBuffer ring_buffer_; - int16_t* outbuf16_; + //int16_t* outbuf16_; + float* outbuf_; uint32_t bufsize_; int16_t extra_buf_[N]; int extra_buf_size_; diff --git a/src/dexed.mh b/src/dexed.mh new file mode 100644 index 0000000..4a6c644 --- /dev/null +++ b/src/dexed.mh @@ -0,0 +1,7 @@ +add https://github.com/dcoredump/dexed.lv2 0 +add http://gareus.org/oss/lv2/stepseq#s4n4 1 +connect effect_1:midiout effect_0:midi_in +connect effect_0:audio_out system:playback_1 +connect effect_0:audio_out system:playback_2 +param_set 1 grid_1_1 1 +param_set 1 grid_2_3 1