From 9f8e8a9896f075a662ea95cd8fb23186a55b3f6c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 6 Mar 2013 16:56:53 -0500 Subject: [PATCH] demos/demo_spectrogram.py: add samplerate option to spectrogram --- python/demos/demo_spectrogram.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.26.2