28
28
import os
29
29
import mingus .core .scales as scales
30
30
import sys
31
+ import re
31
32
32
33
from src .chords2midi import c2m
33
34
from chords import *
64
65
# Test mode
65
66
if len (sys .argv ) > 1 and sys .argv [1 ] == '--test' :
66
67
keys = [ ('C' , 'A' ) ]
67
- styles = [ '' ]
68
+ # styles = [ '' ]
68
69
69
70
#
70
71
# Generate a single chord
@@ -82,11 +83,17 @@ def gen(dir, key, chords, prefix):
82
83
#
83
84
def genprog (dir , key , chords , prefix , style = '' ):
84
85
c2m_obj = c2m .Chords2Midi ()
85
- args = chords .split (" " )
86
+ # two spaces to insert a rest
87
+ newchords = re .sub (r' ' , ' X ' , chords )
88
+ args = newchords .split (" " )
86
89
if style != '' :
87
90
args .extend (["-p" , style ])
88
91
dir = dir + "/" + style + " style"
89
- else :
92
+ elif re .search (r' X ' , newchords ):
93
+ # if there are rests
94
+ args .extend (["-d" , "2" , "-p" , "basic" ])
95
+ else :
96
+ # no rests
90
97
args .extend (["-d" , "4" , "-p" , "long" ])
91
98
args .extend (["-t" , "5" , "-B" ,
92
99
"--key" , f"{ key } " , "-N" , f"{ prefix } - { chords } " , "--output" ,
0 commit comments