-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement MidiFile with pretty_midi (#7)
* reimplement MidiFile with pretty_midi, update tests * remove previous implementation * deal with warnings in tests 👍 * add method to merge MidiFiles and a test * improve midi file merge logic * cleanup - remove copies of pretty_midi internals - improve tests * Add MidiFile docstring * add streamlit for development flow
- Loading branch information
Showing
10 changed files
with
201 additions
and
1,039 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.pymon | ||
.plan | ||
.env | ||
tmp/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import streamlit as st | ||
from streamlit_pianoroll import from_fortepyan | ||
|
||
from fortepyan import MidiFile | ||
|
||
|
||
def main(): | ||
st.write("# Test MidiFile merging") | ||
uploaded_files = st.file_uploader( | ||
label="Upload one or many MIDI files", | ||
accept_multiple_files=True, | ||
) | ||
|
||
if not uploaded_files: | ||
st.write("Waiting for files") | ||
return | ||
|
||
midi_files = [] | ||
for uploaded_file in uploaded_files: | ||
midi_file = MidiFile.from_file(uploaded_file) | ||
midi_files.append(midi_file) | ||
|
||
merge_spacing = st.number_input( | ||
label="merge spacing [s] (time interval inserted between files)", | ||
min_value=0.0, | ||
max_value=30.0, | ||
value=5.0, | ||
) | ||
merged_midi_file = MidiFile.merge_files( | ||
midi_files=midi_files, | ||
space=merge_spacing, | ||
) | ||
st.write("Duration after merge:", merged_midi_file.duration) | ||
st.write("Number of notes after merge:", merged_midi_file.piece.size) | ||
|
||
from_fortepyan(merged_midi_file.piece) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.