Skip to content

Commit

Permalink
If a note is played and the sustain pedal is not down and the same no…
Browse files Browse the repository at this point in the history
…te is already playing, then the first note is silenced as the new note begins.
  • Loading branch information
dhilowitz committed Apr 7, 2021
1 parent 77343be commit 60aa64a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Binary file modified src/Pianobook Piano Template (with Mic Levels).nki
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ on init
declare $tmp_num_round_robins
declare $tmp_last_rr
declare %last_rr[5] := (0,0,0,0,0)
declare %notes_playing[128]

end on

function func_play_note
Expand Down Expand Up @@ -119,7 +121,14 @@ function func_play_note
$tmp_note_id := play_note($func_play_note_midi_note, $func_play_note_velocity, 0, -1)
set_event_par_arr($tmp_note_id,$EVENT_PAR_ALLOW_GROUP,0,$ALL_GROUPS)

message("RR: " & $tmp_rr)
if($func_play_note_type = 1)
if (%notes_playing[$func_play_note_midi_note] > 0)
fade_out(%notes_playing[$func_play_note_midi_note], 20000, 1)
end if
%notes_playing[$func_play_note_midi_note] := $tmp_note_id
end if

{ message("RR: " & $tmp_rr) }
%last_rr[$func_play_note_type-1] := $tmp_rr
$i:= 0
while($i<$NUM_MICS)
Expand Down
12 changes: 12 additions & 0 deletions src/Pianobook Piano Template - Voice Triggering.ksp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on init
these, we will do round robins. Remember to change the size of
the arrays (the number in brackets after the array name) if you
add multiple groups to any of these. }

declare %note_without_pedal_groups[4] := (0,1,2,3)
declare %note_with_pedal_groups[4] := (4,5,6,7)
declare %release_trigger_groups[4] := (8,9,10,11)
Expand Down Expand Up @@ -62,6 +63,8 @@ on init
declare $release_trigger_last_rr := 0
declare $pedal_down_last_rr := 0
declare $pedal_up_last_rr := 0
declare %notes_playing[128]

end on

function func_play_note
Expand Down Expand Up @@ -124,6 +127,15 @@ function func_play_note
$tmp_note_id := play_note($func_play_note_midi_note, $func_play_note_velocity, 0, -1)
set_event_par_arr($tmp_note_id,$EVENT_PAR_ALLOW_GROUP,0,$ALL_GROUPS)

if($func_play_note_type = 1)
if (%notes_playing[$func_play_note_midi_note] > 0)
fade_out(%notes_playing[$func_play_note_midi_note], 20000, 1)
end if
%notes_playing[$func_play_note_midi_note] := $tmp_note_id
end if

{ message("RR: " & $tmp_rr) }

select($func_play_note_type)
case 1
$note_without_pedal_last_rr := $tmp_rr
Expand Down
Binary file modified src/Pianobook Piano Template.nki
Binary file not shown.

0 comments on commit 60aa64a

Please sign in to comment.