# (Audio Analysis | redis ) == <3 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. **Two modes are available, so you might need to run two processes for full analysis.** ### Redis Keys and Contents Each **word in bold** is a key which you can query the redis server for. Ex: ``` $ redis-cli get spectrum_120 "[2.21, 0.56, 0.51, 0.32, 0.27, 0.21, 0.18, 0.17, 0.18, 0.23]" ``` **rms** * **Mode** spectrum * **Type** float number * **Length** scalar * **Meaning** Represents the root-mean-square -a mean value- for all frequencies between ```C0``` and ```C9```, e.g. between 12Hz and 8,372Hz. * **Use** A fairly basic information about the scene audio volume. * **Example** * ```"0.12"``` * The audio volume for the scene is pretty low. * It is obtained by averaging the RMS of every audio frame during the capture. **spectrum_10** * **Mode** spectrum * **Type** array of float numbers (0.0-10.0) * **Length** 10 * **Meaning** Represents the audio volume for the 10 **octaves** between ```C0``` and ```C9```, e.g. between 12Hz and 8,372Hz. * **Use** A simple and useful way to get a global idea of the sound landscape. * **Example** * ```"[2.21, 0.56, 0.51, 0.32, 0.27, 0.21, 0.18, 0.17, 0.18, 0.23]"``` * The audio volume for the `C4` octave is `spectrum_10[4]`. * That value being `0.27` is pretty low meaning almost no audio volume for that octave. * It is calculated by averaging the volume of the octave's notes, e.g. `C4, D4, D#4, E4, F4, F#4, G4, G#4, A4, A#4, B4`. **spectrum_120** * **Mode** spectrum * **Type** array of float numbers (0.0-10.0) * **Length** 120 * **Meaning** Represents the audio volume for the 120 **notes** between ```C0``` and ```C9```, e.g. between 12Hz and 8,372Hz. * **Use** More detailed than spectrum_10, it allows to find the standing out notes of the audio landscape. * **Example** * ```"[5.55, 2.61, 2.49, 1.79, 2.09, 4.35, 1.99, 1.57, 1.47, 0.77, 0.91, 0.89, 0.85, 0.56, 0.53, 0.73, 0.53, 0.46, 0.43, 0.44, 0.27, 0.45, 0.7, 0.81, 0.98, 0.7, 0.71, 0.6, 0.83, 0.51, 0.32, 0.31, 0.33, 0.24, 0.25, 0.33, 0.39, 0.43, 0.51, 0.28, 0.27, 0.25, 0.38, 0.25, 0.27, 0.3, 0.2, 0.27, 0.35, 0.29, 0.34, 0.3, 0.27, 0.27, 0.22, 0.21, 0.21, 0.29, 0.22, 0.28, 0.18, 0.19, 0.25, 0.26, 0.25, 0.24, 0.2, 0.21, 0.19, 0.18, 0.19, 0.17, 0.2, 0.17, 0.18, 0.17, 0.15, 0.17, 0.19, 0.18, 0.21, 0.16, 0.16, 0.18, 0.15, 0.13, 0.14, 0.16, 0.2, 0.17, 0.17, 0.2, 0.18, 0.16, 0.18, 0.15, 0.15, 0.16, 0.16, 0.19, 0.19, 0.19, 0.17, 0.18, 0.17, 0.19, 0.23, 0.23, 0.2, 0.23, 0.24, 0.36, 0.34, 0.23, 0.22, 0.2, 0.19, 0.18, 0.21, 0.21]"``` * The audio volume for the `C2` note is `spectrum_10[23]` (12x2 - 1). * That value being `0.81` is average meaning there is some audio volume for that octave. bpm * **Mode** bpm * **Type** * **Length** * **Meaning** Represents * **Use** * **Example** bpm_sample_interval * **Mode** bpm * **Type** * **Length** * **Meaning** Represents * **Example** bpm_delay * **Mode** bpm * **Type** * **Length** * **Meaning** Represents * **Example** beats * **Mode** bpm * **Type** * **Length** * **Meaning** Represents * **Example** ### Requirements and installation * python 2.7 * audio card * redis server #### Installation ```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 in Spectrum Mode ``` python redilysis.py -m spectrum ``` This is the default mode. It performs some frequency analysis (Fast Fourier Transform) to detect "energy" in the human audition bandwidths. It will record if there is sound and at which frequencies. It can run at sub-second frequency (100ms) with no problem. It reports realistic data: spectrum analysis is the easy part. ### Running in BPM Mode ``` python redilysis.py -m bpm -s 0.5 ``` This mode is experimental. It attempts to detect beats based on complex parameters.