7507cc0be2
Updated with a fresh gui, customisable settings, more effects, and a lot more class.
123 lines
4.5 KiB
Python
123 lines
4.5 KiB
Python
"""Settings for audio reactive LED strip"""
|
|
from __future__ import print_function
|
|
from __future__ import division
|
|
import os
|
|
|
|
DEVICE = 'stripless'
|
|
"""Device used to control LED strip. Must be 'pi', 'esp8266' or 'blinkstick'
|
|
|
|
'esp8266' means that you are using an ESP8266 module to control the LED strip
|
|
and commands will be sent to the ESP8266 over WiFi.
|
|
|
|
'pi' means that you are using a Raspberry Pi as a standalone unit to process
|
|
audio input and control the LED strip directly.
|
|
|
|
'blinkstick' means that a BlinkstickPro is connected to this PC which will be used
|
|
to control the leds connected to it.
|
|
|
|
'stripless' means that the program will run without sending data to a strip.
|
|
Useful for development etc, but doesn't look half as good ;)
|
|
"""
|
|
|
|
if DEVICE == 'esp8266':
|
|
AUTO_DETECT = False
|
|
"""Set to true if the ip address of the device changes. This is the case if it's connecting
|
|
through windows hotspot for instance. If so, give the mac address of the device."""
|
|
MAC_ADDR = "5c-cf-7f-f0-8c-f3"
|
|
"""MAC address of the ESP8266."""
|
|
UDP_IP = "192.168.1.68"
|
|
"""IP address of the ESP8266.
|
|
Unless using auto detect, it must match IP in ws2812_controller.ino"""
|
|
UDP_PORT = 7778
|
|
"""Port number used for socket communication between Python and ESP8266"""
|
|
SOFTWARE_GAMMA_CORRECTION = False
|
|
"""Set to False because the firmware handles gamma correction + dither"""
|
|
|
|
elif DEVICE == 'pi':
|
|
LED_PIN = 18
|
|
"""GPIO pin connected to the LED strip pixels (must support PWM)"""
|
|
LED_FREQ_HZ = 800000
|
|
"""LED signal frequency in Hz (usually 800kHz)"""
|
|
LED_DMA = 5
|
|
"""DMA channel used for generating PWM signal (try 5)"""
|
|
BRIGHTNESS = 255
|
|
"""Brightness of LED strip between 0 and 255"""
|
|
LED_INVERT = True
|
|
"""Set True if using an inverting logic level converter"""
|
|
SOFTWARE_GAMMA_CORRECTION = True
|
|
"""Set to True because Raspberry Pi doesn't use hardware dithering"""
|
|
|
|
elif DEVICE == 'blinkstick':
|
|
SOFTWARE_GAMMA_CORRECTION = True
|
|
"""Set to True because blinkstick doesn't use hardware dithering"""
|
|
|
|
elif DEVICE == 'stripless':
|
|
pass
|
|
|
|
else:
|
|
raise ValueError("Invalid device selected. Device {} not known.".format(DEVICE))
|
|
|
|
USE_GUI = True
|
|
"""Whether or not to display a PyQtGraph GUI plot of visualization"""
|
|
|
|
DISPLAY_FPS = False
|
|
"""Whether to display the FPS when running (can reduce performance)"""
|
|
|
|
N_PIXELS = 242
|
|
"""Number of pixels in the LED strip (must match ESP8266 firmware)"""
|
|
|
|
GAMMA_TABLE_PATH = os.path.join(os.path.dirname(__file__), 'gamma_table.npy')
|
|
"""Location of the gamma correction table"""
|
|
|
|
MIC_RATE = 48000
|
|
"""Sampling frequency of the microphone in Hz"""
|
|
|
|
FPS = 40
|
|
"""Desired refresh rate of the visualization (frames per second)
|
|
|
|
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.
|
|
|
|
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.
|
|
"""
|
|
_max_led_FPS = int(((N_PIXELS * 30e-6) + 50e-6)**-1.0)
|
|
assert FPS <= _max_led_FPS, 'FPS must be <= {}'.format(_max_led_FPS)
|
|
|
|
MIN_FREQUENCY = 20
|
|
"""Frequencies below this value will be removed during audio processing"""
|
|
|
|
MAX_FREQUENCY = 18000
|
|
"""Frequencies above this value will be removed during audio processing"""
|
|
|
|
LOGARITHMIC_SCALING = True
|
|
"""Scale frequencies logarithmically to match perceived pitch of human ear"""
|
|
|
|
N_FFT_BINS = 24
|
|
"""Number of frequency bins to use when transforming audio to frequency domain
|
|
|
|
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.
|
|
|
|
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. More bins is not always better!
|
|
|
|
There is no point using more bins than there are pixels on the LED strip.
|
|
"""
|
|
|
|
N_ROLLING_HISTORY = 4
|
|
"""Number of past audio frames to include in the rolling window"""
|
|
|
|
MIN_VOLUME_THRESHOLD = 1e-3
|
|
"""No music visualization displayed if recorded audio volume below threshold"""
|