@@ -60,6 +60,7 @@ Dexed::Dexed(uint8_t maxnotes, uint16_t rate)
60
60
lastKeyDown = -1 ;
61
61
lfo.reset (data + 137 );
62
62
sustain = false ;
63
+ sostenuto = false ;
63
64
hold = false ;
64
65
voices = NULL ;
65
66
@@ -72,6 +73,7 @@ Dexed::Dexed(uint8_t maxnotes, uint16_t rate)
72
73
voices[i].dx7_note = new Dx7Note; // sizeof(Dx7Note) = 692
73
74
voices[i].keydown = false ;
74
75
voices[i].sustained = false ;
76
+ voices[i].sostenuted = false ;
75
77
voices[i].held = false ;
76
78
voices[i].live = false ;
77
79
voices[i].key_pressed_timer = 0 ;
@@ -284,13 +286,14 @@ void Dexed::keydown(uint8_t pitch, uint8_t velo) {
284
286
}
285
287
voices[note].keydown = false ;
286
288
voices[note].sustained = false ;
289
+ voices[note].sostenuted = false ;
287
290
voices[note].held = false ;
288
291
voices[note].live = false ;
289
292
voices[note].key_pressed_timer = 0 ;
290
293
keydown_counter--;
291
294
}
292
295
293
- if (!voices[note].keydown )
296
+ if (!voices[note].keydown && !voices[note]. sostenuted )
294
297
{
295
298
if ( hold )
296
299
{
@@ -321,6 +324,7 @@ void Dexed::keydown(uint8_t pitch, uint8_t velo) {
321
324
voices[note].midi_note = pitch;
322
325
voices[note].velocity = velo;
323
326
voices[note].sustained = sustain;
327
+ voices[note].sostenuted = false ;
324
328
voices[note].held = hold;
325
329
voices[note].keydown = true ;
326
330
int32_t srcnote = (previousKeyDown >= 0 ) ? previousKeyDown : pitch;
@@ -399,6 +403,9 @@ void Dexed::keyup(uint8_t pitch) {
399
403
}
400
404
}
401
405
406
+ if ( voices[note].sostenuted )
407
+ return ;
408
+
402
409
if ( sustain ) {
403
410
voices[note].sustained = true ;
404
411
} else if ( hold ) {
@@ -459,6 +466,41 @@ bool Dexed::getSustain(void)
459
466
return sustain;
460
467
}
461
468
469
+ void Dexed::setSostenuto (bool s)
470
+ {
471
+ if (sostenuto == s)
472
+ return ;
473
+
474
+ sostenuto = s;
475
+
476
+ if (sostenuto)
477
+ {
478
+ for (uint8_t note = 0 ; note < getMaxNotes (); note++)
479
+ {
480
+ if (voices[note].keydown )
481
+ {
482
+ voices[note].sostenuted = true ;
483
+ }
484
+ }
485
+ }
486
+ else
487
+ {
488
+ for (uint8_t note = 0 ; note < getMaxNotes (); note++)
489
+ {
490
+ if (voices[note].sostenuted )
491
+ {
492
+ voices[note].dx7_note ->keyup ();
493
+ voices[note].sostenuted = false ;
494
+ }
495
+ }
496
+ }
497
+ }
498
+
499
+ bool Dexed::getSostenuto (void )
500
+ {
501
+ return sostenuto;
502
+ }
503
+
462
504
void Dexed::setHold (bool h)
463
505
{
464
506
if (hold == h)
@@ -492,6 +534,7 @@ void Dexed::panic(void)
492
534
voices[i].keydown = false ;
493
535
voices[i].live = false ;
494
536
voices[i].sustained = false ;
537
+ voices[i].sostenuted = false ;
495
538
voices[i].held = false ;
496
539
voices[i].key_pressed_timer = 0 ;
497
540
if ( voices[i].dx7_note != NULL ) {
@@ -567,6 +610,7 @@ uint8_t Dexed::getNumNotesPlaying(void)
567
610
// all carrier-operators are silent -> disable the voice
568
611
voices[i].live = false ;
569
612
voices[i].sustained = false ;
613
+ voices[i].sostenuted = false ;
570
614
voices[i].held = false ;
571
615
voices[i].keydown = false ;
572
616
#if defined(MICRODEXED_VERSION) && defined(DEBUG)
0 commit comments