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

Method PlayNote

Source/NoteChance.cpp:117–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void NoteChance::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
118{
119 if (!mEnabled)
120 {
121 PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation);
122 return;
123 }
124
125 if (velocity > 0)
126 ComputeSliders(0);
127
128 float random;
129 if (mDeterministic)
130 {
131 const int kStepResolution = 128;
132 uint64_t step = int(TheTransport->GetMeasureTime(time) * kStepResolution);
133 int randomIndex = step % ((mLength * kStepResolution) / TheTransport->GetTimeSigTop());
134 random = ((abs(DeterministicRandom(mSeed, randomIndex)) % 10000) / 10000.0f);
135 }
136 else
137 {
138 random = ofRandom(1);
139 }
140
141 bool accept = random <= mChance;
142 if (accept || velocity == 0)
143 PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation);
144
145 if (velocity > 0)
146 {
147 if (accept)
148 mLastAcceptTime = time;
149 else
150 mLastRejectTime = time;
151 }
152}
153
154void NoteChance::Reseed()
155{

Callers

nothing calls this directly

Calls 4

DeterministicRandomFunction · 0.85
ofRandomFunction · 0.85
GetMeasureTimeMethod · 0.80
GetTimeSigTopMethod · 0.80

Tested by

no test coverage detected