Skip to content

Commit 7f25441

Browse files
committed
added chikkenplayer
1 parent 0bda445 commit 7f25441

File tree

7 files changed

+50
-0
lines changed

7 files changed

+50
-0
lines changed

larger-tricks/chikkenplayer.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# chikkenplayer.py - StreetChicken Remixer by todbot
2+
# 21 Mar 2021 - @todbot / Tod Kurt, from @jedgarpark idea
3+
#
4+
import time
5+
import board
6+
import analogio
7+
import keypad
8+
import audiocore
9+
import audiomixer
10+
from audiopwmio import PWMAudioOut as AudioOut
11+
12+
time.sleep(5) # wait a bit to reduce noise from CIRCUITPY access
13+
14+
wav_files = (
15+
"wav/chikken1_161_22k16b.wav", # slowed down & hacked StreetChicken
16+
"wav/chikken2_161_22k16b.wav", # fat distorty bassline
17+
"wav/chikken3_161_22k16b.wav", # reversed & slowed & warped StreetChicken
18+
"wav/chikken4_161_22k16b.wav", # 808 drum pattern (kick + snare only)
19+
"wav/chikken5_161_22k16b.wav", # chunky guitar power chords
20+
"wav/chikken6_161_22k16b.wav", # ethereal space arpeggios
21+
)
22+
23+
# knob to adjust loop levels
24+
knob = analogio.AnalogIn(board.A3)
25+
# what keys to use
26+
keys = keypad.Keys((board.RX, board.SCK, board.MISO, board.MOSI, board.SCL, board.SDA),
27+
value_when_pressed=False, pull=True)
28+
# audio output
29+
audio = AudioOut(board.TX) # board.A0 for SAMD chips, any for rp2040 pico
30+
mixer = audiomixer.Mixer(voice_count=len(wav_files), sample_rate=22050, channel_count=1,
31+
bits_per_sample=16, samples_signed=True)
32+
audio.play(mixer) # attach mixer to audio playback, play with mixer.voice[n].play()
33+
34+
# start loops playing, but silently
35+
for i in range(len(wav_files)):
36+
wave = audiocore.WaveFile(open(wav_files[i],"rb"))
37+
mixer.voice[i].play(wave, loop=True)
38+
mixer.voice[i].level = 0.0
39+
40+
print("chikenplayer ready")
41+
voice_num = None # which loop level to change if any
42+
while True:
43+
event = keys.events.get()
44+
if event:
45+
if event.pressed: voice_num = event.key_number
46+
if event.released: voice_num = None
47+
if voice_num is not None: # while voice key is pressed, adjust level
48+
val = knob.value
49+
mixer.voice[voice_num].level = val / 65535 # convert to 0-1.0
50+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)