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

Method PlayNote

Source/NoteTransformer.cpp:72–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void NoteTransformer::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
73{
74 if (!mEnabled)
75 {
76 PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation);
77 return;
78 }
79
80 if (velocity == 0) //note off the one we played for this pitch, in case the transformer changed it while the note was held
81 {
82 if (mLastNoteOnForPitch[pitch] != -1)
83 PlayNoteOutput(time, mLastNoteOnForPitch[pitch], 0, voiceIdx);
84 return;
85 }
86
87 int tone = TheScale->GetToneFromPitch(pitch);
88 if (velocity > 0)
89 mLastTimeTonePlayed[tone % 7] = time;
90 int pitchOffset = pitch - TheScale->GetPitchFromTone(tone);
91
92 tone += mToneMod[tone % TheScale->NumTonesInScale()];
93
94 int outPitch = TheScale->GetPitchFromTone(tone) + pitchOffset;
95 PlayNoteOutput(time, outPitch, velocity, voiceIdx, modulation);
96 mLastNoteOnForPitch[pitch] = outPitch;
97}
98
99void NoteTransformer::LoadLayout(const ofxJSONElement& moduleInfo)
100{

Callers

nothing calls this directly

Calls 3

GetToneFromPitchMethod · 0.80
GetPitchFromToneMethod · 0.80
NumTonesInScaleMethod · 0.45

Tested by

no test coverage detected