History

demos/demo_spectrogram.py: add samplerate option to spectrogram

Paul Brossier committed 13 years ago

Commit 9f8e8a91 parent d5e846c1 file · +2 −2Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_spectrogram.py+2−2
@@ -5,13 +5,13 @@ from aubio import pvoc, source · 4 unmodified lines
55 from numpy import array, arange, zeros, shape, log10, vstack
66 from pylab import imshow, show, cm, axis, ylabel, xlabel, xticks, yticks
77
8−def get_spectrogram(filename):
9− samplerate = 44100
8+def get_spectrogram(filename, samplerate = 0):
109 win_s = 512 # fft window size
1110 hop_s = win_s / 2 # hop size
1211 fft_s = win_s / 2 + 1 # spectrum bins
1312
1413 a = source(filename, samplerate, hop_s) # source file
14+ if samplerate == 0: samplerate = a.samplerate
1515 pv = pvoc(win_s, hop_s) # phase vocoder
1616 specgram = zeros([0, fft_s], dtype='float32') # numpy array to store spectrogram
1717

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t