Reimplemented MIDI controller 120 and 123 with event-cue-flushing.

pull/1/head
Holger Wirtz 8 years ago
parent da0fabe3de
commit 56adff66e1
  1. 54
      src/dexed.cpp
  2. 4
      src/dexed.h
  3. 2
      src/dexed.mk

@ -83,7 +83,6 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
lfo.reset(data+137); lfo.reset(data+137);
//normalizeDxVelocity = false;
setMonoMode(false); setMonoMode(false);
@ -369,13 +368,12 @@ void Dexed::run (uint32_t sample_count)
const LV2_Atom_Sequence* seq = p<LV2_Atom_Sequence> (p_midi_in); const LV2_Atom_Sequence* seq = p<LV2_Atom_Sequence> (p_midi_in);
float* output = p(p_audio_out); float* output = p(p_audio_out);
uint32_t last_frame = 0, num_this_time = 0; uint32_t last_frame = 0, num_this_time = 0;
bool drop_next_events=false;
Plugin::run(sample_count); Plugin::run(sample_count);
if(++_k_rate_counter%16) if(++_k_rate_counter%16)
{
set_params(); // pre_process: copy actual voice params set_params(); // pre_process: copy actual voice params
}
for (LV2_Atom_Event* ev = lv2_atom_sequence_begin (&seq->body); for (LV2_Atom_Event* ev = lv2_atom_sequence_begin (&seq->body);
!lv2_atom_sequence_is_end(&seq->body, seq->atom.size, ev); !lv2_atom_sequence_is_end(&seq->body, seq->atom.size, ev);
@ -386,7 +384,9 @@ void Dexed::run (uint32_t sample_count)
// If it's midi, send it to the engine // If it's midi, send it to the engine
if (ev->body.type == m_midi_type) if (ev->body.type == m_midi_type)
{ {
ProcessMidiMessage((uint8_t*) LV2_ATOM_BODY (&ev->body),ev->body.size); drop_next_events|=ProcessMidiMessage((uint8_t*) LV2_ATOM_BODY (&ev->body),ev->body.size);
if(drop_next_events==true)
continue;
} }
// render audio from the last frame until the timestamp of this event // render audio from the last frame until the timestamp of this event
@ -396,7 +396,7 @@ void Dexed::run (uint32_t sample_count)
// j is the index of the plugin's float output buffer which will be the timestamp // j is the index of the plugin's float output buffer which will be the timestamp
// of the last processed atom event. // of the last processed atom event.
for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j) for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
output[j]=outbuf_[i]; output[j]=outbuf_[i];
last_frame = ev->time.frames; last_frame = ev->time.frames;
} }
@ -411,7 +411,7 @@ void Dexed::run (uint32_t sample_count)
num_this_time = sample_count - last_frame; num_this_time = sample_count - last_frame;
GetSamples (num_this_time, outbuf_); GetSamples (num_this_time, outbuf_);
for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j) for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
output[j] = outbuf_[i]; output[j] = outbuf_[i];
} }
fx.process(output, sample_count); fx.process(output, sample_count);
@ -468,18 +468,16 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer)
if(f<-1) f=-1; if(f<-1) f=-1;
sumbuf[j]+=f; sumbuf[j]+=f;
audiobuf.get()[j]=0; audiobuf.get()[j]=0;
//sumbuf[j]+=static_cast<float>(audiobuf.get()[j]);
} }
} }
} }
uint32_t jmax = n_samples - i; uint32_t jmax = n_samples - i;
for (uint32_t j = 0; j < N; ++j) { for (uint32_t j = 0; j < N; ++j) {
if (j < jmax) { if (j < jmax)
buffer[i + j] = sumbuf[j]; buffer[i + j] = sumbuf[j];
} else { else
extra_buf_[j - jmax] = sumbuf[j]; extra_buf_[j - jmax] = sumbuf[j];
}
} }
} }
extra_buf_size_ = i - n_samples; extra_buf_size_ = i - n_samples;
@ -527,7 +525,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer)
} }
} }
void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) { bool Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
TRACE("Hi"); TRACE("Hi");
uint8_t cmd = buf[0]; uint8_t cmd = buf[0];
@ -536,12 +534,12 @@ void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
case 0x80 : case 0x80 :
TRACE("MIDI keyup event: %d",buf[1]); TRACE("MIDI keyup event: %d",buf[1]);
keyup(buf[1]); keyup(buf[1]);
return; return(false);
break; break;
case 0x90 : case 0x90 :
TRACE("MIDI keydown event: %d %d",buf[1],buf[2]); TRACE("MIDI keydown event: %d %d",buf[1],buf[2]);
keydown(buf[1], buf[2]); keydown(buf[1], buf[2]);
return; return(false);
break; break;
case 0xb0 : { case 0xb0 : {
uint8_t ctrl = buf[1]; uint8_t ctrl = buf[1];
@ -575,13 +573,18 @@ void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
} }
} }
break; break;
case 123:
TRACE("MIDI all-notes-off: %d %d",ctrl,value);
panic();
break;
case 120: case 120:
TRACE("MIDI all-sound-off: %d %d",ctrl,value); TRACE("MIDI all-sound-off: %d %d",ctrl,value);
all_sound_off(); panic();
return(true);
break;
case 123:
TRACE("MIDI all-notes-off: %d %d",ctrl,value);
for(uint8_t note=0; note<max_notes; note++)
{
voices[note].dx7_note->keyup();
}
return(true);
break; break;
} }
break; break;
@ -608,8 +611,8 @@ void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
break; break;
} }
TRACE("Bye"); TRACE("Bye");
return(false);
} }
void Dexed::keydown(uint8_t pitch, uint8_t velo) { void Dexed::keydown(uint8_t pitch, uint8_t velo) {
@ -622,10 +625,6 @@ TRACE("pitch=%d, velo=%d\n",pitch,velo);
pitch += data[144] - 24; pitch += data[144] - 24;
//if ( normalizeDxVelocity ) {
// velo = ((float)velo) * 0.7874015; // 100/127
//}
uint8_t note = currentNote; uint8_t note = currentNote;
uint8_t keydown_counter=0; uint8_t keydown_counter=0;
@ -842,15 +841,6 @@ void Dexed::panic(void) {
} }
} }
void Dexed::all_sound_off(void) {
for(uint8_t i=0;i<MAX_ACTIVE_NOTES;i++) {
voices[i].dx7_note->init(data, 0, 0, feedback_bitdepth);
if ( voices[i].dx7_note != NULL ) {
voices[i].dx7_note->oscSync();
}
}
}
//============================================================================== //==============================================================================
DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate) DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate)

