Skip to content

Commit 40526f5

Browse files
committed
You can add two spaces in a progression definition to insert a rest
1 parent 25a0984 commit 40526f5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gen.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import os
2929
import mingus.core.scales as scales
3030
import sys
31+
import re
3132

3233
from src.chords2midi import c2m
3334
from chords import *
@@ -64,7 +65,7 @@
6465
# Test mode
6566
if 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
#
8384
def 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

Comments
 (0)