Skip to content

Commit aefff77

Browse files
committed
tbish: better accent, step display
1 parent 30b65c6 commit aefff77

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

circuitpython/tbish/code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ def update_ui():
138138
if key.pressed:
139139
if sequencer.playing:
140140
sequencer.stop()
141+
tb_disp.stop()
141142
# testing out save/load params
142143
s = ParamSet.dump(param_set)
143144
print(s)
144145
ParamSet.load(s)
145146

146147
else:
148+
tb_disp.start()
147149
sequencer.start()
148150

149151
if touch_events := check_touch():

circuitpython/tbish/paramset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@ def apply_to_obj(self,o):
6060
setattr(o, self.objattr, self.val)
6161

6262
class ParamSet:
63+
"""ParamSet is a collection of Params that track normalized knob positions,
64+
especially for the case when there are fewer knobs than Params.
65+
"""
6366

6467
KNOB_PICKUP = 0
6568
KNOB_SCALE = 1
6669
KNOB_RELATIVE = 2
6770

68-
"""ParamSet is a collection of Params that track normalized knob positions,
69-
especially for the case when there are fewer knobs than Params.
70-
"""
71-
7271
def __init__(self, params, num_knobs, min_knob_change=0.05,
7372
knob_smooth=0.5, knob_mode = KNOB_PICKUP):
7473
self.params = params

circuitpython/tbish/tbish_sequencer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, tb, steps_per_beat=4, bpm=120, seqs=None):
1616
self.transpose = 0
1717
self.i = 0 # step number
1818
self.playing = True
19-
self.on_step_callback = None
19+
self.on_step_callback = None # callback is func(step, steps_per_beat, seq_len)
2020

2121
@property
2222
def steps_per_beat(self):
@@ -59,9 +59,10 @@ def update(self):
5959
if dt <= 0:
6060
self.next_step_time = now + self._secs_per_step + dt
6161
# add dt delta to attempt to make up for display hosing us
62-
62+
63+
seq_len = len(self.seqs[self.seq_num][0])
6364
if self.on_step_callback: # and (self.i % self._steps_per_beat)==0:
64-
self.on_step_callback(self.i, self.steps_per_beat)
65+
self.on_step_callback(self.i, self.steps_per_beat, seq_len)
6566

6667
if not self.playing:
6768
return
@@ -77,9 +78,9 @@ def update(self):
7778
self.gate_off_time = time.monotonic() + self._secs_per_step * self.gate_amount
7879

7980
#seq_num = int(param_set.param_for_name('seq').val)
80-
self.i = (self.i+1) % len(self.seqs[self.seq_num][0])
81+
self.i = (self.i+1) % seq_len
8182
self.midi_note = midi_note
8283

83-
print(self.i,"note: %d vel:%3d" % (midi_note, vel),
84+
print("step", self.i,"note: %d vel:%3d" % (midi_note, vel),
8485
int(self._secs_per_step*1000), int(dt*1000))
8586

circuitpython/tbish/tbish_synth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def add_audioeffects(self):
129129

130130
def note_on_step(self, midi_note, slide=False, accent=False):
131131
"""Trigger a note, with slide and accent"""
132-
print("note_on_step: %3d %1d %1d" % (midi_note, slide, accent), self.accent)
132+
print("note_on_step: %3d %1d %1d" % (midi_note, slide, accent))
133133
self.note_off(midi_note) # must do when in step mode
134134
attack_level = 0.8
135135
cutoff = self.cutoff
@@ -138,7 +138,8 @@ def note_on_step(self, midi_note, slide=False, accent=False):
138138
glide_time = 0.001 # minimal slide
139139
if accent:
140140
attack_level = min(1.0, attack_level + 0.5 * self.accent)
141-
cutoff = cutoff + 0.3 * self.accent # FIXME: verify
141+
cutoff = max(cutoff, 4000 * self.accent) # FIXME: verify
142+
print("\ncutoff:", cutoff, self.cutoff, "\n")
142143
#resonance *= 1.3 # FIXME: how to do
143144
envmod = min(1.0, envmod + 0.25 * self.accent)
144145
if slide:

circuitpython/tbish/tbish_ui.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,28 @@ def __init__(self, display, params={}): #, knobAval, knobBval):
3535
#for l in (self.textA, self.textB):
3636
self.append(l)
3737

38+
self.logo = label.Label(fnt, text="TBishBassSynth", color=cw, x=20,y=45)
39+
self.append(self.logo)
40+
3841
self.display.refresh()
3942

4043
def next_param_pair(self):
4144
self.curr_param_pair = (self.curr_param_pair+1) % self.num_param_pairs
4245

43-
def show_beat(self, step, steps_per_beat):
46+
def stop(self):
47+
pass
48+
49+
def start(self):
50+
pass
51+
52+
def show_beat(self, step, steps_per_beat, seq_len):
53+
self.stepspot.x = 5 + step * 6
54+
4455
# this doesn't work right but sorta works
45-
if step % steps_per_beat == 0 :
46-
self.stepspot.hidden = False
47-
else:
48-
self.stepspot.hidden = True
56+
#if step % steps_per_beat == 0 :
57+
# self.stepspot.hidden = False
58+
#else:
59+
# self.stepspot.hidden = True
4960

5061
def update_param_pairs(self):
5162
self.paramspot.x = 45 + 4*(self.curr_param_pair)

0 commit comments

Comments
 (0)