Skip to content

Commit ad28ef9

Browse files
committed
fix vectorio tip
1 parent bfab739 commit ad28ef9

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,9 @@ display = board.DISPLAY # built-in display
723723
maingroup = displayio.Group() # a main group that holds everything
724724
display.show(maingroup)
725725

726-
background = vectorio.Rectangle(pixel_shader=mypal, width=display.width, height=display.height, 0,0)
726+
mypal = displayio.Palette(1)
727+
mypal[0] = 0x999900
728+
background = vectorio.Rectangle(pixel_shader=mypal, width=display.width, height=display.height, x=0, y=0)
727729
maingroup.append(background)
728730
```
729731

larger-tricks/chikkenplayer.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# chikkenplayer.py - StreetChicken Remixer by todbot
22
# 21 Mar 2021 - @todbot / Tod Kurt, from @jedgarpark idea
3-
43
#
54
import time
65
import board
@@ -41,23 +40,25 @@
4140

4241
print("chikkenplayer ready")
4342

44-
voice_num = None # which loop level to change if any
45-
in_pickup = False # in knob pickup mode or not
43+
edit_voices = [False] * len(wav_files)
44+
pickup_voices = [False] * len(wav_files)
4645

4746
while True:
4847
event = keys.events.get()
4948
if event:
49+
voice_num = event.key_number
5050
if event.pressed:
51-
voice_num = event.key_number
51+
edit_voices[voice_num] = True
5252
if event.released:
53-
voice_num = None
54-
in_pickup = False
53+
edit_voices[voice_num] = False
54+
pickup_voices[voice_num] = False
5555

56-
if voice_num is not None:
56+
for i in range(len(wav_files)):
5757
new_val = knob.value
58-
if in_pickup: # if in knob pickup mode, knob controls level
59-
mixer.voice[voice_num].level = new_val / 65535 # convert to 0-1.0
60-
else:
61-
old_val = int(mixer.voice[voice_num].level * 65535) # convert 0-1 to 0-65535
62-
if abs(new_val - old_val) < 100: # if we get close to old value,
63-
in_pickup = True # flip the pickup switch until key release
58+
if edit_voices[i]: # only edit voices with pressed buttons
59+
if pickup_voices[i]: # have we crossed old value?
60+
mixer.voice[i].level = new_val / 65535 # convert to 0-1.0
61+
else:
62+
old_val = int(mixer.voice[i].level * 65535) # convert 0-1 to 0-65535
63+
if abs(new_val - old_val) < 100: # if we get close to old value,
64+
pickup_voices[i] = True # flip the pickup switch until key release

larger-tricks/pidaydrummachine.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import audiomixer
1010
from audiopwmio import PWMAudioOut as AudioOut
1111

12+
time.sleep(3) # wait a bit to reduce noise from CIRCUITPY access
13+
1214
wav_files = (
1315
"wav/544413_punch_22k16b.wav",
1416
"wav/544682_snare_22k16b.wav",
@@ -21,8 +23,6 @@
2123
keys = keypad.Keys((board.GP16, board.GP17, board.GP18, board.GP19, board.GP20),
2224
value_when_pressed=False, pull=True)
2325

24-
time.sleep(3) # wait a bit to reduce noise from CIRCUITPY access
25-
2626
audio = AudioOut(board.GP15)
2727
mixer = audiomixer.Mixer(voice_count=len(wav_files), sample_rate=22050, channel_count=1,
2828
bits_per_sample=16, samples_signed=True)
@@ -33,3 +33,8 @@
3333
if event and event.pressed:
3434
n = event.key_number
3535
mixer.voice[n].play( audiocore.WaveFile(open(wav_files[n],"rb")) )
36+
37+
38+
39+
40+

0 commit comments

Comments
 (0)