Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -5,13 +5,13 @@ from aubio import pvoc, source · 4 unmodified lines | ||
| 5 | 5 | from numpy import array, arange, zeros, shape, log10, vstack |
| 6 | 6 | from pylab import imshow, show, cm, axis, ylabel, xlabel, xticks, yticks |
| 7 | 7 | |
| 8 | −def get_spectrogram(filename): | |
| 9 | − samplerate = 44100 | |
| 8 | +def get_spectrogram(filename, samplerate = 0): | |
| 10 | 9 | win_s = 512 # fft window size |
| 11 | 10 | hop_s = win_s / 2 # hop size |
| 12 | 11 | fft_s = win_s / 2 + 1 # spectrum bins |
| 13 | 12 | |
| 14 | 13 | a = source(filename, samplerate, hop_s) # source file |
| 14 | + if samplerate == 0: samplerate = a.samplerate | |
| 15 | 15 | pv = pvoc(win_s, hop_s) # phase vocoder |
| 16 | 16 | specgram = zeros([0, fft_s], dtype='float32') # numpy array to store spectrogram |
| 17 | 17 | |