0

METRO M0 EXPRESS WAVE FILES NOT PLAYING
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

METRO M0 EXPRESS WAVE FILES NOT PLAYING

by kgrove on Mon Mar 08, 2021 8:10 pm

So I've been going through the Audio Out lesson https://learn.adafruit.com/circuitpytho ... -audio-out and have been following every step they're telling me, even using the .wav file they provided, and all I'm getting is a quiet "pop" in my speaker.

I even went through the "Play a tone" sections before that. I was able to create a tone, so I know it's not the speaker.

Code: Select all | TOGGLE FULL SIZE
import time
import board
from audiocore import WaveFile

try:
    from audioio import AudioOut
except ImportError:
    try:
        from audiopwmio import PWMAudioOut as AudioOut
    except ImportError:
        pass

wave_file = open("StreetChicken.wav", "rb")
wave = WaveFile(wave_file)
audio = AudioOut(board.A0)

while True:
    audio.play(wave)


I omitted the pause part of the lesson in this code, but I've tried both ways; still just the pop. Not sure what is wrong.

This lesson works, and creates a tone:
Code: Select all | TOGGLE FULL SIZE
import time
import array
import math
import board
from audiocore import RawSample
 
try:
    from audioio import AudioOut
except ImportError:
    try:
        from audiopwmio import PWMAudioOut as AudioOut
    except ImportError:
        pass  # not always supported by every board!
 
tone_volume = 0.1  # Increase this to increase the volume of the tone.
frequency = 440  # Set this to the Hz of the tone you want to generate.
length = 8000 // frequency
sine_wave = array.array("H", [0] * length)
for i in range(length):
    sine_wave[i] = int((1 + math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 - 1))
 
audio = AudioOut(board.A0)
sine_wave_sample = RawSample(sine_wave)


while True:
    audio.play(sine_wave_sample)


Any suggestions?

kgrove
 
Posts: 44
Joined: Wed Feb 17, 2021 4:51 pm

Re: METRO M0 EXPRESS WAVE FILES NOT PLAYING

by mikeysklar on Tue Mar 09, 2021 6:19 pm

I suspect you have the right code in place. As the examples look just like ours and you have a working tone.

This is probably going to come down to library release versus circuitpython release compatibility issue. Which version of each are you running?

Can you post a photo of your wiring so we can confirm it looks like the example:

wiring.jpg
wiring.jpg (294.08 KiB) Viewed 93 times

mikeysklar
 
Posts: 4523
Joined: Mon Aug 01, 2016 8:10 pm

Re: METRO M0 EXPRESS WAVE FILES NOT PLAYING

by kgrove on Tue Mar 16, 2021 3:21 pm

I have Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit Grand Central M4 Express with samd51p20 and the TXT file attached as my libraries.

As you might have noticed, I am now using a Grand Central M4 Express. I tried setting up the audio the same way (see image for ref). I
started with the sine wave generator and got a sputtering of sound, then it stopped.
Attachments
VERSIONS.txt
(20.95 KiB) Downloaded 2 times
IMG_1993.jpeg
IMG_1993.jpeg (798.22 KiB) Viewed 77 times

kgrove
 
Posts: 44
Joined: Wed Feb 17, 2021 4:51 pm

Re: METRO M0 EXPRESS WAVE FILES NOT PLAYING

by kgrove on Tue Mar 16, 2021 5:59 pm

Actually I got it working. I didn't have a capacitor hooked up.

Is there any way to boost the signal beyond the highest level it is putting out?

kgrove
 
Posts: 44
Joined: Wed Feb 17, 2021 4:51 pm

Re: METRO M0 EXPRESS WAVE FILES NOT PLAYING

by mikeysklar on Wed Mar 17, 2021 1:12 pm

tone_volume in your code example is set to 0.1 by default so you can increase that up to 1 which will be painfully loud.

are you able to use the potentiometer to adjust the volume of the WavFile while playing?

mikeysklar
 
Posts: 4523
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.