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

Method PlayNote

Source/ScriptModule.cpp:812–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812void ScriptModule::PlayNote(double time, float pitch, float velocity, float pan, int noteOutputIndex, int lineNum)
813{
814 if (velocity > 0)
815 {
816 //run through any scheduled note offs for this pitch
817 for (size_t i = 0; i < mScheduledNoteOutput.size(); ++i)
818 {
819 if (mScheduledNoteOutput[i].velocity == 0 &&
820 mScheduledNoteOutput[i].pitch == pitch &&
821 mScheduledNoteOutput[i].time != -1 &&
822 mScheduledNoteOutput[i].time - 3 <= time)
823 {
824 PlayNote(MIN(mScheduledNoteOutput[i].time, time), mScheduledNoteOutput[i].pitch, mScheduledNoteOutput[i].velocity, mScheduledNoteOutput[i].pan, mScheduledNoteOutput[i].noteOutputIndex, mScheduledNoteOutput[i].lineNum);
825 mScheduledNoteOutput[i].time = -1;
826 }
827 }
828 }
829
830 //ofLog() << "ScriptModule::PlayNote() " << velocity << " " << time;
831 int intPitch = int(pitch + .5f);
832 ModulationParameters modulation;
833 modulation.pan = pan;
834 if (pitch - intPitch != 0)
835 {
836 modulation.pitchBend = &mPitchBends[intPitch];
837 modulation.pitchBend->SetValue(pitch - intPitch);
838 }
839 SendNoteToIndex(noteOutputIndex, time, intPitch, (int)velocity, -1, modulation);
840
841 if (velocity > 0)
842 mNotePlayTracker.AddEvent(lineNum, ofToString(pitch) + " " + ofToString(velocity) + " " + ofToString(pan, 1));
843}
844
845void ScriptModule::SendNoteToIndex(int index, double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
846{

Callers

nothing calls this directly

Calls 4

ofToStringFunction · 0.85
sizeMethod · 0.80
SetValueMethod · 0.45
AddEventMethod · 0.45

Tested by

no test coverage detected