I am attempting to play a wave file on the Funhouse using CircuitPython. I downloaded 'adafruit-circuitpython-bundle-7.x-mpy-20211024' and cannot find audioio in the lib folder.
When including import audioio I am told that the module doesn't exist. I figure I have to copy it into the directory structure or Funhouse before I can continue.
Is there something like audio.play(wavfile) or play_wav(wavfile)? Importing adafruit_funhouse in the REPL allowed me to find play_tone buried deeply using the dir() command.
play_tone works well enough to pester the other people in the room while I am testing code. :-D I would rather play a wav file to keep from being told to stop that noise.
Funhouse and audioio
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- kattni
- Posts: 132
- Joined: Fri Aug 18, 2017 6:33 pm
Re: Funhouse and audioio
Hello! You're looking for audiocore. https://circuitpython.readthedocs.io/en ... e.WaveFile
Hope this helps! Post here again if you're having issues figuring out how to use it.
Hope this helps! Post here again if you're having issues figuring out how to use it.
- fid
- Posts: 74
- Joined: Wed Sep 25, 2013 3:00 pm
Re: Funhouse and audioio
Hi kattni,
Thank you. I'll give it a go. The included example still asks for import audioio. Perhaps I can find what is needed in audiocore. I keep grinding away while the laundry is in the dryer.
Thank you. I'll give it a go. The included example still asks for import audioio. Perhaps I can find what is needed in audiocore. I keep grinding away while the laundry is in the dryer.
- kattni
- Posts: 132
- Joined: Fri Aug 18, 2017 6:33 pm
Re: Funhouse and audioio
I apologise - I have apparently steered you wrong. There isn't wav playback support on MagTag in CircuitPython. You're not missing anything, it's not there. It requires either audioio or audiopwmio.
I tried to do it myself, and failed. So, I ended up looking deeper into it to find this info.
There is an issue open on CircuitPython for it (https://github.com/adafruit/circuitpython/issues/3898). We tried to implement it but it was not a good experience - it was super glitchy. It hasn't been revisited yet.
I tried to do it myself, and failed. So, I ended up looking deeper into it to find this info.
There is an issue open on CircuitPython for it (https://github.com/adafruit/circuitpython/issues/3898). We tried to implement it but it was not a good experience - it was super glitchy. It hasn't been revisited yet.
- fid
- Posts: 74
- Joined: Wed Sep 25, 2013 3:00 pm
Re: Funhouse and audioio
Hi,
I am using Funhouse and now have gotten the speaker to pop and then pop again. It might be at the beginning of the wav and again at the end of the wav file.
I am scratching around with what goes in audiobusio.I2SOut(board.SCL, board.SPEAKER, board.SDA). The example says D1, D0 and D9. The class shows audiobusio.I2SOut(bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool). So I was guessing that it would be board.clock, board.something, and board.data.
If I use microcontroller.pin and see which GPIOs are available, I see GPIO zero through 46. I didn't use microcontroller because I am not sure what each pin does.
At least I am getting some sound out of the speaker.
Thank you for the help. I appreciate it.
I am using Funhouse and now have gotten the speaker to pop and then pop again. It might be at the beginning of the wav and again at the end of the wav file.
I am scratching around with what goes in audiobusio.I2SOut(board.SCL, board.SPEAKER, board.SDA). The example says D1, D0 and D9. The class shows audiobusio.I2SOut(bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool). So I was guessing that it would be board.clock, board.something, and board.data.
If I use microcontroller.pin and see which GPIOs are available, I see GPIO zero through 46. I didn't use microcontroller because I am not sure what each pin does.
At least I am getting some sound out of the speaker.
Code: Select all
import board
import audiocore
import audiobusio
import digitalio
# Required for CircuitPlayground Express
#speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
#speaker_enable.switch_to_output(value=True)
data = open("/sounds/intruder.wav", "rb")
wav = audiocore.WaveFile(data)
a = audiobusio.I2SOut(board.SCL, board.SPEAKER, board.SDA)
print("playing")
a.play(wav)
while a.playing:
pass
print("stopped")
Please be positive and constructive with your questions and comments.