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

Method PlayNote

Source/UnstablePressure.cpp:105–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void UnstablePressure::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
106{
107 if (mEnabled)
108 {
109 if (voiceIdx == -1)
110 {
111 if (velocity > 0)
112 {
113 bool foundVoice = false;
114 for (size_t i = 0; i < mIsVoiceUsed.size(); ++i)
115 {
116 int voiceToCheck = (i + mVoiceRoundRobin) % kNumVoices;
117 if (mIsVoiceUsed[voiceToCheck] == false)
118 {
119 voiceIdx = voiceToCheck;
120 mVoiceRoundRobin = (mVoiceRoundRobin + 1) % kNumVoices;
121 foundVoice = true;
122 break;
123 }
124 }
125
126 if (!foundVoice)
127 {
128 voiceIdx = mVoiceRoundRobin;
129 mVoiceRoundRobin = (mVoiceRoundRobin + 1) % kNumVoices;
130 }
131 }
132 else
133 {
134 voiceIdx = mPitchToVoice[pitch];
135 }
136 }
137
138 if (voiceIdx < 0 || voiceIdx >= kNumVoices)
139 voiceIdx = 0;
140
141 mIsVoiceUsed[voiceIdx] = velocity > 0;
142 mPitchToVoice[pitch] = (velocity > 0) ? voiceIdx : -1;
143
144 mModulation.GetPressure(voiceIdx)->AppendTo(modulation.pressure);
145 modulation.pressure = mModulation.GetPressure(voiceIdx);
146 }
147
148 FillModulationBuffer(time, voiceIdx);
149 PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation);
150}
151
152void UnstablePressure::OnTransportAdvanced(float amount)
153{

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
AppendToMethod · 0.80
GetPressureMethod · 0.45

Tested by

no test coverage detected