shithub: aubio

Download patch

ref: 9f8e8a9896f075a662ea95cd8fb23186a55b3f6c
parent: d5e846c4a54a78204784739e155a5317f4ecfcf1
author: Paul Brossier <piem@piem.org>
date: Wed Mar 6 11:56:53 EST 2013

demos/demo_spectrogram.py: add samplerate option to spectrogram

--- a/python/demos/demo_spectrogram.py
+++ b/python/demos/demo_spectrogram.py
@@ -5,13 +5,13 @@
 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