roszcz commited on
Commit
45ea463
1 Parent(s): 5cea595

Demo on a single file

Browse files
Files changed (2) hide show
  1. app.py +33 -10
  2. haydn.mid +0 -0
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
- dataset = load_dataset("epr-labs/maestro-sustain-v2", split="train")
7
- idx = st.number_input(
8
- label="Piece IDX",
9
- min_value=0,
10
- max_value=len(dataset) - 1,
11
- value=420,
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  )
13
- piece = MidiPiece.from_huggingface(dataset[idx])
14
 
15
- streamlit_pianoroll.from_fortepyan(piece[:500])
16
 
17
- st.json(piece.source)
 
 
 
 
 
 
 
 
 
 
 
 
 
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