-
1Step 1
These directions are written under the assumption that you will be following along with the original documentation - I purposefully leave out large chucks as they are already documented here:
https://github.com/scottlawsonbc/audio-reactive-led-strip under the heading "Installation for Raspberry Pi"
Install Raspbian on a SD card - I used Jesse Lite, which came with the 4.4 kernel.
On the first boot:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
and add a network profile:network={ ssid="MyWirelessAP" psk="MyWirelessPassword" }
then configure the hostname, and under Localisation Options, configure locale, language, and keyboard using raspi-config. Also, enable SSHsudo raspi-config
SSHd hangs after authenticating until updating its config: https://expresshosting.net/ssh-hanging-authentication/
sudo nano /etc/ssh/sshd_config
And add this to the bottomIPQoS 0x00
After a reboot, You should be able to SSH in and remotely perform the rest of the configuration
-
2Step 2
The Fe-Pi drivers are now included in the 4.9 kernel.
From https://github.com/PiSupply/PaPiRus/issues/82, to upgrade to 4.9:
sudo apt-get update sudo apt-get install rpi-update sudo rpi-update
After rebooting, disable the built-in sound chip and enable the Fe-Pi by editing /boot/config.txt
(http://fe-pi.com/p/building-a-new-kernel?_ga=2.186172393.1565192209.1496548161-1555104412.1496548161)
sudo nano /boot/config.txt
Disable the built-in sound by changing this line:dtparam=audio=on
to
dtparam=audio=off
Enable the Fe-Pi by adding these values to the bottom:
dtoverlay=fe-pi-audio dtoverlay=i2s-mmap
Restart again and then proceed to the next step
-
3Step 3
Install the Audio Reactive pre-requisite software as described at Scott Lawson's github site: https://github.com/scottlawsonbc/audio-reactive-led-strip
Skip the apt-get update if you updated in the prior step - no need to cause unneeded load on the Raspbian servers.
sudo apt-get install python-numpy python-scipy python-pyaudio
Install ws281x library:
sudo apt-get install build-essential python-dev git scons swig git clone https://github.com/jgarff/rpi_ws281x.git cd rpi_ws281x scons cd python sudo python setup.py install
The values given for the newly created /etc/asound.conf and edits to the /etc/asla.conf are from a system with two sound devices. In a prior step, the built-in sound was disabled, so the Fe-Pi is the only sound device that should be enabled, meaning that it should be device zero.
In this case, the /etc/asound.conf should look like this:
pcm.!default { type hw card 0 } ctl.!default { type hw card 0 }
and these two values in /usr/share/alsa/alsa.conf should equal 0, as show here:defaults.ctl.card 0 defaults.pcm.card 0
While you are editing the alsa.conf, also update the following from:
pcm.front cards.pcm.front pcm.rear cards.pcm.rear pcm.center_lfe cards.pcm.center_lfe pcm.side cards.pcm.side pcm.surround21 cards.pcm.surround21 pcm.surround40 cards.pcm.surround40 pcm.surround41 cards.pcm.surround41 pcm.surround50 cards.pcm.surround50 pcm.surround51 cards.pcm.surround51 pcm.surround71 cards.pcm.surround71 pcm.iec958 cards.pcm.iec958 pcm.hdmi cards.pcm.hdmi pcm.modem cards.pcm.modem pcm.phoneline cards.pcm.phoneline
To this:pcm.front cards.pcm.default pcm.rear cards.pcm.default pcm.center_lfe cards.pcm.default pcm.side cards.pcm.default pcm.surround21 cards.pcm.default pcm.surround40 cards.pcm.default pcm.surround41 cards.pcm.default pcm.surround50 cards.pcm.default pcm.surround51 cards.pcm.default pcm.surround71 cards.pcm.default pcm.iec958 cards.pcm.default pcm.hdmi cards.pcm.default pcm.modem cards.pcm.default pcm.phoneline cards.pcm.default
Test the strip:
Because the Fe-Pi is hardwired to use GPIO18, I am using GPIO12 to talk to the LED strip. The two figuration updates I made were to the LED_PIN and LED_COUNT.
Edit the ~/rpi_ws281x/python/examples/strandtest.py file
LED_COUNT = 102 LED_PIN = 12
try running the test:
cd ~/rpi_ws281x/python/examples sudo python strandtest.py
-
4Step 4
Verify sound, and adjust microphone levels.
Use alsamixer to make adjustments. I used this simple python script to adjust the microphone settings http://www.swharden.com/wp/2016-07-19-realtime-audio-visualization-in-python/
Create a new file called vuMeter.py
cd nano vuMeter.py
Paste the following into the file, save and exit.
import pyaudio import numpy as np CHUNK = 2**11 RATE = 44100 p=pyaudio.PyAudio() stream=p.open(format=pyaudio.paInt16,channels=1,rate=RATE,input=True, frames_per_buffer=CHUNK) for i in range(int(10*44100/1024)): #go for a few seconds data = np.fromstring(stream.read(CHUNK),dtype=np.int16) peak=np.average(np.abs(data))*2 bars="#"*int(50*peak/2**16) print("%04d %05d %s"%(i,peak,bars)) stream.stop_stream() stream.close() p.terminate()
The Fe-Pi has a black 1/8" TRRS port, while the microphone I have has a TRS connector, so I got a breakout cable for a cell phone that breaks the TRRS connector into two individual sound and microphone plugs.
The way I made adjustments was by opening two SSH sessions, one running the vuMeter script, while the other one had alsamixer running.
For my setup, all I had to do was increase the Mic level in the mixer
-
5Step 5
Download the code:
cd git clone https://github.com/scottlawsonbc/audio-reactive-led-strip.git cd audio-reactive-led-strip/python/ nano config.py
And make the following updates:
DEVICE = 'pi'
Scroll to the " if DEVICE == 'pi' " section and updateLED_PIN = 12
Disable GUIUSE_GUI = False
Turn off the FPS display
DISPLAY_FPS = False
Set strand length
N_PIZELS = 102
Drop the FPS to prevent audio buffering issues
FPS = 9
Try starting the script
cd ~/audio-reactive-led-strip/python/ sudo python visualization.py
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.