2828import os
2929import mingus .core .scales as scales
3030import sys
31+ import re
3132
3233from src .chords2midi import c2m
3334from chords import *
6465# Test mode
6566if len (sys .argv ) > 1 and sys .argv [1 ] == '--test' :
6667 keys = [ ('C' , 'A' ) ]
67- styles = [ '' ]
68+ # styles = [ '' ]
6869
6970#
7071# Generate a single chord
@@ -82,11 +83,17 @@ def gen(dir, key, chords, prefix):
8283#
8384def genprog (dir , key , chords , prefix , style = '' ):
8485 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 (" " )
8689 if style != '' :
8790 args .extend (["-p" , style ])
8891 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
9097 args .extend (["-d" , "4" , "-p" , "long" ])
9198 args .extend (["-t" , "5" , "-B" ,
9299 "--key" , f"{ key } " , "-N" , f"{ prefix } - { chords } " , "--output" ,
0 commit comments