@ -91,12 +91,11 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
VoiceStatus voiceStatus; VoiceStatus voiceStatus;
protected: protected:
void ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size); bool ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size);
void onParam(uint8_t param_num,float param_val); void onParam(uint8_t param_num,float param_val);
void keyup(uint8_t pitch); void keyup(uint8_t pitch);
void keydown(uint8_t pitch, uint8_t velo); void keydown(uint8_t pitch, uint8_t velo);
void panic(void); void panic(void);
void all_sound_off(void);
static const uint8_t MAX_ACTIVE_NOTES = 32; static const uint8_t MAX_ACTIVE_NOTES = 32;
uint8_t max_notes=MAX_ACTIVE_NOTES; uint8_t max_notes=MAX_ACTIVE_NOTES;
@ -105,7 +104,6 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
bool sustain; bool sustain;
bool monoMode; bool monoMode;
bool refreshVoice; bool refreshVoice;
//bool normalizeDxVelocity;
uint8_t engineType; uint8_t engineType;
uint8_t feedback_bitdepth; uint8_t feedback_bitdepth;
PluginFx fx; PluginFx fx;

@ -5,7 +5,7 @@
###################################### ######################################
DEXED_DEPENDENCIES = lvtk DEXED_DEPENDENCIES = lvtk
DEXED_VERSION = d8fcf2d029401bcebb2326a34d01b263dc555c48 DEXED_VERSION = da0fabe3de43de10c1e36899e751791888a7f4e3
DEXED_BUNDLES = dexed.lv2 DEXED_BUNDLES = dexed.lv2
DEXED_SITE = $(call github,dcoredump,dexed,$(DEXED_VERSION)) DEXED_SITE = $(call github,dcoredump,dexed,$(DEXED_VERSION))
DEXED_TARGET_MAKE = $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) MOD=1 DEXED_TARGET_MAKE = $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) MOD=1

Loading…
Cancel
Save