コード例 #1
0
def run_FFT_analyzer():
    args = parse_args()
    window_ratio = convert_window_ratio(args.window_ratio)

    ear = Stream_Analyzer(
        device=args.
        device,  # Pyaudio (portaudio) device index, defaults to first mic input
        rate=None,  # Audio samplerate, None uses the default source settings
        FFT_window_size_ms=60,  # Window size used for the FFT transform
        updates_per_second=
        1000,  # How often to read the audio stream for new data
        smoothing_length_ms=
        50,  # Apply some temporal smoothing to reduce noisy features
        n_frequency_bins=args.
        frequency_bins,  # The FFT features are grouped in bins
        visualize=1,  # Visualize the FFT features with PyGame
        verbose=args.verbose,  # Print running statistics (latency, fps, ...)
        height=args.height,  # Height, in pixels, of the visualizer window,
        window_ratio=
        window_ratio  # Float ratio of the visualizer window. e.g. 24/9
    )

    fps = 60  #How often to update the FFT features + display
    last_update = time.time()
    while True:
        if (time.time() - last_update) > (1. / fps):
            last_update = time.time()
            raw_fftx, raw_fft, binned_fftx, binned_fft = ear.get_audio_features(
            )
コード例 #2
0
import time
from src.stream_analyzer import Stream_Analyzer

ear = Stream_Analyzer(
                device = None,               # Manually play with this (int) if you don't see anything
                rate   = None,               # Audio samplerate, None uses the default source settings
                FFT_window_size_ms  = 60,    # Window size used for the FFT transform
                updates_per_second  = 2000,  # How often to read the audio stream for new data
                smoothing_length_ms = 50,    # Apply some temporal smoothing to reduce noisy features
                n_frequency_bins    = 300,   # The FFT features are grouped in bins
                visualize = 1,               # Visualize the FFT features with PyGame
                verbose   = 0                # Print running statistics (latency, fps, ...)
                )

fps = 60  #How often to update the FFT features + display

last_update = time.time()
while True:
    if (time.time() - last_update) > (1./fps):
        last_update = time.time()
        raw_fftx, raw_fft, binned_fftx, binned_fft = ear.get_audio_features()