MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / OnTransportAdvanced

Method OnTransportAdvanced

Source/LFO.cpp:178–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void LFO::OnTransportAdvanced(float amount)
179{
180 if (mOsc.GetType() == kOsc_Drunk)
181 {
182 float distance = 0;
183 if (mPeriod == kInterval_Free)
184 {
185 distance = mFreeRate / 40;
186 }
187 else
188 {
189 distance = TheTransport->GetDuration(kInterval_64n) / TheTransport->GetDuration(mPeriod);
190 }
191 float drunk = ofRandom(-distance, distance);
192 if (mDrunk + drunk > 1 || mDrunk + drunk < 0)
193 drunk *= -1;
194 mDrunk = ofClamp(mDrunk + drunk, 0, 1);
195 }
196 if (mPeriod == kInterval_Free || mOsc.GetType() == kOsc_Perlin)
197 {
198 mFreePhase += mFreeRate * amount * TheTransport->MsPerBar() / 1000;
199 double wrap = mOsc.GetShuffle() > 0 ? 2 : 1;
200 if (mFreePhase > wrap || mFreePhase < 0)
201 {
202 mFreePhase = fmod(mFreePhase, wrap);
203 if (mOsc.GetType() == kOsc_Random)
204 OnTimeEvent(gTime);
205 }
206 }
207}

Callers 1

AdvanceMethod · 0.45

Calls 6

ofRandomFunction · 0.85
ofClampFunction · 0.85
GetDurationMethod · 0.80
MsPerBarMethod · 0.80
GetShuffleMethod · 0.80
GetTypeMethod · 0.45

Tested by

no test coverage detected