Fixed some problems with handling MIDI.

Hopefully fixed initial parameter handling.
pull/1/head
Holger Wirtz 8 years ago
parent e54bc531de
commit bf05154a7f
  1. 35
      src/dexed.cpp
  2. 2
      src/dexed.h

@ -58,6 +58,9 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
extra_buf_size_ = 0; extra_buf_size_ = 0;
add_voices(new DexedVoice(rate)); add_voices(new DexedVoice(rate));
//add_voices(new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate));
add_audio_outputs(p_audio_out);
TRACE("Bye"); TRACE("Bye");
} }
@ -87,11 +90,9 @@ void Dexed::activate(void)
{ {
TRACE("Hi"); TRACE("Hi");
refreshVoice=true;
set_params();
Plugin::activate(); Plugin::activate();
set_params();
add_audio_outputs(p_audio_out); refreshVoice=true;
TRACE("Bye"); TRACE("Bye");
} }
@ -100,8 +101,6 @@ void Dexed::deactivate(void)
{ {
TRACE("Hi"); TRACE("Hi");
refreshVoice=true;
set_params();
Plugin::deactivate(); Plugin::deactivate();
TRACE("Bye"); TRACE("Bye");
@ -110,7 +109,6 @@ void Dexed::deactivate(void)
void Dexed::set_params(void) void Dexed::set_params(void)
{ {
TRACE("Hi"); TRACE("Hi");
TRACE("refreshVoice=%d",refreshVoice);
// Dexed-Unisono // Dexed-Unisono
if(isMonoMode()!=bool(*p(p_unisono))) if(isMonoMode()!=bool(*p(p_unisono)))
@ -324,9 +322,7 @@ void Dexed::run (uint32_t sample_count)
{ {
TRACE("midi msg %d: %d\n",i,((uint8_t*)LV2_ATOM_BODY(&ev->body))[i]); TRACE("midi msg %d: %d\n",i,((uint8_t*)LV2_ATOM_BODY(&ev->body))[i]);
} }
ProcessMidiMessage((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 // render audio from the last frame until the timestamp of this event
@ -448,7 +444,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer)
} }
} }
bool Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) { void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
TRACE("Hi"); TRACE("Hi");
uint8_t cmd = buf[0]; uint8_t cmd = buf[0];
@ -456,12 +452,10 @@ bool Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
switch(cmd & 0xf0) { switch(cmd & 0xf0) {
case 0x80 : case 0x80 :
keyup(buf[1]); keyup(buf[1]);
return(true); break;
case 0x90 : case 0x90 :
keydown(buf[1], buf[2]); keydown(buf[1], buf[2]);
return(true); break;
case 0xb0 : { case 0xb0 : {
uint8_t ctrl = buf[1]; uint8_t ctrl = buf[1];
uint8_t value = buf[2]; uint8_t value = buf[2];
@ -491,33 +485,28 @@ bool Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) {
} }
break; break;
} }
return(true); break;
} }
case 0xc0 : case 0xc0 :
//setCurrentProgram(buf[1]); //setCurrentProgram(buf[1]);
return(true); break;
// aftertouch // aftertouch
case 0xd0 : case 0xd0 :
controllers.aftertouch_cc = buf[1]; controllers.aftertouch_cc = buf[1];
controllers.refresh(); controllers.refresh();
return(true); break;
} }
switch (cmd) { switch (cmd) {
case 0xe0 : case 0xe0 :
controllers.values_[kControllerPitch] = buf[1] | (buf[2] << 7); controllers.values_[kControllerPitch] = buf[1] | (buf[2] << 7);
return(true);
break; break;
} }
TRACE("MIDI event unknown: cmd=%d, val1=%d, val2=%d",buf[0],buf[1],buf[2]); TRACE("MIDI event unknown: cmd=%d, val1=%d, val2=%d",buf[0],buf[1],buf[2]);
TRACE("Bye"); TRACE("Bye");
return(false);
} }
void Dexed::keydown(uint8_t pitch, uint8_t velo) { void Dexed::keydown(uint8_t pitch, uint8_t velo) {

@ -90,7 +90,7 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
VoiceStatus voiceStatus; VoiceStatus voiceStatus;
protected: protected:
bool ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size); void ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size);
void onParam(uint8_t param_num,uint8_t param_val); void onParam(uint8_t param_num,uint8_t 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);

Loading…
Cancel
Save