From: Paul Brossier Date: Wed, 6 Mar 2013 21:56:53 +0000 (-0500) Subject: demos/demo_spectrogram.py: add samplerate option to spectrogram X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9f8e8a9896f075a662ea95cd8fb23186a55b3f6c;p=aubio.git demos/demo_spectrogram.py: add samplerate option to spectrogram --- diff --git a/python/demos/demo_spectrogram.py b/python/demos/demo_spectrogram.py index 16bd69ef..cf5f80d5 100755 --- a/python/demos/demo_spectrogram.py +++ b/python/demos/demo_spectrogram.py @@ -5,13 +5,13 @@ from aubio import pvoc, source from numpy import array, arange, zeros, shape, log10, vstack from pylab import imshow, show, cm, axis, ylabel, xlabel, xticks, yticks -def get_spectrogram(filename): - samplerate = 44100 +def get_spectrogram(filename, samplerate = 0): win_s = 512 # fft window size hop_s = win_s / 2 # hop size fft_s = win_s / 2 + 1 # spectrum bins a = source(filename, samplerate, hop_s) # source file + if samplerate == 0: samplerate = a.samplerate pv = pvoc(win_s, hop_s) # phase vocoder specgram = zeros([0, fft_s], dtype='float32') # numpy array to store spectrogram