0

No audio from CircuitPlayground Express?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

No audio from CircuitPlayground Express?

by eat_sleep_code on Fri Apr 06, 2018 2:14 pm

I am following John Park's guide https://learn.adafruit.com/spy-theme-pl ... cuitpython … but trying to use a CircuitPlayground Express instead of the Gemma MO.

The first example runs but produces no sound?

This is my code...

Code: Select all | TOGGLE FULL SIZE
import adafruit_rtttl
import board

print("starting...")
adafruit_rtttl.play(board.A2, "Bond:d=4,o=5,b=320:c,8d,8d,d,2d,c,c,c,c,8d#,8d#,2d#,d,d,d,c,8d,8d,d,2d,c,c,c,c,8d#,8d#,d#,2d#,d,c#,c,c6,1b.,g,f,1g.")
print("ending...")



This is my REPL output...

Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
starting...
ending...

Press any key to enter the REPL. Use CTRL-D to reload.


There is a pause between starting and ending so it acts like it is actually playing something. Perhaps the neighbor's dog hears it but I sure don't.

eat_sleep_code
 
Posts: 20
Joined: Sat Dec 30, 2017 1:30 am

Re: No audio from CircuitPlayground Express?

by johnpark on Fri Apr 06, 2018 4:53 pm

Ah, I understand better now what you're doing. There is are a few small differences to do this on the Circuit Playground Express vs. the Gemma M0 example in the guide. We want to pick pin A0, which is the pin that runs the on-board speaker. We also need to enable that pin to act as the speaker (it can do multiple things, so isn't running as speaker pin all the time by default.

Here's the code that'll play rtttl songs on the Circuit Playground Express (as a lovely sine wave, incidentally, instead of the square wave output over PWM to a piezo. It sounds lovely!)
Code: Select all | TOGGLE FULL SIZE
import board
from digitalio import DigitalInOut, Direction
import adafruit_rtttl
spkrenable = DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = Direction.OUTPUT
spkrenable.value = True
adafruit_rtttl.play(board.A0, "Bond:d=4,o=5,b=320:c,8d,8d,d,2d,c,c,c,c,8d#,8d#,2d#,d,d,d,c,8d,8d,d,2d,c,c,c,c,8d#,8d#,d#,2d#,d,c#,c,c6,1b.,g,f,1g.")
print("ending...")


Have fun!
-John

johnpark
 
Posts: 68
Joined: Wed Mar 25, 2009 2:15 pm

Re: No audio from CircuitPlayground Express?

by eat_sleep_code on Fri Apr 06, 2018 10:23 pm

Oddly, using your new snippet, I get...

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "main.py", line 7, in <module>
  File "adafruit_rtttl.py", line 177, in play
ValueError: Invalid pin

eat_sleep_code
 
Posts: 20
Joined: Sat Dec 30, 2017 1:30 am

Re: No audio from CircuitPlayground Express?

by johnpark on Sat Apr 07, 2018 6:56 pm

In case these aren't the versions you're using, please try that code again using the 2.2.4 release version of CircuitPython for Circuit Playground Express: https://github.com/adafruit/circuitpython/releases/tag/2.2.4
and the 2.1.1 release version of rtttl: https://github.com/adafruit/Adafruit_CircuitPython_RTTTL/releases

johnpark
 
Posts: 68
Joined: Wed Mar 25, 2009 2:15 pm

Re: No audio from CircuitPlayground Express?

by eat_sleep_code on Sun Apr 08, 2018 10:57 pm

Just refreshed with the referenced files and am getting the same error. :/

eat_sleep_code
 
Posts: 20
Joined: Sat Dec 30, 2017 1:30 am

Re: No audio from CircuitPlayground Express?

by johnpark on Sun Apr 08, 2018 11:04 pm

Would you double check that you don't have two different rtttl libraries on your Circuit Playground Express? In the CIRCUITPY/lib directory you should only see the one adafruit_rtttl.mpy file. Also, check that there isn't one living outside the lib folder.

I ask just in case you had a previous version in there named adafruit_rtttl.py

I can't recall if this is one case where a prior version existed that wasn't an .mpy, but I've had that sort of thing happen before when I'm trying out new libraries and forget to remove them when the release version comes out.

Another way to be extra sure is to delete the entire /lib folder and contents and then download and install the release library bundle. https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases

johnpark
 
Posts: 68
Joined: Wed Mar 25, 2009 2:15 pm

Re: No audio from CircuitPlayground Express?

by eat_sleep_code on Tue Apr 10, 2018 7:34 pm

Ok, I basically purged everything and installed the 2.2.3 libraries and now I have sound. Ok, now to figure out some new songs. :-)

eat_sleep_code
 
Posts: 20
Joined: Sat Dec 30, 2017 1:30 am

Re: No audio from CircuitPlayground Express?

by johnpark on Tue Apr 10, 2018 8:02 pm

Oh, good! So glad that did the trick. Enjoy composing, we'd love to hear what you create!

Best,
John

johnpark
 
Posts: 68
Joined: Wed Mar 25, 2009 2:15 pm

Please be positive and constructive with your questions and comments.