Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 282fc39

Browse files
authored
Merge pull request #27 from lukewys/main
Fix bug on instrument mis-alignment when using command-line midi synthesis. Bump version to 0.1.4.
2 parents 2466d61 + af55158 commit 282fc39

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

midi_ddsp/utils/midi_synthesis_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def time_to_frame(time_s, fs=250):
2020
return int(round(time_s * fs))
2121

2222

23-
def note_list_to_sequence(note_list, fs=250, pitch_offset=0, speed_rate=1):
23+
def note_list_to_sequence(note_list, fs=250, pitch_offset=0, speed_rate=1,
24+
remove_start_silence=False):
2425
"""Convert list of note in pretty_midi to midi sequence for
2526
expression generator."""
2627
note_pitch = []
@@ -37,7 +38,12 @@ def note_list_to_sequence(note_list, fs=250, pitch_offset=0, speed_rate=1):
3738
note_length.append(off_frame - on_frame)
3839
prev_off_frame = off_frame
3940

40-
# add a rest to the end
41+
# add the silence to the start if the remove_start_silence is False
42+
if not remove_start_silence:
43+
note_pitch.insert(0, 0)
44+
note_length.insert(0, time_to_frame(note_list[0].start / speed_rate, fs))
45+
46+
# add a rest of 1 second to the end for better synthesis quality
4147
note_pitch.append(0)
4248
note_length.append(fs)
4349

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setuptools.setup(
99
name='midi-ddsp',
10-
version='0.1.3',
10+
version='0.1.4',
1111
description='Synthesis of MIDI with DDSP',
1212
long_description=long_description,
1313
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)