Skip to content

Commit bf9fa50

Browse files
committed
fixed note omission in chord names
1 parent a90394c commit bf9fa50

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

textbeat/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def peel_any(s, match, d=''):
9393
ct += 1
9494
else:
9595
break
96-
return (ct,orr(r,d))
96+
return (orr(r,d),ct)
9797

9898
def note_value(s): # turns dot note values (. and *) into frac
9999
if not s:

textbeat/player.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,28 +1017,42 @@ def run(self):
10171017
try:
10181018
# TODO: addchords
10191019

1020-
# TODO note removal (Maj7no5)
1020+
# TODO omit note (Maj7no5)
10211021
if chordname[-2:]=='no':
1022-
numberpart = tok[cut+1:]
1022+
# print(tok)
1023+
# print(cut)
1024+
cut += 1 # The 'o' of no
1025+
numberpart = tok[cut:]
1026+
# print(numberpart)
10231027
# second check will throws
1024-
if numberpart in '#b' or (int(numberpart) or True):
1028+
int_numberpart = None
1029+
try:
1030+
int_numberpart = int(numberpart)
1031+
except ValueError:
1032+
pass
1033+
if numberpart[0] in '#b' or int_numberpart!=None:
10251034
# if tok[]
10261035
prefix,ct = peel_any(tok[cut:],'#b')
1036+
# print('prefix', prefix)
1037+
# print('ct', ct)
10271038
if ct: cut += ct
10281039

1029-
num,ct = peel_uint(tok[cut+1:])
1040+
num,ct = peel_uint(tok[cut:])
10301041
if ct:
1031-
out(num)
10321042
cut += ct
1033-
cut -= 2 # remove "no"
1034-
chordname = chordname[:-2] # cut "no
1035-
nonotes.append(str(prefix)+str(num)) # ex: b5
1043+
# cut += 1 # remove "no"
1044+
chordname = chordname[:-2] # cut "no"
1045+
if prefix:
1046+
nonotes.append(str(prefix)+str(num)) # ex: b5
1047+
else:
1048+
nonotes.append(str(num)) # ex: b5
1049+
# print(nonotes)
10361050
break
10371051

10381052
# cut += 2
10391053

10401054
except IndexError:
1041-
log('chordname length ' + str(len(chordname)))
1055+
log('bad chordname index')
10421056
pass # chordname length
10431057
except ValueError:
10441058
log('bad cast ' + char)

textbeat/schedule.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self, ctx):
1414
# we'll need to reenter knowing this value
1515
self.passed = 0.0
1616
self.clock = 0.0
17+
self.last_clock = 0
1718
self.started = False
1819
# all note mute and play events should be marked skippable
1920
def pending(self):
@@ -30,6 +31,12 @@ def logic(self, t):
3031
processed = 0
3132
self.passed = 0
3233

34+
# if self.last_clock == 0:
35+
# self.last_clock = time.clock()
36+
# clock = time.clock()
37+
# self.dontsleep = (clock - self.last_clock)
38+
# self.last_clock = clock
39+
3340
# clock = time.clock()
3441
# if self.started:
3542
# tdelta = (clock - self.passed)
@@ -50,20 +57,20 @@ def logic(self, t):
5057
# sleep until next event
5158
if ev.t >= 0.0:
5259
if self.ctx.cansleep and self.ctx.startrow == -1:
53-
self.ctx.t += self.ctx.speed*t*(ev.t-self.passed)
54-
time.sleep(self.ctx.speed*t*(ev.t-self.passed))
60+
self.ctx.t += self.ctx.speed * t * (ev.t-self.passed)
61+
time.sleep(max(0,self.ctx.speed * t * (ev.t-self.passed)))
5562
ev.func(0)
5663
self.passed = ev.t # only inc if positive
5764
else:
5865
ev.func(0)
5966

6067
processed += 1
6168

62-
slp = t*(1.0-self.passed) # remaining time
69+
slp = t * (1.0 - self.passed) # remaining time
6370
if slp > 0.0:
6471
self.ctx.t += self.ctx.speed*slp
6572
if self.ctx.cansleep and self.ctx.startrow == -1:
66-
time.sleep(self.ctx.speed*slp)
73+
time.sleep(max(0,self.ctx.speed*slp))
6774
self.passed = 0.0
6875

6976
self.events = self.events[processed:]

0 commit comments

Comments
 (0)