#Yah, don't know what is wrong with the

1 messages ยท Page 1 of 1 (latest)

blissful python
#

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)

fresh epoch
#

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.

blissful python
#

moment

#

Adafruit Prop-Maker FeatherWing

#

Hmm...Didn't work, just outputing nothing now

fresh epoch
#

hrm. ok. i've got code for thepropmaker somewhere, i'll go look at what i did.

blissful python
#

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?

fresh epoch
#

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)
blissful python
#

oh these are all wavs, so no need to decode

fresh epoch
#

right. just posting what I actually used. ๐Ÿ™‚ will look over the code for lighting issues... 1 sec

blissful python
#

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.

fresh epoch
#

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?

blissful python
#

Hm. Can't swear

#

that takes some of the anger out.

#

Turns out a bloody wire was lose

fresh epoch
#

heh. been there, soldered that. ๐Ÿ˜‰

blissful python
#

now I just need to figuire out order of operations, so that the sound plays WHILE the light goes

#

now, the file plays, and when it's done, the lights spin

#

thank you for your help though!