Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 7, 2024
1 parent c7823c5 commit 94c45cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/nodegraph/include/nodegraph/NodeGraphOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ namespace l::nodegraph {
protected:
float mSamplesUntilUpdate = 0.0f;
int32_t mGateIndex = 0;
std::vector<float> mGate;
float mGainTarget = 1.0f;
float mGain = 1.0f;
float mGateSmoothing = 0.01f;
Expand Down
12 changes: 5 additions & 7 deletions packages/nodegraph/source/common/NodeGraphOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,29 +891,27 @@ namespace l::nodegraph {
void GraphEffectTranceGate::Process(int32_t numSamples, std::vector<NodeGraphInput>& inputs, std::vector<NodeGraphOutput>& outputs) {
// "Bpm", "Fmod", "Attack", "Pattern"


float bpm = inputs.at(2).Get();
//fmod = l::math::functions::pow(l::math::constants::E_f, (1.0f / 10.0f) * fmod); // range 0.1 - 10 with arg -1,1

float fmod = inputs.at(3).Get();
float attack = inputs.at(4).Get();

size_t patternsSize = patterns.size();
int32_t patternId = static_cast<int32_t>(patternsSize * inputs.at(5).Get());
auto& gate = patterns[patternId % patternsSize];

size_t patternSize = gate.size();
float fmod = inputs.at(3).Get() / static_cast<float>(patternSize);
mGateIndex %= patternSize;
float fmodPerPattern = fmod / static_cast<float>(patternSize);

mGateSmoothing = attack * attack;
mGateSmoothingNeg = mGateSmoothing * 0.25f;

float freq = 44100.0f * 60.0f / bpm;

mSamplesUntilUpdate = l::audio::BatchUpdate(freq * fmod, mSamplesUntilUpdate, 0, numSamples,
mSamplesUntilUpdate = l::audio::BatchUpdate(freq * fmodPerPattern, mSamplesUntilUpdate, 0, numSamples,
[&]() {
mGateIndex %= gate.size();
mGainTarget = gate[mGateIndex];
mGateIndex = (mGateIndex + 1) % gate.size();
mGateIndex++;
},
[&](int32_t start, int32_t end, bool) {
for (int32_t i = start; i < end; i++) {
Expand Down

0 comments on commit 94c45cf

Please sign in to comment.