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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -1
app.py CHANGED
@@ -1,9 +1,57 @@
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 |
 
1
  from midiutil import MIDIFile
2
  from musicpy import *
3
+ from musicpy.daw import *
4
 
5
+ import gradio as gr
6
 
7
  def write_song():
8
+
9
+ current_daw = daw(3)
10
+ current_daw.load(0, 'EMU II ACOUSTIC GUITAR.sf2')
11
+ current_daw.load(1, 'Arachno.sf2')
12
+
13
+ bass1 = chord('A1') % (1,) * 4
14
+ bass2 = (chord('A1, A2') % (1/16, 1/8) * 4 |
15
+ chord('G1, G2') % (1/16, 1/8) * 4 |
16
+ chord('F1, F2') % (1/16, 1/8) * 4 |
17
+ chord('D1, D2') % (1/16, 1/8) * 4)
18
+
19
+ guitar1 = (C('Am/A', 3) @ [1,2,3,4,2,3,4,3] % (1, 1/8) |
20
+ C('G/A', 3) @ [1,2,3,4,2,3,4,3] % (1, 1/8) |
21
+ C('F/A', 3) @ [1,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8) |
22
+ C('Dm/A', 3) @ [1,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8))
23
+
24
+ guitar2 = (C('Am', 4) @ [2,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8) |
25
+ C('G', 4) @ [2,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8) |
26
+ C('F', 4) @ [2,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8) |
27
+ C('Dm', 4) @ [2,3,1.1,2.1,3,1.1,2.1,1.1] % (1, 1/8))
28
+
29
+ drum1 = drum('S[l:.8; i:.; r:4], S[l:.16; i:.], S[l:.8; i:.], S[l:.16; i:.], S[l:.8; i:.], S[l:.8; i:.]').notes
30
+ drum2 = drum('H, a:.16;., r:16').notes
31
+ drum1 &= drum2
32
+ drum3 = drum('K, H, S, H, K[l:.16; i:.], K[l:.8; i:.], H[l:.16; i:.], S[l:.8; i:.], H[l:.8; i:.]').notes
33
+
34
+ synth_pad1 = chord('E5, G5, C6') % (1,) | chord('E5, B5, D6') % (1,) | chord('E5, A5, C6') % (1,) | chord('D5, F5, A5') % (1,)
35
+ synth_pad1.set_volume(80)
36
+
37
+ bass_part = (bass1 * 2 | bass2 * 4) + 3
38
+ guitar_part = (guitar1 * 2 | guitar2 * 4) + 3
39
+ drum_part = (drum1 * 4 | drum3 * 16)
40
+ synth_pad_part = (synth_pad1 * 4) + 3
41
+
42
+ result = P(tracks=[bass_part, guitar_part, drum_part, synth_pad_part],
43
+ instruments=[34, 3, 1, 51],
44
+ channels=[0, 1, 9, 2],
45
+ daw_channels=[1, 0, 1, 1],
46
+ start_times=[0, 0, 4, 8],
47
+ bpm=165)
48
+ #current_daw.play(result)
49
+ current_daw.export(current_song, filename='song.wav') # export the piece type current_song to
50
+ # a wav file named "my first song.wav"
51
+ return 'song.wav'
52
+
53
+
54
+ def write_song1():
55
  w = (C('Cmadd9,add11',5) @ [1,3,1.1,4,2.1,5,2.1,4] % (1/2,1/8) * 2 |
56
  C('A#add9,add11',4) @ [1,3,1.1,4,2.1,5,2.1,4] % (1/2,1/8) * 2 |
57
  C('G#add9',4) @ [1,3,1.1,4,2.1,4,1.1,3] % (1/2,1/8) * 2 |