Skip to content

Commit

Permalink
Add a modulator 'keytrack from 60' (#126)
Browse files Browse the repository at this point in the history
Ther eyou go, Jacky!
  • Loading branch information
baconpaul authored Jan 15, 2025
1 parent 9cd1d66 commit 1228fcc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/clap/six-sines-clap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct SixSinesClap : public plugHelper_t, sst::clap_juce_shim::EditorProvider
clapJuceShim = std::make_unique<sst::clap_juce_shim::ClapJuceShim>(this);
clapJuceShim->setResizable(false);
}
virtual ~SixSinesClap() {};
virtual ~SixSinesClap(){};

std::unique_ptr<Synth> engine;
size_t blockPos{0};
Expand Down
3 changes: 3 additions & 0 deletions src/dsp/node_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ template <typename T> struct ModulationSupport
case ModMatrixConfig::Source::RELEASED:
sourcePointers[which] = &voiceValues.ungatedFloat;
break;
case ModMatrixConfig::Source::KEYTRACK_FROM_60:
sourcePointers[which] = &voiceValues.keytrackFrom60;
break;

case ModMatrixConfig::Source::MPE_PRESSURE:
sourcePointers[which] = &voiceValues.mpePressure;
Expand Down
1 change: 1 addition & 0 deletions src/synth/mod_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ModMatrixConfig::ModMatrixConfig()
add(GATED, "Voice", "Gated");
add(RELEASED, "Voice", "Released");
add(UNISON_VAL, "Voice", "Unison Position");
add(KEYTRACK_FROM_60, "Voice", "Keytrack from 60");

add(MPE_PRESSURE, "MPE", "Pressure");
add(MPE_TIMBRE, "MPE", "Timbre");
Expand Down
1 change: 1 addition & 0 deletions src/synth/mod_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ModMatrixConfig
GATED = voiceLevel + 50,
RELEASED = voiceLevel + 51,
UNISON_VAL = voiceLevel + 60,
KEYTRACK_FROM_60 = voiceLevel + 61,

MPE_PRESSURE = voiceLevel + 100,
MPE_TIMBRE = voiceLevel + 101,
Expand Down
6 changes: 3 additions & 3 deletions src/synth/synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ struct Synth
void moveVoice(Voice *v, uint16_t p, uint16_t c, uint16_t k, float ve)
{
v->setupPortaTo(k, synth.patch.output.portaTime.value);
v->voiceValues.key = k;
v->voiceValues.setKey(k);
v->voiceValues.velocity = ve;
v->retriggerAllEnvelopesForKeyPress();
}

void moveAndRetriggerVoice(Voice *v, uint16_t p, uint16_t c, uint16_t k, float ve)
{
v->setupPortaTo(k, synth.patch.output.portaTime.value);
v->voiceValues.key = k;
v->voiceValues.setKey(k);
v->voiceValues.velocity = ve;
v->voiceValues.setGated(true);
v->retriggerAllEnvelopesForReGate();
Expand Down Expand Up @@ -157,7 +157,7 @@ struct Synth
obuf[vc].voice = &synth.voices[i];
synth.voices[i].used = true;
synth.voices[i].voiceValues.setGated(true);
synth.voices[i].voiceValues.key = key;
synth.voices[i].voiceValues.setKey(key);
synth.voices[i].voiceValues.channel = ch;
synth.voices[i].voiceValues.velocity = vel;
synth.voices[i].voiceValues.releaseVelocity = 0;
Expand Down
12 changes: 10 additions & 2 deletions src/synth/voice_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace baconpaul::six_sines
{
struct VoiceValues
{
VoiceValues() : gated(gatedV) {}
VoiceValues() : gated(gatedV), key(keyV) {}

const bool &gated;
float gatedFloat, ungatedFloat;
Expand All @@ -35,7 +35,14 @@ struct VoiceValues
gatedFloat = g ? 1.f : 0.f;
ungatedFloat = 1.0 - gatedFloat;
}
int key{0}, channel{0};
void setKey(int k)
{
keyV = k;
keytrackFrom60 = (k - 60) / 12.0;
}
const int &key;
float keytrackFrom60;
int channel{0};
float velocity{0}, releaseVelocity{0};

float polyAt{0};
Expand All @@ -54,6 +61,7 @@ struct VoiceValues

private:
bool gatedV{false};
int keyV{0};
};
}; // namespace baconpaul::six_sines
#endif // MONO_VALUES_H

0 comments on commit 1228fcc

Please sign in to comment.