Skip to content

Commit 2ed2149

Browse files
committed
more changes from last commit
1 parent d245f18 commit 2ed2149

12 files changed

+280
-151
lines changed

decadence.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88
decadence.py song.dc play song
99
1010
Usage:
11-
decadence.py [--midi=<fn> | --ring | --follow | --csound | --supercollider] [-eftnpsrxh] [SONGNAME]
12-
decadence.py [+RANGE] [--ring || --follow | --csound | --supercollider] [-eftnpsrxh] [SONGNAME]
11+
decadence.py [--dev=<device> | --verbose | --midi=<fn> | --ring | --follow | --csound | --supercollider] [-eftnpsrxhv] [SONGNAME]
12+
decadence.py [+RANGE] [--dev=<device> | --midi=<fn> | --ring | --follow | --csound | --supercollider] [-eftnpsrxhv] [SONGNAME]
1313
decadence.py -c [COMMANDS ...]
1414
decadence.py -l [LINE_CONTENT ...]
1515
1616
Options:
1717
-h --help show this
1818
-v --verbose verbose
19-
-t --tempo=<bpm> (STUB) set tempo
20-
-x --grid=<g> (STUB) set grid
21-
-n --note=<n> (STUB) set grid using note value
22-
-s --speed=<s> (STUB) playback speed
19+
-t --tempo=<bpm> (STUB) set tempo [default: 120]
20+
-x --grid=<g> (STUB) set grid [default: 4]
21+
-n --note=<n> (STUB) set grid using note value [default: 1]
22+
-s --speed=<s> (STUB) playback speed [speed: 1.0]
2323
--dev=<device> output device, partial match
2424
-p --patch=<patch> (STUB) default midi patch, partial match
2525
-c execute commands sequentially
2626
-l execute commands simultaenously
27-
-r --remote (STUB) remote, keep alive as daemon
27+
-r --remote (STUB) remote/daemon mode, keep alive
2828
--ring don't mute midi on end
2929
--midi=<fn> generate midi file
3030
+<range> play from line or maker, for range use start:end
3131
-e --edit (STUB) open file in editor
3232
--vi (STUB) shell vi mode
3333
-h --transpose transpose (in half steps)
34-
--sustain sustain by default
34+
--sustain start with sustain enabled
3535
--numbers use note numbers in output
3636
--notenames use note names in output
37-
--flats prefer flats in output
37+
--flats prefer flats in output (default)
3838
--sharps prefer sharps in output
3939
--lint (STUB) analyze file
4040
--follow (old) print newlines every line, no output
@@ -79,7 +79,8 @@
7979
elif arg == '--note': dc.grid = float(val)/4.0
8080
elif arg == '--speed': dc.speed = float(val)
8181
elif arg == '--verbose': dc.showtext = True
82-
elif arg == '--dev': dc.portname = val
82+
elif arg == '--dev':
83+
dc.portname = val
8384
elif arg == '--vi': dc.vimode = True
8485
elif arg == '--patch':
8586
vals = val.split(',')
@@ -155,21 +156,27 @@
155156
print('No midi devices found.')
156157
sys.exit(1)
157158
dev = -1
159+
160+
# if dc.showtext:
161+
# for i in range(pygame.midi.get_count()):
162+
# print(pygame.midi.get_device_info(i))
163+
164+
DEVS = get_defs()['dev']
158165
for i in range(pygame.midi.get_count()):
159166
port = pygame.midi.get_device_info(i)
167+
# print(port)
160168
portname = port[1].decode('utf-8')
161-
# print(portname)
162-
devs = get_defs()['dev']
163169
if dc.portname:
164-
if portname.lower().startswith(dc.portname.lower()):
165-
dc.portname = portname
166-
dev = i
167-
break
168-
for name in devs:
169-
if portname.lower().startswith(name):
170+
if dc.portname.lower() in portname.lower():
170171
dc.portname = portname
171172
dev = i
172173
break
174+
else:
175+
for name in DEVS:
176+
if portname.lower().startswith(name):
177+
dc.portname = portname
178+
dev = i
179+
break
173180

174181
# dc.player = pygame.midi.Output(pygame.midi.get_default_output_id())
175182

def/default.yaml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,35 @@ scales:
1414
wholetone:
1515
human: 'whole tone'
1616
intervals: '222222'
17-
bebop:
17+
bebopmajor:
1818
intervals: '2212p121'
1919
pentatonic:
2020
intervals: '23223'
2121
modes:
2222
- yo
2323
- minorpentatonic
2424
- majorpentatonic
25-
- egyption
25+
- egyptian
2626
- mangong
2727
blues:
2828
intervals: '32p132'
2929
melodicminor:
3030
intervals: '2122221'
31+
modes:
32+
- melodicminor
33+
- assyrian
34+
- lydianaug
35+
- acoustic
36+
- melodicmajor
37+
- halfdim
38+
- altered
3139
harmonicminor:
3240
human: 'harmonic minor'
3341
intervals: '2122132'
3442
modes:
3543
- harmonicminor
3644
- locriann6
37-
- ionianaug#5
45+
- ionianaug
3846
- dorian#4
3947
- phyrigianminor
4048
- lydian#9
@@ -43,6 +51,7 @@ scales:
4351
human: 'harmonic major'
4452
intervals: '2122132'
4553
modes:
54+
- harmonicmajor
4655
- dorianb5
4756
- phyrgianb4
4857
- lydianb3
@@ -58,7 +67,7 @@ scales:
5867
- ultraphyrigian
5968
- hungarianminor
6069
- oriental
61-
- ionianaug
70+
- ionian#2#5
6271
- locrianbb3bb7
6372
neapolitan:
6473
intervals: '1222221'
@@ -123,13 +132,13 @@ chords:
123132

