Skip to content

Commit

Permalink
Add isGated and isReleased to voice mod matrix (#1463)
Browse files Browse the repository at this point in the history
Closes #1428

Also clean up some logging in the voice manager which I left on
by mistake
  • Loading branch information
baconpaul authored Nov 25, 2024
1 parent 349b3c1 commit 19c319d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libs/sst/sst-voicemanager
3 changes: 1 addition & 2 deletions src/engine/engine_voice_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void Engine::VoiceManagerResponder::moveAndRetriggerVoice(VMConfig::voice_t *v,
v->key = key;
v->originalMidiKey = key - dkey;
v->calculateVoicePitch();
v->isGated = true;
v->setIsGated(true);
for (auto &eg : v->eg)
{
eg.attackFrom(eg.outBlock0);
Expand All @@ -296,7 +296,6 @@ void Engine::VoiceManagerResponder::moveAndRetriggerVoice(VMConfig::voice_t *v,
{
eg.attackFrom(eg.outBlock0);
}
SCLOG("TODO - Gate voice and Retrigger AEG and EG2");
}

void Engine::MonoVoiceManagerResponder::setMIDIPitchBend(int16_t channel, int16_t pb14bit)
Expand Down
3 changes: 3 additions & 0 deletions src/modulation/voice_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void MatrixEndpoints::Sources::bind(scxt::voice::modulation::Matrix &m, engine::
m.bindSourceValue(noteExpressions.pressure,
v.noteExpressions[(int)Voice::ExpressionIDs::PRESSURE]);

m.bindSourceValue(voiceSources.isGated, v.isGatedF);
m.bindSourceValue(voiceSources.isReleased, v.isReleasedF);

for (int i = 0; i < scxt::numTransportPhasors; ++i)
{
m.bindSourceValue(transportSources.phasors[i], z.getEngine()->transportPhasors[i]);
Expand Down
12 changes: 11 additions & 1 deletion src/modulation/voice_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ struct MatrixEndpoints
Sources(engine::Engine *e)
: lfoSources(e), midiCCSources(e), midiSources(e), noteExpressions(e),
aegSource{'zneg', 'aeg ', 0}, eg2Source{'zneg', 'eg2 ', 0}, transportSources(e),
rngSources(e), macroSources(e), mpeSources(e)
rngSources(e), macroSources(e), mpeSources(e), voiceSources(e)
{
registerVoiceModSource(e, aegSource, "", "AEG");
registerVoiceModSource(e, eg2Source, "", "EG2");
Expand Down Expand Up @@ -292,6 +292,16 @@ struct MatrixEndpoints
SR volume, pan, tuning, vibrato, expression, brightness, pressure;
} noteExpressions;

struct VoiceSources
{
VoiceSources(engine::Engine *e) : isGated{'zvsr', 'gate'}, isReleased{'zvsr', 'reld'}
{
registerVoiceModSource(e, isGated, "Voice", "Is Gated");
registerVoiceModSource(e, isReleased, "Voice", "Is Released");
}
SR isGated, isReleased;
} voiceSources;

TransportSourceBase<SR, 'ztsp', true, registerVoiceModSource> transportSources;

struct RNGSources
Expand Down
12 changes: 10 additions & 2 deletions src/voice/voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ struct alignas(16) Voice : MoveableOnly<Voice>,
* Voice Playback State Model.
*/
bool isGated{false};
float isGatedF{0.f}, isReleasedF{0.f};
void setIsGated(bool g)
{
isGated = g;
isGatedF = g ? 1.f : 0.f;
isReleasedF = g ? 0.f : 1.f;
};

std::array<bool, maxGeneratorsPerVoice> isGeneratorRunning{};
bool isAnyGeneratorRunning{};
bool isAEGRunning{false};
Expand All @@ -202,7 +210,7 @@ struct alignas(16) Voice : MoveableOnly<Voice>,

void attack()
{
isGated = true;
setIsGated(true);
isAEGRunning = true;

isVoicePlaying = true;
Expand All @@ -212,7 +220,7 @@ struct alignas(16) Voice : MoveableOnly<Voice>,

voiceStarted();
}
void release() { isGated = false; }
void release() { setIsGated(false); }
void beginTerminationSequence() { terminationSequence = blocksToTerminate; }
void cleanupVoice();

Expand Down

0 comments on commit 19c319d

Please sign in to comment.