Compare commits

..

2 Commits

Author SHA1 Message Date
alban
509164ad5b [enh] Adds dockers 2020-11-10 22:52:47 +01:00
alban
fcd15ef0ea [fix] fix missing content before inserting 2020-11-10 19:44:42 +01:00
4 changed files with 68 additions and 19 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM python:3.8-slim
LABEL name=redilysis version=0.1
WORKDIR /opt
RUN apt update
RUN apt install -y --no-install-recommends build-essential\
gcc\
pkg-config\
python-dev\
portaudio19-dev\
libsndfile1\
alsa-utils\
pulseaudio
RUN pip3 install librosa numpy pyaudio redis statistics
COPY . .
# Start the main process.
CMD ["python", "./redilysis.py", "-L"]

View File

@ -5,6 +5,45 @@ Redilysis sends audio analysis to a redis server.
The idea is to share a single audio analysis to many Visual Jockey filters, in our case for lasers. The idea is to share a single audio analysis to many Visual Jockey filters, in our case for lasers.
### Requirements and installation
You need:
* python 2.7 / 3+
* an audio card
* a redis server
#### Custom install on Linux
Note that it will almost certainly fail on Debian 9/10/11. This is due to mandatory LLVM's version when compiling the numba library for librosa.
```
apt install -y --no-install-recommends build-essential gcc pkg-config python-dev portaudio19-dev libsndfile1 pulseaudio
pip3 install librosa numpy pyaudio redis statistics
git clone https://git.interhacker.space/tmplab/redilysis.git
cd redilysis
python redilysis.py --help
```
You will need to have pulseaudio and a local redis server.
#### With Docker
Here is an example. It is a dirty method, but it works :)
```
docker run -it \
-e NUMBA_CACHE_DIR=/tmp \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/root/.config/pulse/cookie \
--group-add $(getent group audio | cut -d: -f3) \
protonphoton/redilysis:latest \
python redilysis.py -i 172.17.0.1
```
Two things here:
1. We are using here the `172.17.0.1` IP address to connect to the redis server. Change according to your needs.
2. The dirty part: Docker uses pulseaudio through your personal user and environment variables...
### Redis Keys and Contents for end users ### Redis Keys and Contents for end users
@ -136,21 +175,6 @@ Examples are given based on previous values for redis keys.
* etc. until you have ```f(i) > bpm_sample_interval``` * etc. until you have ```f(i) > bpm_sample_interval```
### Requirements and installation
* python 2.7
* audio card
* redis server
To be honest, in my experience installation on Debian 9,10,11 is a mess, due to mandatory LLVM's version when compiling the numba library for librosa.
```python
sudo apt install python-pyaudio python
git clone https://git.interhacker.space/tmplab/redilysis.git
cd redilysis
pip install -r requirements.txt
python redilysis.py --help
```
### Running redilysis: Common parameters ### Running redilysis: Common parameters
@ -233,4 +257,7 @@ It attempts to detect beats based on audio "jumps" in intensity and energy.
To correct a well-known error called the "octave error" where the detected tempo is twice/half or thrice/third of the real tempo, you can use the Min/Max BPM. When the calculated tempo is outside of the range, it will attempt to find more legitimate values. To correct a well-known error called the "octave error" where the detected tempo is twice/half or thrice/third of the real tempo, you can use the Min/Max BPM. When the calculated tempo is outside of the range, it will attempt to find more legitimate values.
# License
Released under the GPLv3 License

View File

@ -1,3 +1,4 @@
#! /usr/bin/python2.7
""" """
Sends live audio analysis to the terminal. Sends live audio analysis to the terminal.
@ -227,9 +228,9 @@ def m_spectrum(audio_data):
#debug( 'spectrum_120:{} '.format(spectrum_120)) #debug( 'spectrum_120:{} '.format(spectrum_120))
#debug( 'spectrum_10:{}'.format(spectrum_10)) #debug( 'spectrum_10:{}'.format(spectrum_10))
#debug( 'rms:{}'.format(rms_avg)) #debug( 'rms:{}'.format(rms_avg))
r.set( 'spectrum_120', json.dumps( spectrum_120 ) ) if len(spectrum_120): r.set( 'spectrum_120', json.dumps( spectrum_120 ) )
r.set( 'spectrum_10', json.dumps( spectrum_10 ) ) if len(spectrum_10): r.set( 'spectrum_10', json.dumps( spectrum_10 ) )
r.set( 'rms', "{}".format(rms_avg) ) if rms : r.set( 'rms', "{}".format(rms_avg) )
return True return True

View File

@ -1,3 +1,5 @@
librosa==0.7.2 librosa
numpy
pyaudio
redis redis
statistics statistics