added hint CC values

This commit is contained in:
Gordon JC Pearce 2024-09-08 11:13:23 +01:00
parent 879977132f
commit 9dc7f5b0ea
3 changed files with 77 additions and 20 deletions

View File

@ -33,7 +33,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "saw";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.def = 127.0f;
parameter.midiCC = 17;
break;
case k_sqr:
@ -43,15 +44,57 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 16;
break;
case k_sub:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
parameter.hints = kParameterIsAutomatable;
parameter.name = "Sub Osc";
parameter.symbol = "sub";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 18;
break;
case k_attack:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Attack";
parameter.symbol = "attack";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 73;
break;
case k_decay:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Decay";
parameter.symbol = "decay";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 75;
break;
case k_sustain:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Sustain";
parameter.symbol = "sustain";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 27;
break;
case k_release:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Release";
parameter.symbol = "release";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 72;
break;
}
}
@ -67,6 +110,18 @@ void Chassis::setParameterValue(uint32_t index, float value) {
case k_sub:
s.patch.sub = value / 127.0f;
break;
case k_attack:
s.patch.attack = attack_table[(int)value];
break;
case k_decay:
s.patch.decay = decay_table[(int)value];
break;
case k_sustain:
s.patch.sustain = (int)value << 7;
break;
case k_release:
s.patch.release = decay_table[(int)value];
break;
}
}
@ -107,6 +162,7 @@ void Chassis::deactivate() {
void Chassis::noteOn(uint8_t note) {
uint32_t i;
//printf("noteon %d %d\n", note, vPtr);
for (i = 0; i < NUM_VOICES; i++) {
vPtr++;
if (vPtr == NUM_VOICES) vPtr = 0;
@ -127,6 +183,7 @@ void Chassis::noteOn(uint8_t note) {
}
void Chassis::noteOff(uint8_t note) {
// printf("noteoff %d\n", note);
for (uint32_t i = 0; i < NUM_VOICES; i++) {
if (s.voice[i].note == note && !s.voice[i].isFree()) {
s.voice[i].off();
@ -151,6 +208,7 @@ void Chassis::doMidi(const MidiEvent *ev, uint32_t count, uint32_t timeLimit) {
case 0x80:
noteOff(ev[i].data[1]);
break;
#if 0
case 0xb0:
//printf("cc %02x %02x\n", ev[i].data[1], ev[i].data[2]);
val = ev[i].data[2]; // get control value
@ -178,6 +236,7 @@ void Chassis::doMidi(const MidiEvent *ev, uint32_t count, uint32_t timeLimit) {
s.patch.sustain = val << 7;
}
break;
#endif
}
}
lastEvent = i;

View File

@ -26,8 +26,8 @@
START_NAMESPACE_DISTRHO
//uint16_t attack_table[128];
//uint16_t decay_table[128];
// uint16_t attack_table[128];
// uint16_t decay_table[128];
class Chassis : public Plugin {
public:
@ -35,6 +35,10 @@ class Chassis : public Plugin {
k_saw,
k_sqr,
k_sub,
k_attack,
k_decay,
k_sustain,
k_release,
kParameterCount
};
@ -69,7 +73,7 @@ class Chassis : public Plugin {
void noteOff(uint8_t note);
private:
void doMidi(const MidiEvent *ev, uint32_t count, uint32_t timelimit ) ;
void doMidi(const MidiEvent *ev, uint32_t count, uint32_t timelimit);
double sampleRate;
uint32_t lastEvent;
// Voice voice[NUM_VOICES];
@ -80,7 +84,6 @@ class Chassis : public Plugin {
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Chassis);
};
uint16_t attack_table[128] = {
0x4000, 0x2000, 0x1000, 0x0aaa, 0x0800, 0x0666, 0x0555, 0x0492, 0x0400,
0x038e, 0x0333, 0x02e9, 0x02ab, 0x0276, 0x0249, 0x0222, 0x0200, 0x01e2,
@ -115,11 +118,6 @@ uint16_t decay_table[128] = {
0xffd8, 0xffdc, 0xffe0, 0xffe4, 0xffe8, 0xffec, 0xfff0, 0xfff1, 0xfff2,
0xfff3, 0xfff4};
END_NAMESPACE_DISTRHO
#endif // _CHASSIS_HPP

View File

@ -27,7 +27,7 @@ class Synth;
class Patch {
public:
float saw=1, sqr, sub;
uint16_t attack=0x1ff, decay=0x1ff, sustain=0x1000, release=0x1ff;
uint16_t attack, decay, sustain, release;
};
class Voice {
@ -55,12 +55,12 @@ class Voice {
K_ON,
K_SUSTAIN } keyState = K_OFF;
bool ff00; // reset bit
bool ff07; // status bit
bool ff08; // set to indicate attack phase complete
bool ff10; // note on bit
bool ff11; // sustain flag
bool ff33; // releasing flag
bool ff00=0; // reset bit
bool ff07=0; // status bit
bool ff08=0; // set to indicate attack phase complete
bool ff10=0; // note on bit
bool ff11=0; // sustain flag
bool ff33=0; // releasing flag
uint16_t env;