124133
ma: '3 5'
125134
mab5: '3 b5' # lyd
126-
ma#4: '3 #4 5' # lydadd5
135+
ma#4: '3 #4 5' # lyd5
127136
ma6: '3 5 6'
128137
ma69: '3 5 6 9'
129138
ma769: '3 5 6 7 9'
130139
m69: 'b3 5 6 9'
131140
ma7: '3 5 7'
132-
ma7#4: '3 #4 5 7' # lyd7add5
141+
ma7#4: '3 #4 5 7' # lyd75
133142
ma7b5: '3 b5 7' # lyd7
134143
ma7b9: '3 5 7 b9'
135144
ma7b13: '3 5 7 9 11 b13'
@@ -198,12 +207,25 @@ chords:
198207
dim7: 'b3 b5 bb7'
199208
dim9: 'b3 b5 bb7 9'
200209
dim11: 'b3 b5 bb7 9 11'
210+
dimma7: 'b3 b5 7'
201211
sus: '4 5'
202212
sus2: '2 5'
203213
mm7: 'b3 5 7'
204214
mm9: 'b3 5 7 9'
205215
pow: '5 8'
206216

217+
# tunings (1 = lowest)
218+
guitar: '4 b7 b10 12 15' # 1=E
219+
bass: '4 b7 b10' # 1=E
220+
bass5: '4 b7 b10 b13' # 1=B
221+
bass6: '4 b7 b10 b13 16' # 1=B
222+
223+
tune:
224+
guitar: 'E,'
225+
bass: 'E,,'
226+
bass5: 'B,,'
227+
bass6: 'B,,'
228+
207229
chord_alts:
208230
r: '1'
209231
aug: +
@@ -216,10 +238,7 @@ chord_alts:
216238
sus4: sus
217239
ma7: ma7
218240
ma9: ma9
219-
lyd: mab5
220-
lyd7: ma7b5
221-
plyd: ma#4
222-
lyd5: ma#4
241+
oma7: dimma7
223242
p: pow
224243
o: dim
225244
o7: dim7

def/dev.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
dev:
2+
- synth input port # linux qsynth
23
- timidity port 0
3-
- synth input port
44
- loopmidi
5+
- loopbe
56
- fluidsynth-midi
7+
- bassmidi driver (port a)
68
#- qjackctl
79
# helm will autoconnect
10+
- microsoft midi mapper # lowest preference

def/informal.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ chords:
2424
# replace: ma
2525
# add: '2'
2626

27+
chord_alts:
28+
lyd: mab5
29+
lyd7: ma7b5
30+
plyd: ma#4
31+
lyd5: ma#4
32+
lyd57: ma7#4
33+
plyd7: ma7#4
34+
lyd75: ma7#4
35+

src/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
import yaml, colorama, appdirs
99
from docopt import docopt
1010
import mido
11-
import pygame, pygame.midi
11+
with open(os.devnull, 'w') as devnull:
12+
# suppress pygame messages
13+
stdout = sys.stdout
14+
sys.stdout = devnull
15+
import pygame, pygame.midi
16+
sys.stdout = stdout
1217
from multiprocessing import Process,Pipe
1318
from prompt_toolkit import prompt
1419
from prompt_toolkit.styles import style_from_dict
@@ -33,8 +38,8 @@
3338
RANGE = 109
3439
OCTAVE_BASE = 5
3540
DRUM_WORDS = ['drum','drums','drumset','drumkit','percussion']
36-
CCHAR = ' <>=~.\'`,_&|!?*\"$(){}[]%@'
37-
CCHAR_START = 'T' # control chars
41+
CCHAR = ' <>=~.\'`,_&|!?*\"$(){}[]%@;'
42+
CCHAR_START = 'TV' # control chars
3843
PRINT = True
3944

4045
def cmp(a,b):

src/midi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
MIDI_CC = 0B1011
33
MIDI_PROGRAM = 0B1100
44
MIDI_PITCH = 0B1110
5+
MIDI_SUSTAIN_PEDAL = 0B1000
56
GM = get_defs()['patches']
67
GM_LOWER = [""]*len(GM)
78
for i in range(len(GM)): GM_LOWER[i] = GM[i].lower()

src/parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
def count_seq(seq, match=''):
44
if not seq:
55
return 0
6+
r = 0
67
if match == '':
7-
match = seq[0]
8-
seq = seq[1:]
9-
r = 1
8+
try:
9+
match = seq[0]
10+
except IndexError:
11+
return 0
1012
for c in seq:
1113
if c != match:
1214
break
1315
r+=1
1416
return r
1517

1618
def peel_uint(s, d=None):
17-
a,b = peel_uint_s(s,d)
19+
a,b = peel_uint_s(s,str(d))
1820
return (int(a),b)
1921

2022
# don't cast

0 commit comments

Comments
 (0)