OK - France won, but came last.
I was starting to get very annoyed with this little RPi beast. It would seem that a bad workman always blames his tools....
Here is the code:
Code: Select all
import alsaaudio as aa
from time import sleep
import RPi.GPIO as GPIO
#Define physical header pin numbers for 6 LEDs
#Set all pins as output
for pin in RPiPins:
# Set up audio
data_in = aa.PCM(aa.PCM_CAPTURE, aa.PCM_NONBLOCK)
# Read data from device
l,data = data_in.read()
# catch frame error
scaled_vol = max_vol//4680
for pin in range(0,6):
for pin in range(0,scaled_vol):
for pin in range(scaled_vol,6):
except audioop.error, e:
if e.message !="not a whole number of frames":
On and off, I spent two weeks trying to get this working in ALSA. It seemed my cheapo USB audio was not so bad after all, but needed modding.
Gave up on pyaudio. Too much baggage.
Alsaaudio on the other hand is low maintenance.
I will post all the pfaffing I did on my website in the next couple of days.
I have not tackled FFT just yet. This code gets over most buffer problems, but everything I do with floating point numbers locks the RPi. Working on it..........
Please query if you have any problems.
PS I have this running with my music as I type. It is soooooooo cool.
PPS Working on a guitar tuner for my daughter...
PPPS Working on a Stephen Hawking speech emulator for my son.
PPPPS Working on a Darth Vader voice for me.