def freq_slider_change(tick): minf = freq_slider.tickValue(0)**2.0 * (CONFIGS['mic_rate'] / 2.0) maxf = freq_slider.tickValue(1)**2.0 * (CONFIGS['mic_rate'] / 2.0) t = 'Frequency range: {:.0f} - {:.0f} Hz'.format(minf, maxf) freq_label.setText(t) CONFIGS['min_frequency'] = minf CONFIGS['max_frequency'] = maxf dsp.create_mel_bank()
def freq_slider_change(tick): minf = freq_slider.tickValue(0)**2.0 * (config.MIC_RATE / 2.0) maxf = freq_slider.tickValue(1)**2.0 * (config.MIC_RATE / 2.0) t = 'Frequency range: {:.0f} - {:.0f} Hz'.format(minf, maxf) freq_label.setText(t) config.MIN_FREQUENCY = minf config.MAX_FREQUENCY = maxf dsp.create_mel_bank()
def freq_slider_change(tick): minf = freq_slider.tickValue(0)**2.0 * (config.MIC_RATE / 2.0) maxf = freq_slider.tickValue(1)**2.0 * (config.MIC_RATE / 2.0) t = 'Frequency range: {:.0f} - {:.0f} Hz'.format(minf, maxf) freq_label.setText(t) config.MIN_FREQUENCY = minf config.MAX_FREQUENCY = maxf dsp.create_mel_bank()
spectrum_label.setText('Spectrum', color=active_color) # Create effect "buttons" (labels with click event) energy_label = pg.LabelItem('Energy') scroll_label = pg.LabelItem('Scroll') spectrum_label = pg.LabelItem('Spectrum') energy_label.mousePressEvent = energy_click scroll_label.mousePressEvent = scroll_click spectrum_label.mousePressEvent = spectrum_click energy_click(0) # Layout layout.nextRow() layout.addItem(freq_label, colspan=3) layout.nextRow() layout.addItem(freq_slider, colspan=3) layout.nextRow() layout.addItem(energy_label) layout.addItem(scroll_label) layout.addItem(spectrum_label) # Initialize LEDs dsp.create_mel_bank(config) led.setup(config) led.update(config) # Start listening to live audio stream tmic = threading.Thread(target=microphone.start_stream, args=(microphone_update, config)) tmic.start() remote_control.control_loop(config) tmic.join() # microphone.start_stream(microphone_update)
def set_freq_max(): config.MAX_FREQUENCY = freq_slider.end() dsp.create_mel_bank()
def set_freq_min(): config.MIN_FREQUENCY = freq_slider.start() dsp.create_mel_bank()
args = parser.parse_args() # Visualization effect to display on the LED strip vis_type = args.vis_type if vis_type == "spectrum": visualization_effect = visualize_spectrum elif vis_type == "energy": visualization_effect = visualize_energy elif vis_type == "scroll": visualization_effect = visualize_scroll else: visualization_effect = visualize_spectrum # Low pass and high pass filters. config.MIN_FREQUENCY = args.min_hz config.MAX_FREQUENCY = args.max_hz dsp.create_mel_bank() if config.USE_GUI: import pyqtgraph as pg from pyqtgraph.Qt import QtGui, QtCore # Create GUI window app = QtGui.QApplication([]) view = pg.GraphicsView() layout = pg.GraphicsLayout(border=(100, 100, 100)) view.setCentralItem(layout) view.show() view.setWindowTitle('Visualization') view.resize(800, 600) # Mel filterbank plot fft_plot = layout.addPlot(title='Filterbank Output', colspan=3) fft_plot.setRange(yRange=[-0.1, 1.2])