python - Audio visualizer on led matrix -


my need play audio file , have contents on 8x8 matrix in equalizer aspect done in piccolo quite spectrum analyzer adapted beaglebone or raspberrypi. doesn't need ambiant analysis microphone : visualisation when playing music on same board.

adafruit made library made leds matrix control easy, missing audio analysis down matrix each audio chunk.

languages maybe c or c++, best if it's in python code.for there libraries timeside , aubio couldn't found out how fill leds matrix same way in piccolo, though i've tested examples.

to crude 8-band, 8-level ongoing spectral estimate (in python, using numpy):

import numpy np  fftsize = 4096  # 100ms @ 44 khz; each bin ~ 10 hz # band edges define 8 octave-wide ranges in fft output binedges = [8, 16, 32, 64, 128, 256, 512, 1024, 2048] nbins = len(binedges)-1 # offsets our 48 db range onto useful, per band offsets = [4, 4, 4, 4, 6, 8, 10, 12] # largest value in ledval nleds = 8 # scaling of leds per doubling in amplitude ledsperdoubling = 1.0 # initial value of per-band energy history binval = 0.001 * np.ones(nbins, np.float) newbinval = np.zeros(nbins, np.float) # how rapidly displays decay after peak (depends on how we're called) decayconst = 0.9  if not_done:     # somehow tap recent 30-100ms of audio.       # assume 44 khz mono     waveform = get_latest_waveform()     # find spectrum     spectrum = np.abs(np.fft.rfft(waveform[:fftsize]))     # gather octave bands     in range(nbins-1):         newbinval[i] = np.mean(spectrum[binedges[i]:binedges[i+1]])     # peak smoothing - decay after large values     binval = np.maximum(newbinval, decayconst*binval)     # quantize values 0..8 number of leds light in each column     ledval = np.round(np.maximum(0, np.minimum(nleds,                                                 ledsperdoubling * np.log2(binval)                                                 + offsets)))     # illuminate ledval[i] leds in column (0..7) ... 

apart grabbing latest (4096 points of) waveform, should give idea.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -