diff --git a/src/Dexed.ttl b/src/Dexed.ttl index dcb2c50..7ac9b86 100644 --- a/src/Dexed.ttl +++ b/src/Dexed.ttl @@ -61,7 +61,7 @@ lv2:index 5 ; lv2:symbol "engine" ; lv2:name "ENGINE" ; - lv2:default 3 ; + lv2:default 2 ; lv2:minimum 1 ; lv2:maximum 3 ; lv2:portProperty lv2:integer ; @@ -1517,6 +1517,6 @@ lv2:portProperty lv2:integer ; ] ; - doap:name "DeeAxe7" ; + doap:name "Dexed" ; doap:maintainer [ foaf:name "dcoredump" ] . diff --git a/src/dexed.cpp b/src/dexed.cpp index f0fb5fb..dc239ad 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -19,7 +19,6 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) TRACE("Hi"); bufsize_=256; - //outbuf_=new int16_t[bufsize_]; outbuf_=new float[bufsize_]; Exp2::init(); @@ -89,14 +88,29 @@ Dexed::~Dexed() void Dexed::set_params(void) { - TRACE("Hi"); - - refreshVoice=true; + // Dexed-Engine + if(getEngineType()!=(*p(p_engine))-1) + { + panic(); + setEngineType((*p(p_engine))-1); + } // Dexed-Filter - fx.uiCutoff=*p(p_cutoff); - fx.uiReso=*p(p_resonance); - fx.uiGain=*p(p_output); + if(fx.uiCutoff!=*p(p_cutoff)) + { + fx.uiCutoff=*p(p_cutoff); + refreshVoice=true; + } + if(fx.uiReso!=*p(p_resonance)) + { + fx.uiReso=*p(p_resonance); + refreshVoice=true; + } + if(fx.uiGain!=*p(p_output)) + { + fx.uiGain=*p(p_output); + refreshVoice=true; + } // OP6 onParam(0,static_cast(*p(p_op6_eg_rate_1))); @@ -252,8 +266,6 @@ void Dexed::set_params(void) onParam(144,static_cast(*p(p_transpose))); // 10 bytes (145-154) are the name of the patch onParam(155,0x3f); // operator on/off => All OPs on - - TRACE("Bye"); } // override the run() method @@ -263,6 +275,8 @@ void Dexed::run (uint32_t sample_count) float* output = p(p_audio_out); uint32_t last_frame = 0, num_this_time = 0; + set_params(); // pre_process: copy actual voice params + for (LV2_Atom_Event* ev = lv2_atom_sequence_begin (&seq->body); !lv2_atom_sequence_is_end(&seq->body, seq->atom.size, ev); ev = lv2_atom_sequence_next (ev)) @@ -272,14 +286,16 @@ void Dexed::run (uint32_t sample_count) // If it's midi, send it to the engine if (ev->body.type == m_midi_type) { - set_params(); // pre_process: copy actual voice params - ring_buffer_.Write ((uint8_t*) LV2_ATOM_BODY (&ev->body), ev->body.size); #ifdef DEBUG - for(uint i=0;ibody.size;i++) - { - TRACE("midi msg %d: %d\n",i,((uint8_t*)LV2_ATOM_BODY(&ev->body))[i]); - } + for(uint i=0;ibody.size;i++) + { + TRACE("midi msg %d: %d\n",i,((uint8_t*)LV2_ATOM_BODY(&ev->body))[i]); + } #endif +// ring_buffer_.Write ((uint8_t*) LV2_ATOM_BODY (&ev->body), ev->body.size); + + if(ProcessMidiMessage((uint8_t*) LV2_ATOM_BODY (&ev->body),ev->body.size)==false) + break; } // render audio from the last frame until the timestamp of this event @@ -289,7 +305,6 @@ void Dexed::run (uint32_t sample_count) // 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 (outbuf_[i])) * *p(p_output); output[j]=outbuf_[i]; last_frame = ev->time.frames; @@ -305,7 +320,6 @@ void Dexed::run (uint32_t sample_count) num_this_time = sample_count - last_frame; GetSamples (num_this_time, outbuf_); for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j) - //output[j] = (static_cast (outbuf_[i])) * *p(p_output); output[j] = outbuf_[i]; } @@ -314,7 +328,7 @@ void Dexed::run (uint32_t sample_count) void Dexed::GetSamples(int n_samples, float *buffer) { - size_t input_offset; + /* size_t input_offset; TransferInput(); for (input_offset = 0; input_offset < input_buffer_index_; ) { @@ -325,7 +339,7 @@ void Dexed::GetSamples(int n_samples, float *buffer) } input_offset += bytes_consumed; } - ConsumeInput(input_offset); + ConsumeInput(input_offset); */ int i; if ( refreshVoice ) { @@ -394,20 +408,25 @@ void Dexed::GetSamples(int n_samples, float *buffer) } extra_buf_size_ = i - n_samples; } +//#ifdef DEBUG +//for(i=0;i 0) { - ring_buffer_.Read(bytes_to_read, input_buffer_ + input_buffer_index_); - input_buffer_index_ += bytes_to_read; - } -} + TRACE("MIDI event unknown: cmd=%d, val1=%d, val2=%d",buf[0],buf[1],buf[2]); -void Dexed::ConsumeInput(size_t n_input_bytes) { - if (n_input_bytes < input_buffer_index_) { - memmove(input_buffer_, input_buffer_ + n_input_bytes, - input_buffer_index_ - n_input_bytes); - } - input_buffer_index_ -= n_input_bytes; + TRACE("Bye"); + + return(false); } void Dexed::keydown(uint8_t pitch, uint8_t velo) { @@ -580,7 +586,11 @@ TRACE("Bye"); void Dexed::onParam(int param_num,int param_val) { - data[param_num]=param_val; + if(param_val!=data[param_num]) + { + refreshVoice=true; + data[param_num]=param_val; + } } int Dexed::getEngineType() { @@ -611,6 +621,16 @@ void Dexed::setMonoMode(bool mode) { monoMode = mode; } +void Dexed::panic(void) { + for(int i=0;ioscSync(); + } + } +} + //============================================================================== DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate) diff --git a/src/dexed.h b/src/dexed.h index e64d0dc..76d3308 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -92,12 +92,11 @@ class Dexed : public lvtk::Synth VoiceStatus voiceStatus; protected: - int ProcessMidiMessage(const uint8_t *buf, int buf_size); + bool ProcessMidiMessage(const uint8_t *buf, int buf_size); void onParam(int param_num,int param_val); - void TransferInput(); - void ConsumeInput(size_t n_input_bytes); void keyup(uint8_t pitch); void keydown(uint8_t pitch, uint8_t velo); + void panic(void); static const int MAX_ACTIVE_NOTES = 16; ProcessorVoice voices[MAX_ACTIVE_NOTES]; @@ -115,13 +114,10 @@ class Dexed : public lvtk::Synth EngineMkI engineMkI; EngineOpl engineOpl; RingBuffer ring_buffer_; - //int16_t* outbuf16_; float* outbuf_; uint32_t bufsize_; int16_t extra_buf_[N]; int extra_buf_size_; - uint8_t input_buffer_[8192]; - size_t input_buffer_index_; private: };