0

私が必要としているのは、オーディオ ファイルを再生し、 BeagleBone または RaspberryPI に適応したスペクトル アナライザーのように、 Piccoloで行われたように、イコライザーの側面でその内容を 8x8 マトリックスに配置することです。これには、マイクからの環境分析は必要ありません。同じボードで音楽を再生するときの視覚化だけです。

Adafruit は、LED マトリクス制御を容易にするライブラリを作成しました。欠落しているのは、ほとんどの場合、各オーディオ チャンクのマトリクスまでのオーディオ分析です。

言語は C または C++ かもしれませんが、Python コードである場合に最適です。これには、Timesideaubioなどの優れたライブラリがありますが、Piccolo と同じ方法で LED マトリックスを埋める方法を見つけることができませんでした。いくつかの例をテストしました。

4

1 に答える 1

2

大まかな 8 バンド、8 レベルの進行中のスペクトル推定を取得するには (Python で numpy を使用):

import numpy as np

fftsize = 4096  # about 100ms at 44 kHz; each bin will be ~ 10 Hz
# Band edges to define 8 octave-wide ranges in the FFT output
binedges = [8, 16, 32, 64, 128, 256, 512, 1024, 2048]
nbins = len(binedges)-1
# offsets to get our 48 dB range onto something 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 the displays decay after a peak (depends on how often we're called)
decayConst = 0.9

if not_done:
    # somehow tap into the most recent 30-100ms of audio.  
    # Assume we get 44 kHz mono back
    waveform = get_latest_waveform()
    # find spectrum
    spectrum = np.abs(np.fft.rfft(waveform[:fftsize]))
    # gather into octave bands
    for i in range(nbins-1):
        newbinval[i] = np.mean(spectrum[binedges[i]:binedges[i+1]])
    # Peak smoothing - decay slowly after large values
    binval = np.maximum(newbinval, decayConst*binval)
    # Quantize into values 0..8 as the number of leds to light in each column
    ledval = np.round(np.maximum(0, np.minimum(nleds, 
                                               ledsPerDoubling * np.log2(binval) 
                                               + offsets)))
    # Now illuminate ledval[i] LEDs in column i (0..7) ...

最新の (4096 ポイントの) 波形を取得することは別として、これでアイデアが得られるはずです。

于 2014-07-03T18:42:17.320 に答える