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

Method PlayNote

Source/Chorder.cpp:215–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void Chorder::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
216{
217 if (!mEnabled)
218 {
219 PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation);
220 return;
221 }
222
223 bool noteOn = velocity > 0;
224 if (mInputNotes[pitch] == noteOn)
225 return;
226 mInputNotes[pitch] = noteOn;
227
228 if (velocity > 0)
229 mVelocity = velocity;
230
231 int idx = 0;
232 // iterate rows from bottom to top to go from lowest to highest note
233 // for compatibility with arpeggiator and strummer
234 for (int row = mChordGrid->GetRows() - 1; row >= 0; --row)
235 {
236 for (int col = 0; col < mChordGrid->GetCols(); ++col)
237 {
238 float val = mChordGrid->GetVal(col, row);
239 if (val > 0)
240 {
241 int gridPosition = col + (mChordGrid->GetRows() / 2 - row) * mChordGrid->GetCols();
242 int voice = (voiceIdx == -1) ? -1 : (voiceIdx + idx) % 16;
243 int outPitch;
244
245 if (!mDiatonic)
246 {
247 outPitch = pitch + gridPosition;
248 }
249 else if (gridPosition % TheScale->NumTonesInScale() == 0) //if this is the pressed note or an octave of it
250 {
251 //play the pressed note (might not be in scale, so play it directly)
252 int octave = gridPosition / TheScale->NumTonesInScale();
253 outPitch = pitch + TheScale->GetPitchesPerOctave() * octave;
254 }
255 else
256 {
257 int tone = gridPosition + TheScale->GetToneFromPitch(pitch);
258 outPitch = TheScale->MakeDiatonic(TheScale->GetPitchFromTone(tone));
259 }
260
261 PlayChorderNote(time, outPitch, velocity * val * val, voice, modulation);
262
263 ++idx;
264 }
265 }
266 }
267 CheckLeftovers();
268}
269
270void Chorder::PlayChorderNote(double time, int pitch, int velocity, int voice /*=-1*/, ModulationParameters modulation)
271{

Callers

nothing calls this directly

Calls 8

GetValMethod · 0.80
GetPitchesPerOctaveMethod · 0.80
GetToneFromPitchMethod · 0.80
MakeDiatonicMethod · 0.80
GetPitchFromToneMethod · 0.80
GetRowsMethod · 0.45
GetColsMethod · 0.45
NumTonesInScaleMethod · 0.45

Tested by

no test coverage detected