Fixing several small bugs in handling of controllers.

Additional small bugs fixed.
pull/17/head
Holger Wirtz 5 years ago
parent 92c7adc989
commit bd6b251441
  1. 21
      MicroDexed.ino
  2. 1
      config.h
  3. 10
      controllers.h
  4. 58
      dexed.cpp

@ -566,6 +566,9 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
{
inCtrl = constrain(inCtrl, 0, 127);
inValue = constrain(inValue, 0, 127);
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
if (checkMidiChannel(inChannel, instance_id))
@ -587,26 +590,44 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
}
break;
case 1:
#ifdef DEBUG
Serial.println(F("MODWHEEL CC"));
#endif
MicroDexed[instance_id]->controllers.modwheel_cc = inValue;
MicroDexed[instance_id]->controllers.refresh();
break;
case 2:
#ifdef DEBUG
Serial.println(F("BREATH CC"));
#endif
MicroDexed[instance_id]->controllers.breath_cc = inValue;
MicroDexed[instance_id]->controllers.refresh();
break;
case 4:
#ifdef DEBUG
Serial.println(F("FOOT CC"));
#endif
MicroDexed[instance_id]->controllers.foot_cc = inValue;
MicroDexed[instance_id]->controllers.refresh();
break;
case 7: // Volume
#ifdef DEBUG
Serial.println(F("VOLUME CC"));
#endif
configuration.vol = map(inValue, 0, 0x7f, VOLUME_MIN, VOLUME_MAX);
set_volume(configuration.vol, configuration.pan, configuration.mono);
break;
case 10: // Pan
#ifdef DEBUG
Serial.println(F("PANORAMA CC"));
#endif
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX);
set_volume(configuration.vol, configuration.pan, configuration.mono);
break;
case 32: // BankSelect LSB
#ifdef DEBUG
Serial.println(F("BANK-SELECT CC"));
#endif
configuration.dexed[instance_id].bank = inValue;
break;
case 64:

@ -38,6 +38,7 @@
// 3. Afterconnecting to a Linux system there should be a MIDI an audio device available that is called "MicroMDexed", so you can start the following:
// $ aplaymidi -p 20:0 <MIDI-File> # e.g. test.mid
// $ arecord -f cd -Dhw:1,0 /tmp/bla.wav
//
#define VERSION "0.9.8"

@ -22,10 +22,6 @@
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#define snprintf _snprintf
#endif
// State of MIDI controllers
const int kControllerPitch = 0;
const int kControllerPitchRange = 1;
@ -47,13 +43,13 @@ struct FmMod {
}
void setRange(uint8_t r) {
range = r < 0 && r > 127 ? 0 : r;
range = r < 0 && r > 99 ? 0 : r;
}
void setTarget(uint8_t assign) {
assign = assign < 0 && assign > 7 ? 0 : assign;
pitch = assign & 1; // AMP
amp = assign & 2; // PITCH
pitch = assign & 1; // PITCH
amp = assign & 2; // AMP
eg = assign & 4; // EG
}
};

@ -605,24 +605,22 @@ void Dexed::setPBController(uint8_t pb_range, uint8_t pb_step)
Serial.println(F("Dexed::setPBController"));
#endif
pb_range %= PB_RANGE_MAX;
pb_step %= PB_STEP_MAX;
/*
#ifdef DEBUG
Serial.print(F("pb_range="));
Serial.println(pb_range, DEC);
Serial.print(F("pb_step="));
Serial.println(pb_step, DEC);
#endif
*/
pb_range = constrain(pb_range, PB_RANGE_MIN, PB_RANGE_MAX);
pb_step = constrain(pb_step, PB_STEP_MIN, PB_STEP_MAX);
#ifdef DEBUG
Serial.print(F("pb_range="));
Serial.println(pb_range, DEC);
Serial.print(F("pb_step="));
Serial.println(pb_step, DEC);
#endif
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE] = pb_range;
controllers.values_[kControllerPitchRange] = pb_range;
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP] = pb_step;
controllers.values_[kControllerPitchStep] = pb_step;
controllers.refresh();
//controllers.refresh();
}
void Dexed::setMWController(uint8_t mw_range, uint8_t mw_assign)
@ -631,17 +629,15 @@ void Dexed::setMWController(uint8_t mw_range, uint8_t mw_assign)
Serial.println(F("Dexed::setMWController"));
#endif
mw_range %= MW_RANGE_MAX;
mw_assign %= MW_ASSIGN_MAX;
mw_range = constrain(mw_range, MW_RANGE_MIN, MW_RANGE_MAX);
mw_assign = constrain(mw_assign, MW_ASSIGN_MIN, MW_ASSIGN_MAX);
/*
#ifdef DEBUG
Serial.print(F("mw_range="));
Serial.println(mw_range, DEC);
Serial.print(F("mw_assign="));
Serial.println(mw_assign, DEC);
#endif
*/
#ifdef DEBUG
Serial.print(F("mw_range="));
Serial.println(mw_range, DEC);
Serial.print(F("mw_assign="));
Serial.println(mw_assign, DEC);
#endif
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE] = mw_range;
controllers.wheel.setRange(mw_range);
@ -657,17 +653,15 @@ void Dexed::setFCController(uint8_t fc_range, uint8_t fc_assign)
Serial.println(F("Dexed::setFCController"));
#endif
fc_range %= FC_RANGE_MAX;
fc_assign %= FC_ASSIGN_MAX;
fc_range = constrain(fc_range, FC_RANGE_MIN, FC_RANGE_MAX);
fc_assign = constrain(fc_assign, FC_ASSIGN_MIN, FC_ASSIGN_MAX);
/*
#ifdef DEBUG
Serial.print(F("fc_range="));
Serial.println(fc_range, DEC);
Serial.print(F("fc_assign="));
Serial.println(fc_assign, DEC);
#endif
*/
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE] = fc_range;
controllers.foot.setRange(fc_range);
@ -683,17 +677,15 @@ void Dexed::setBCController(uint8_t bc_range, uint8_t bc_assign)
Serial.println(F("Dexed::setBCController"));
#endif
bc_range %= BC_RANGE_MAX;
bc_assign %= BC_ASSIGN_MAX;
bc_range = constrain(bc_range, BC_RANGE_MIN, BC_RANGE_MAX);
bc_assign = constrain(bc_assign, BC_ASSIGN_MIN, BC_ASSIGN_MAX);
/*
#ifdef DEBUG
Serial.print(F("bc_range="));
Serial.println(bc_range, DEC);
Serial.print(F("bc_assign="));
Serial.println(bc_assign, DEC);
#endif
*/
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE] = bc_range;
controllers.breath.setRange(bc_range);
@ -709,17 +701,15 @@ void Dexed::setATController(uint8_t at_range, uint8_t at_assign)
Serial.println(F("Dexed::setATController"));
#endif
at_range %= AT_RANGE_MAX;
at_assign %= AT_ASSIGN_MAX;
at_range = constrain(at_range, AT_RANGE_MIN, AT_RANGE_MAX);
at_assign = constrain(at_assign, AT_ASSIGN_MIN, AT_ASSIGN_MAX);
/*
#ifdef DEBUG
Serial.print(F("at_range="));
Serial.println(at_range, DEC);
Serial.print(F("at_assign="));
Serial.println(at_assign, DEC);
#endif
*/
data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE] = at_range;
controllers.at.setRange(at_range);

Loading…
Cancel
Save