diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/__pycache__/hannds_files.cpython-38.pyc b/__pycache__/hannds_files.cpython-38.pyc new file mode 100644 index 0000000..4773e1d Binary files /dev/null and b/__pycache__/hannds_files.cpython-38.pyc differ diff --git a/__pycache__/kalman_mapper.cpython-38.pyc b/__pycache__/kalman_mapper.cpython-38.pyc new file mode 100644 index 0000000..4cd07a5 Binary files /dev/null and b/__pycache__/kalman_mapper.cpython-38.pyc differ diff --git a/single_file.py b/single_file.py index a9e1f32..2993861 100644 --- a/single_file.py +++ b/single_file.py @@ -17,7 +17,7 @@ def process(self, filename): right_hand = mido.MidiTrack() bpm = 120 #default - new_mid = mido.MidiFile() + new_mid = mido.MidiFile(ticks_per_beat=mid.ticks_per_beat) left_hand_is_playing = {0} total_sec = 0 @@ -26,7 +26,8 @@ def process(self, filename): for msg in track: sec = mido.tick2second(msg.time, mid.ticks_per_beat, mido.bpm2tempo(bpm)) total_sec = total_sec + sec - total_ticks = total_ticks + msg.time + # total_ticks = total_ticks + msg.time + total_ticks += msg.time if msg.type == "note_off" or (msg.type == "note_on" and msg.velocity==0): event = kalman_mapper.MidiEvent(msg.note, is_note_on=False, when=total_sec, is_left=None) mapper.midi_event(event) @@ -49,11 +50,15 @@ def process(self, filename): left_hand.append(msg.copy(time=total_ticks)) right_hand.append(msg.copy(time=total_ticks)) + + new_mid.tracks.append(mido.midifiles.tracks._to_reltime(right_hand)) new_mid.tracks.append(mido.midifiles.tracks._to_reltime(left_hand)) new_mid.save(filename.replace(".mid", "-split.mid")) + + def main(): parser = argparse.ArgumentParser() parser.add_argument('--input', required=True, help='File path of the MIDI file to process.')