2016-10-14 07:27:45 +02:00
|
|
|
"""Settings for audio reactive LED strip"""
|
2016-10-23 06:55:22 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import division
|
2016-10-14 07:27:45 +02:00
|
|
|
import os
|
|
|
|
|
2016-11-08 02:43:31 +01:00
|
|
|
N_PIXELS = 60
|
2016-10-14 07:27:45 +02:00
|
|
|
"""Number of pixels in the LED strip (must match ESP8266 firmware)"""
|
|
|
|
|
2016-11-13 10:08:51 +01:00
|
|
|
GAMMA_TABLE_PATH = os.path.join(os.path.dirname(__file__), 'gamma_table.npy')
|
2016-10-14 07:27:45 +02:00
|
|
|
"""Location of the gamma correction table"""
|
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
UDP_IP = '192.168.137.150'
|
2016-10-14 07:27:45 +02:00
|
|
|
"""IP address of the ESP8266"""
|
|
|
|
|
|
|
|
UDP_PORT = 7777
|
|
|
|
"""Port number used for socket communication between Python and ESP8266"""
|
|
|
|
|
2016-11-13 10:08:51 +01:00
|
|
|
MIC_RATE = 48000
|
2016-10-14 07:27:45 +02:00
|
|
|
"""Sampling frequency of the microphone in Hz"""
|
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
FPS = 60
|
|
|
|
"""Desired refresh rate of the visualization (frames per second)
|
2016-10-14 07:27:45 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
FPS indicates the desired refresh rate, or frames-per-second, of the audio
|
|
|
|
visualization. The actual refresh rate may be lower if the computer cannot keep
|
|
|
|
up with desired FPS value.
|
2016-10-14 07:27:45 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
Higher framerates improve "responsiveness" and reduce the latency of the
|
|
|
|
visualization but are more computationally expensive.
|
|
|
|
|
|
|
|
Low framerates are less computationally expensive, but the visualization may
|
|
|
|
appear "sluggish" or out of sync with the audio being played if it is too low.
|
|
|
|
|
|
|
|
The FPS should not exceed the maximum refresh rate of the LED strip, which
|
|
|
|
depends on how long the LED strip is.
|
2016-10-14 07:27:45 +02:00
|
|
|
"""
|
2016-11-22 05:08:35 +01:00
|
|
|
_max_led_FPS = int(((N_PIXELS * 30e-6) + 50e-6)**-1.0)
|
|
|
|
assert FPS <= _max_led_FPS, 'FPS must be <= {}'.format(_max_led_FPS)
|
2016-10-14 07:27:45 +02:00
|
|
|
|
2016-11-13 10:08:51 +01:00
|
|
|
MIN_FREQUENCY = 200
|
2016-11-22 05:08:35 +01:00
|
|
|
"""Frequencies below this value will be removed during audio processing"""
|
|
|
|
|
|
|
|
MAX_FREQUENCY = 12000
|
|
|
|
"""Frequencies above this value will be removed during audio processing"""
|
2016-10-25 01:42:03 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
N_FFT_BINS = 30
|
|
|
|
"""Number of frequency bins to use when transforming audio to frequency domain
|
2016-10-25 01:42:03 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
Fast Fourier transforms are used to transform time-domain audio data to the
|
|
|
|
frequency domain. The frequencies present in the audio signal are assigned
|
|
|
|
to their respective frequency bins. This value indicates the number of
|
|
|
|
frequency bins to use.
|
2016-10-14 07:27:45 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
A small number of bins reduces the frequency resolution of the visualization
|
|
|
|
but improves amplitude resolution. The opposite is true when using a large
|
|
|
|
number of bins.
|
2016-10-14 07:27:45 +02:00
|
|
|
|
2016-11-22 05:08:35 +01:00
|
|
|
There is no point using more bins than there are pixels on the LED strip.
|
2016-10-14 07:27:45 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
GAMMA_CORRECTION = True
|
2016-10-23 06:55:22 +02:00
|
|
|
"""Whether to correct LED brightness for nonlinear brightness perception"""
|
|
|
|
|
2016-11-13 10:08:51 +01:00
|
|
|
N_ROLLING_HISTORY = 2
|
2016-11-08 02:43:31 +01:00
|
|
|
"""Number of past audio frames to include in the rolling window"""
|
2016-10-23 06:55:22 +02:00
|
|
|
|
2016-11-08 02:43:31 +01:00
|
|
|
MIN_VOLUME_THRESHOLD = 1e-7
|
2016-12-25 06:54:06 +01:00
|
|
|
"""No music visualization displayed if recorded audio volume below threshold"""
|