Sound spectrum

From cod3v
Revision as of 23:41, 15 February 2021 by Mol (talk | contribs) (→‎Theory)

Introduction

Use USB microphone to listen sound and FFT it to waveforms.

Theory

import pyaudio
#import wave
import multiprocessing
import numpy as np
#import pickle #Not good for np arrays
import time
from pathlib import Path 

audio = pyaudio.PyAudio() # create pyaudio instantiation

info = audio.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
        if (audio.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
                print( "Input Device id ", i, " - ", audio.get_device_info_by_host_api_device_index(0, i).get('name') )