Changeset e8dd49f for interfaces/python/demo_spectrogram.py
- Timestamp:
- Feb 8, 2013, 5:30:51 PM (12 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 21e2d5e3
- Parents:
- 7175ed4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/demo_spectrogram.py
r7175ed4 re8dd49f 25 25 imshow(log10(specgram.T + .001), origin = 'bottom', aspect = 'auto', cmap=cm.gray_r) 26 26 axis([0, len(specgram), 0, len(specgram[0])]) 27 ylabel('Frequency (Hz)')28 xlabel('Time (s)')29 27 # show axes in Hz and seconds 30 28 time_step = hop_s / float(samplerate) 31 29 total_time = len(specgram) * time_step 32 ticks = 10 33 xticks( arange(ticks) / float(ticks) * len(specgram), 34 [x * total_time / float(ticks) for x in range(ticks) ] ) 35 yticks( arange(ticks) / float(ticks) * len(specgram[0]), 36 [x * samplerate / 2. / float(ticks) for x in range(ticks) ] ) 30 print "total time: %0.2fs" % total_time, 31 print ", samplerate: %.2fkHz" % (samplerate / 1000.) 32 n_xticks = 10 33 n_yticks = 10 34 xticks_pos = [ x / float(n_xticks) * len(specgram) for x in range(n_xticks) ] 35 xticks_str = [ "%.2f" % (x * total_time / float(n_xticks)) for x in range(n_xticks) ] 36 xticks( xticks_pos , xticks_str ) 37 yticks_pos = [ y / float(n_yticks) * len(specgram[0]) for y in range(n_yticks) ] 38 yticks_str = [ "%.2f" % (y * samplerate / 2000. / float(n_yticks)) for y in range(n_yticks) ] 39 yticks( yticks_pos , yticks_str ) 40 ylabel('Frequency (kHz)') 41 xlabel('Time (s)') 37 42 38 43 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.