diff --git a/mic_read.py b/mic_read.py index b74d9fe..64161f4 100644 --- a/mic_read.py +++ b/mic_read.py @@ -43,7 +43,7 @@ def open_mic(): outputs: int16 data array """ def get_data(stream,pa): - input_data = stream.read(CHUNK_SIZE) + input_data = stream.read(CHUNK_SIZE, exception_on_overflow=False) data = np.fromstring(input_data,np.int16) return data diff --git a/requirements.txt b/requirements.txt index c963c20..6acd8e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ -funcsigs==0.4 -matplotlib==1.4.3 -mock==1.3.0 -nose==1.3.7 -numpy==1.9.2 -pbr==1.4.0 -PyAudio==0.2.8 -pyparsing==2.0.3 -python-dateutil==2.4.2 -pytz==2015.4 -six==1.9.0 +funcsigs>=0.4 +matplotlib>=1.4.3 +mock>=1.3.0 +nose>=1.3.7 +numpy>=1.9.2 +pbr>=1.4.0 +PyAudio>=0.2.8 +pyparsing>=2.0.3 +python-dateutil>=2.4.2 +pytz>=2015.4 +six>=1.9.0 diff --git a/run_specgram.py b/run_specgram.py index 6ba9931..7f54b91 100644 --- a/run_specgram.py +++ b/run_specgram.py @@ -31,7 +31,7 @@ inputs: audio stream and PyAudio object outputs: int16 array """ -def get_sample(stream,pa): +def get_sample(stream, pa): data = mic_read.get_data(stream,pa) return data """ @@ -54,8 +54,8 @@ def get_specgram(signal,rate): inputs: iteration number outputs: updated image """ -def update_fig(n): - data = get_sample(stream,pa) +def update_fig(n, stream, pa, im): + data = get_sample(stream, pa) arr2D,freqs,bins = get_specgram(data,rate) im_data = im.get_array() if n < SAMPLES_PER_FRAME: @@ -74,8 +74,8 @@ def main(): """ Launch the stream and the original spectrogram """ - stream,pa = mic_read.open_mic() - data = get_sample(stream,pa) + stream, pa = mic_read.open_mic() + data = get_sample(stream, pa) arr2D,freqs,bins = get_specgram(data,rate) """ Setup the plot paramters @@ -90,7 +90,8 @@ def main(): ##plt.colorbar() #enable if you want to display a color bar ############### Animate ############### - anim = animation.FuncAnimation(fig,update_fig,blit = False, + upd_fig = lambda n: update_fig(n, stream=stream, pa=pa, im=im) + anim = animation.FuncAnimation(fig,upd_fig,blit = False, interval=mic_read.CHUNK_SIZE/1000)