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

Method PlayNote

Source/UnstableModWheel.cpp:106–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
AppendToMethod · 0.80
GetModWheelMethod · 0.45

Tested by

no test coverage detected