Commit 71743e3 larspalo
committed
1 parent aca2058 commit 71743e3 Copy full SHA for 71743e3
File tree 1 file changed +29
-9
lines changed
1 file changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -309,20 +309,40 @@ void GOCoupler::ChangeKey(int note, unsigned velocity) {
309
309
m_CurrentTone = -1 ;
310
310
}
311
311
312
- if (
313
- ((velocity > 0 && nextNote == note)
314
- || (velocity == 0 && nextNote == m_LastTone))
315
- || m_CurrentTone == -1 )
312
+ if (((velocity > 0 && nextNote == note)
313
+ || (velocity == 0 && nextNote == m_LastTone)))
316
314
m_CurrentTone = nextNote;
317
315
318
316
if (m_CurrentTone != -1 )
319
317
SetOut (m_CurrentTone + m_Keyshift, m_KeyVelocity[m_CurrentTone]);
320
318
321
- if (velocity > 0 )
322
- m_LastTone = note;
323
- else
324
- m_LastTone = -1 ;
325
- return ;
319
+ int nextCandidate = nextNote;
320
+ if (m_CouplerType == COUPLER_BASS) {
321
+ for (nextCandidate += 1 ; nextCandidate < (int )m_KeyVelocity.size ();
322
+ nextCandidate++)
323
+ if (m_KeyVelocity[nextCandidate] > 0 )
324
+ break ;
325
+ if (nextCandidate == (int )m_KeyVelocity.size ())
326
+ nextCandidate = -1 ;
327
+ if (velocity > 0 )
328
+ m_LastTone = (note < nextCandidate)
329
+ ? note
330
+ : (nextCandidate < 0 ? note : nextCandidate);
331
+ else
332
+ m_LastTone = (note < nextCandidate) ? -1 : nextCandidate;
333
+ return ;
334
+ } else {
335
+ for (nextCandidate -= 1 ; nextCandidate >= 0 ; nextCandidate--)
336
+ if (m_KeyVelocity[nextCandidate] > 0 )
337
+ break ;
338
+ if (velocity > 0 )
339
+ m_LastTone = (note > nextCandidate)
340
+ ? note
341
+ : (nextCandidate > 0 ? nextCandidate : note);
342
+ else
343
+ m_LastTone = (note > nextCandidate) ? -1 : nextCandidate;
344
+ return ;
345
+ }
326
346
}
327
347
SetOut (note + m_Keyshift, velocity);
328
348
}
You can’t perform that action at this time.
0 commit comments