Skip to content

Commit 82adc21

Browse files
committed
fix audiomixer demo for SAMD51
1 parent 2ba7ed0 commit 82adc21

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

larger-tricks/audiomixer_demo.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# audiomixer_demo.py -- show how to fade up and down playing loops
2-
# note this causes glitches and crashes on at least RP2040
2+
# note this causes glitches and crashes on RP2040
33
# 9 Feb 2022 - @todbot / Tod Kurt
44

55
import time
66
import board
77
import audiocore
88
import audiomixer
9-
from audiopwmio import PWMAudioOut as AudioOut
9+
#from audiopwmio import PWMAudioOut as AudioOut # for RP2040 etc
10+
from audioio import AudioOut as AudioOut # for SAMD51 etc
1011

1112
num_voices = 2
1213

13-
# audio pin is RX (pin 1) (RP2040 GPIO1)
14-
audio = AudioOut(board.RX)
14+
# audio pin is almost any pin on RP2040, let's do RX (pin 1) (RP2040 GPIO1)
15+
# audio pin is A0 on SAMD51 (Trelllis M4, Itsy M4, etc)
16+
audio = AudioOut(board.A0)
1517
mixer = audiomixer.Mixer(voice_count=num_voices, sample_rate=22050, channel_count=1,
1618
bits_per_sample=16, samples_signed=True)
1719
# attach mixer to audio playback
@@ -34,4 +36,3 @@
3436
mixer.voice[1].level = min(max(mixer.voice[1].level + 0.01, 0), 1)
3537
mixer.voice[0].level = min(max(mixer.voice[0].level - 0.01, 0), 1)
3638
time.sleep(0.1)
37-

0 commit comments

Comments
 (0)