#Yah, don't know what is wrong with the
1 messages ยท Page 1 of 1 (latest)
import digitalio
import board
import neopixel
import audioio
import audiocore
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.color import BLUE
try:
from audiocore import WaveFile
except ImportError:
from audioio import WaveFile
try:
from audioio import AudioOut
except ImportError:
try:
from audiopwmio import PWMAudioOut as AudioOut
except ImportError:
pass
NUM_PIXELS = 60
NEOPIXEL_PIN = board.D5
POWER_PIN = board.D10
ONSWITCH_PIN = board.A1
wave_file = open("sounds/" "sound.wav", "rb")
wave = WaveFile(wave_file)
audio = AudioOut(board.A0)
strip = neopixel.NeoPixel(
NEOPIXEL_PIN, NUM_PIXELS, brightness=1, auto_write=False, pixel_order=neopixel.GRBW
)
strip.fill(0)
strip.show()
enable = digitalio.DigitalInOut(POWER_PIN)
enable.direction = digitalio.Direction.OUTPUT
enable.value = True
cometBlue = Comet(
strip,
speed=0.01,
color=(255, 0, 0),
tail_length=5,
ring=True,
bounce=False,
)
while True:
cometBlue.animate()
audio.play(wave)
which featherwing?
also, this line looks strange
wave_file = open("sounds/" "sound.wav", "rb")
my brain tells me it should be "sounds/sound.wav" ... i.e., without the " " in the middle.
but my brain could be wrong.
moment
Adafruit Prop-Maker FeatherWing
Hmm...Didn't work, just outputing nothing now
hrm. ok. i've got code for thepropmaker somewhere, i'll go look at what i did.
OK! I got audio output!
But now I can't get lights AND audio, something must be overlapping
SPDX-FileCopyrightText: 2019, 2023 Kattni Rembor for Adafruit Industries
SPDX-License-Identifier: MIT
"""Simple example to play a wave file"""
This example only works on Feathers that have analog audio out!
import digitalio
import board
import audiocore
try:
from audioio import AudioOut
except ImportError:
try:
from audiopwmio import PWMAudioOut as AudioOut
except ImportError:
pass # not always supported by every board!
WAV_FILE_NAME = "StreetChicken.wav" # Change to the name of your wav file!
enable = digitalio.DigitalInOut(board.D10)
enable.direction = digitalio.Direction.OUTPUT
enable.value = True
with AudioOut(board.A0) as audio: # Speaker connector
wave_file = open(WAV_FILE_NAME, "rb")
wave = audiocore.WaveFile(wave_file)
audio.play(wave)
while audio.playing:
pass
That outputs audio, no problem. But I can't use that code and the previous code. I think cause of the digitialio being named twice?
i've got this... had all my sounds stored as .mp3... it was in CP 7.something I think, so things may have changed a little.
import audiomp3
import audiopwmio
audio = audiopwmio.PWMAudioOut(board.A0)
def playmp3(file):
decoder = audiomp3.MP3Decoder(open("sounds/"+file, "rb"))
audio.play(decoder)
oh these are all wavs, so no need to decode
right. just posting what I actually used. ๐ will look over the code for lighting issues... 1 sec
thank you!
The code for lighting that works I have, does a fine job, but i can't get it to output audio and light.
i don't see anything that would conflict, at least as far as my knowledge goes. given that they're both background things, I wonder if there's a conflict. Which feather are you running?
Hm. Can't swear
that takes some of the anger out.
Turns out a bloody wire was lose
heh. been there, soldered that. ๐