(Outdated) Manual installation - TobKra96/music_led_strip_control GitHub Wiki

This is the manual installation, which was replaced by the automatic installation script.

DO NOT USE IT!

  1. Manual Setup
    1. Download and install dependencies
    2. Setup Microphone
    3. Install Music LED Strip Controller (MLSC)
    4. Add MLSC to the autostart.

Manual Setup

Note: You do not need to do the Manual Setup if you already used the Automatic Setup Script.

Download and install dependencies

  1. Update packages:
sudo apt-get update
sudo apt-get upgrade
  1. Install Audio Driver
sudo apt-get install libatlas-base-dev portaudio19-dev
  1. Install Python
sudo apt-get install python3
  1. Install required Python modules:

Install Pip:

sudo apt-get install python3-pip

Upgrade Pip to the newest version:

pip3 install --upgrade pip

Install Numpy (Offers a lot of mathematical functions and matrix manipulation. This version is required because 1.16 has a memory leak when using queues.):

sudo pip3 install -I numpy==1.17.0

Install Cython (Required to build the rpi_ws281x. module):

sudo pip3 install cython

Install Scipy (Offers a gaussian filter.):

sudo pip3 install scipy==1.3.0

Install Flask (The web server component.):

sudo pip3 install flask

Install PyAudio (Offers the audio input stream, which will be processed.):

sudo pip3 install pyaudio

Install coloredlogs:

sudo pip3 install coloredlogs

Install Flask_Login:

sudo pip3 install Flask_Login

Install Jinja2:

sudo pip3 install Jinja2

Install environs:

sudo pip3 install environs

Install waitress:

sudo pip3 install waitress
  1. Build and install the rpi_ws281x module.

Select a place where you want to build the module. /share is used by default.

Create a new directory:

sudo mkdir /share

Navigate to the directory:

cd /share

Install Git:

sudo apt-get install git

Install the dependencies for rpi_ws281x module:

sudo apt-get install build-essential python3-dev scons swig

Ensure you are in the /share directory and clone the repository:

sudo git clone https://github.com/jgarff/rpi_ws281x.git

Move inside the cloned repository and build the project:

cd rpi_ws281x
sudo scons

The Terminal output should look like this:

image

Move inside the python directory and install the python module:

cd python
sudo python3 setup.py install

Setup microphone

Plug-in your USB microphone.

Create/edit /etc/asound.conf using Nano or any other preferred editor:

sudo nano /etc/asound.conf

Write the following text to /etc/asound.conf:

pcm.!default {
    type hw
    card 1
}
ctl.!default {
    type hw
    card 1
}

In Nano, you can save changes by pressing "Ctrl+X", "Y" and "Enter".

Set the USB device to be the default device by editing /usr/share/alsa/alsa.conf:

sudo nano /usr/share/alsa/alsa.conf

Enable the Default Card:

Change

defaults.ctl.card 0
defaults.pcm.card 0

To

defaults.ctl.card 1
defaults.pcm.card 1

Disable unused interfaces:

Change

#
#  PCM interface
#

# redirect to load-on-demand extended pcm definitions
pcm.cards cards.pcm

pcm.default cards.pcm.default
pcm.sysdefault cards.pcm.default
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.spdif iec958
pcm.hdmi cards.pcm.hdmi
pcm.dmix cards.pcm.dmix
pcm.dsnoop cards.pcm.dsnoop
pcm.modem cards.pcm.modem
pcm.phoneline cards.pcm.phoneline

To

#
#  PCM interface
#

# redirect to load-on-demand extended pcm definitions
pcm.cards cards.pcm

pcm.default cards.pcm.default
pcm.sysdefault cards.pcm.default
#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.spdif iec958
#pcm.hdmi cards.pcm.hdmi
#pcm.dmix cards.pcm.dmix
#pcm.dsnoop cards.pcm.dsnoop
#pcm.modem cards.pcm.modem
#pcm.phoneline cards.pcm.phoneline

Reboot:

sudo reboot

Install Music LED Strip Controller (MLSC)

Navigate to the /share directory:

cd /share

Clone the repository:

sudo git clone https://github.com/TobKra96/music_led_strip_control.git

Add MLSC to the autostart.

Using a systemd service, each time Raspberry Pi reboots, MLSC will run.

Stop MLSC if it is still running.

  1. Create a file mlsc.service in /etc/systemd/system/:
sudo touch /etc/systemd/system/mlsc.service
  1. Add the following to the created mlsc.service file:
[Unit]
Description=Music LED Strip Control
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/share/music_led_strip_control/server
ExecStart=python3 main.py
Restart=on-abnormal
RestartSec=10
KillMode=control-group

[Install]
WantedBy=multi-user.target
  1. Run the following commands to enable and start MLSC:
sudo systemctl daemon-reload

sudo systemctl enable mlsc.service

sudo systemctl start mlsc.service
  1. Reboot:
sudo reboot
  1. Check if the service is running:
sudo systemctl status mlsc.service

MLSC should now restart on reboot.

To remove the service from autostart, run the following commands:

sudo systemctl stop mlsc.service

sudo systemctl disable mlsc.service

Note: The WorkingDirectory specified in the service is /share. If you did not change anything during the installation, the service should work without issues.