Spaces:
Running
Running
Demo on a single file
Browse files
app.py
CHANGED
@@ -1,17 +1,40 @@
|
|
1 |
import streamlit as st
|
2 |
import streamlit_pianoroll
|
3 |
-
from datasets import load_dataset
|
4 |
from fortepyan import MidiPiece
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
)
|
13 |
-
piece = MidiPiece.from_huggingface(dataset[idx])
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import streamlit_pianoroll
|
|
|
3 |
from fortepyan import MidiPiece
|
4 |
|
5 |
+
piece = MidiPiece.from_file("haydn.mid")
|
6 |
+
|
7 |
+
st.write("## Display a PianoRoll player")
|
8 |
+
streamlit_pianoroll.from_fortepyan(piece)
|
9 |
+
|
10 |
+
st.write("## Conditional coloring")
|
11 |
+
st.write("Absolute pitch value condition")
|
12 |
+
df = piece.df.copy()
|
13 |
+
|
14 |
+
ids = df.pitch > 60
|
15 |
+
|
16 |
+
part_a = df[ids]
|
17 |
+
part_b = df[~ids]
|
18 |
+
piece_a = MidiPiece(df=part_a)
|
19 |
+
piece_b = MidiPiece(df=part_b)
|
20 |
+
|
21 |
+
streamlit_pianoroll.from_fortepyan(
|
22 |
+
piece=piece_a,
|
23 |
+
secondary_piece=piece_b,
|
24 |
)
|
|
|
25 |
|
26 |
+
st.write("Note duration condition")
|
27 |
|
28 |
+
df = piece.df.copy()
|
29 |
+
|
30 |
+
ids = df.duration > 0.23
|
31 |
+
|
32 |
+
part_a = df[ids]
|
33 |
+
part_b = df[~ids]
|
34 |
+
piece_a = MidiPiece(df=part_a)
|
35 |
+
piece_b = MidiPiece(df=part_b)
|
36 |
+
|
37 |
+
streamlit_pianoroll.from_fortepyan(
|
38 |
+
piece=piece_a,
|
39 |
+
secondary_piece=piece_b,
|
40 |
+
)
|
haydn.mid
ADDED
Binary file (13.6 kB). View file
|
|