Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ Once everything has been configured, run [visualization.py](python/visualization

A PyQtGraph GUI will open to display the output of the visualization on the computer. There is a setting to enable/disable the GUI display in [config.py](python/config.py)

You can run visualization.py with one of the following arguments to start in that mode: energy, spectrum, scroll

For example: $ python python/visualization.py spectrum

![visualization-gui](images/visualization-gui.png)

If you encounter any issues or have questions about this project, feel free to [open a new issue](https://github.com/scottlawsonbc/audio-reactive-led-strip/issues).
Expand Down
30 changes: 27 additions & 3 deletions python/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import microphone
import dsp
import led
import sys

_time_prev = time.time() * 1000.0
"""The previous time that the frames_per_second() function was called"""
Expand Down Expand Up @@ -248,10 +249,22 @@ def microphone_update(audio_samples):
# Array containing the rolling audio sample window
y_roll = np.random.rand(config.N_ROLLING_HISTORY, samples_per_frame) / 1e16

visualization_effect = visualize_spectrum
"""Visualization effect to display on the LED strip"""


"""Visualization effect to display on the LED strip"""
if len(sys.argv) == 1:
"""No args were passed"""
visualization_effect = visualize_spectrum
else:
if sys.argv[1] == "spectrum":
visualization_effect = visualize_spectrum
elif sys.argv[1] == "energy":
visualization_effect = visualize_energy
elif sys.argv[1] == "scroll":
visualization_effect = visualize_scroll
else:
print("Invalid argument! - Possible values are: spectrum, energy, scroll")

if __name__ == '__main__':
if config.USE_GUI:
import pyqtgraph as pg
Expand Down Expand Up @@ -340,7 +353,18 @@ def spectrum_click(x):
energy_label.mousePressEvent = energy_click
scroll_label.mousePressEvent = scroll_click
spectrum_label.mousePressEvent = spectrum_click
energy_click(0)
"""Start GUI page based on args"""
if len(sys.argv) == 1:
spectrum_click(0)
else:
if sys.argv[1] == "energy":
energy_click(0)
elif sys.argv[1] == "spectrum":
spectrum_click(0)
elif sys.argv[1] == "scroll":
scroll_click(0)
else:
print("Error choosing default GUI page due to unknown user arg")
# Layout
layout.nextRow()
layout.addItem(freq_label, colspan=3)
Expand Down