Skip to content

Commit

Permalink
Add support for the TUNING note expression (#137)
Browse files Browse the repository at this point in the history
except

1. only tuning and
2. its not reliable in legato mode because of note-id reuse

Partially addresses #28
  • Loading branch information
baconpaul authored Jan 17, 2025
1 parent 2c02fe3 commit 07419e8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/clap/six-sines-clap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ struct SixSinesClap : public plugHelper_t, sst::clap_juce_shim::EditorProvider
{
return 16;
}
static uint32_t vst3_supportedNoteExpressions(const clap_plugin *plugin) { return 0; }
static uint32_t vst3_supportedNoteExpressions(const clap_plugin *plugin)
{
return clap_supported_note_expressions::AS_VST3_NOTE_EXPRESSION_TUNING;
}

const void *extension(const char *id) noexcept override
{
Expand Down
12 changes: 11 additions & 1 deletion src/synth/synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,17 @@ struct Synth
v->voiceValues.setGated(false);
v->voiceValues.releaseVelocity = rv;
}
void setNoteExpression(Voice *, int32_t, double) {}
void setNoteExpression(Voice *v, int32_t e, double val)
{
switch (e)
{
case CLAP_NOTE_EXPRESSION_TUNING:
v->voiceValues.noteExpressionTuningInSemis = val;
break;
default:
break;
}
}
void setVoicePolyphonicParameterModulation(Voice *, uint32_t, double) {}
void setPolyphonicAftertouch(Voice *v, int8_t a) { v->voiceValues.polyAt = a / 127.0; }

Expand Down
3 changes: 2 additions & 1 deletion src/synth/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void Voice::renderBlock()
MTS_RetuningInSemitones(monoValues.mtsClient, voiceValues.key, voiceValues.channel);
}
retuneKey += ((monoValues.pitchBend >= 0) ? out.bendUp : out.bendDown) * monoValues.pitchBend;
retuneKey += voiceValues.portaDiff * voiceValues.portaSign + voiceValues.mpeBendInSemis;
retuneKey += voiceValues.portaDiff * voiceValues.portaSign + voiceValues.mpeBendInSemis +
voiceValues.noteExpressionTuningInSemis;
retuneKey += out.fineTune * 0.01 + out.ftModNode.level * 2;

if (voiceValues.portaDiff > 1e-5)
Expand Down
2 changes: 2 additions & 0 deletions src/synth/voice_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct VoiceValues

float mpeBendInSemis{0}, mpeBendNormalized{0}, mpeTimbre{0}, mpePressure{0};

float noteExpressionTuningInSemis{0};

float uniRatioMul{1.0};
float uniPanShift{0.0};
int uniIndex{0};
Expand Down

0 comments on commit 07419e8

Please sign in to comment.