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

Commit

Permalink
Merge pull request #27 from lukewys/main
Browse files Browse the repository at this point in the history
Fix bug on instrument mis-alignment when using command-line midi synthesis. Bump version to 0.1.4.
  • Loading branch information
lukewys authored Jan 8, 2022
2 parents 2466d61 + af55158 commit 282fc39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions midi_ddsp/utils/midi_synthesis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def time_to_frame(time_s, fs=250):
return int(round(time_s * fs))


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

# add a rest to the end
# add the silence to the start if the remove_start_silence is False
if not remove_start_silence:
note_pitch.insert(0, 0)
note_length.insert(0, time_to_frame(note_list[0].start / speed_rate, fs))

# add a rest of 1 second to the end for better synthesis quality
note_pitch.append(0)
note_length.append(fs)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name='midi-ddsp',
version='0.1.3',
version='0.1.4',
description='Synthesis of MIDI with DDSP',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 282fc39

Please sign in to comment.