Skip to content

Commit 0f56ae5

Browse files
committed
fix: midi audio rendering
1 parent 3b93734 commit 0f56ae5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fortepyan/audio/render.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ def midi_to_wav(midi: Union[structures.MidiFile, structures.MidiPiece], wavpath:
3535
"""
3636
if isinstance(midi, structures.MidiPiece):
3737
midi = midi.to_midi()
38+
3839
# This will be deleted
3940
tmp_midi_path = tempfile.mkstemp(suffix=".mid")[1]
4041

4142
# Add an silent event to make sure the final notes
4243
# have time to ring out
43-
end_time = midi.get_end_time() + 0.2
44+
end_time = midi.duration + 0.2
4445
pedal_off = pretty_midi.ControlChange(64, 0, end_time)
45-
midi.instruments[0].control_changes.append(pedal_off)
46+
47+
midi._midi.instruments[0].control_changes.append(pedal_off)
4648

4749
midi.write(tmp_midi_path)
4850

0 commit comments

Comments
 (0)