johann22 commited on
Commit
9454d1d
1 Parent(s): af41b0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1,8 +1,23 @@
1
  from midiutil import MIDIFile
 
2
  import gradio as gr
3
 
4
 
5
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  def make_mid():
8
 
@@ -28,5 +43,5 @@ def make_mid():
28
  with gr.Blocks() as iface:
29
  btn=gr.Button()
30
  outp=gr.Files()
31
- btn.click(make_mid,None,outp)
32
  iface.launch()
 
1
  from midiutil import MIDIFile
2
+ from musicpy import *
3
  import gradio as gr
4
 
5
 
6
+ def write_song():
7
+ w = (C('Cmadd9,add11',5) @ [1,3,1.1,4,2.1,5,2.1,4] % (1/2,1/8) * 2 |
8
+ C('A#add9,add11',4) @ [1,3,1.1,4,2.1,5,2.1,4] % (1/2,1/8) * 2 |
9
+ C('G#add9',4) @ [1,3,1.1,4,2.1,4,1.1,3] % (1/2,1/8) * 2 |
10
+ C('A#add9',4) @ [1,3,1.1,4,2.1,4,1.1,3] % (1/2,1/8) * 2)
11
+
12
+ w2 = translate('C2;C3[l:2], i:2, A#1;A#2[l:2], i:2, G#1;G#2[l:2], i:2, A#1;A#2[l:2]')
13
+
14
+ # Write the song as a MIDI file
15
+ write(w2,
16
+ bpm=100,
17
+ channel=0,
18
+ name='funky_song.mid',
19
+ save_as_file=True)
20
+ return "funky_song.mid"
21
 
22
  def make_mid():
23
 
 
43
  with gr.Blocks() as iface:
44
  btn=gr.Button()
45
  outp=gr.Files()
46
+ btn.click(write_song,None,outp)
47
  iface.launch()