diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3abf3e9..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -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"] diff --git a/README.md b/README.md index 35156de..7fc35b1 100644 --- a/README.md +++ b/README.md @@ -5,45 +5,6 @@ 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. -### 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 @@ -175,6 +136,21 @@ Examples are given based on previous values for redis keys. * 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 @@ -257,7 +233,4 @@ 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. -# License - -Released under the GPLv3 License diff --git a/redilysis.py b/redilysis.py index f9dde74..626888c 100755 --- a/redilysis.py +++ b/redilysis.py @@ -1,4 +1,3 @@ -#! /usr/bin/python2.7 """ Sends live audio analysis to the terminal. @@ -228,9 +227,9 @@ def m_spectrum(audio_data): #debug( 'spectrum_120:{} '.format(spectrum_120)) #debug( 'spectrum_10:{}'.format(spectrum_10)) #debug( 'rms:{}'.format(rms_avg)) - if len(spectrum_120): r.set( 'spectrum_120', json.dumps( spectrum_120 ) ) - if len(spectrum_10): r.set( 'spectrum_10', json.dumps( spectrum_10 ) ) - if rms : r.set( 'rms', "{}".format(rms_avg) ) + r.set( 'spectrum_120', json.dumps( spectrum_120 ) ) + r.set( 'spectrum_10', json.dumps( spectrum_10 ) ) + r.set( 'rms', "{}".format(rms_avg) ) return True diff --git a/requirements.txt b/requirements.txt index 2cb0cdd..792ecf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,3 @@ -librosa -numpy -pyaudio +librosa==0.7.2 redis statistics