Changeset f264b17 for python/demos/demo_onset_plot.py
- Timestamp:
- Jun 22, 2016, 1:00:10 PM (8 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:
- 4b9443c4
- Parents:
- 60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_onset_plot.py
r60fc05b rf264b17 3 3 import sys 4 4 from aubio import onset, source 5 from numpy import array,hstack, zeros5 from numpy import hstack, zeros 6 6 7 7 win_s = 512 # fft size 8 hop_s = win_s / 2# hop size8 hop_s = win_s // 2 # hop size 9 9 10 10 if len(sys.argv) < 2: 11 print "Usage: %s <filename> [samplerate]" % sys.argv[0]11 print("Usage: %s <filename> [samplerate]" % sys.argv[0]) 12 12 sys.exit(1) 13 13 … … 35 35 samples, read = s() 36 36 if o(samples): 37 print "%f" % (o.get_last_s())37 print("%f" % (o.get_last_s())) 38 38 onsets.append(o.get_last()) 39 39 # keep some data to plot it later 40 new_maxes = (abs(samples.reshape(hop_s/ downsample, downsample))).max(axis=0)40 new_maxes = (abs(samples.reshape(hop_s//downsample, downsample))).max(axis=0) 41 41 allsamples_max = hstack([allsamples_max, new_maxes]) 42 42 desc.append(o.get_descriptor()) … … 47 47 if 1: 48 48 # do plotting 49 from numpy import arange50 49 import matplotlib.pyplot as plt 51 50 allsamples_max = (allsamples_max > 0) * allsamples_max … … 63 62 plt1.yaxis.set_visible(False) 64 63 desc_times = [ float(t) * hop_s / samplerate for t in range(len(desc)) ] 65 desc_plot = [d / max(desc) for d in desc] 64 desc_max = max(desc) if max(desc) != 0 else 1. 65 desc_plot = [d / desc_max for d in desc] 66 66 plt2.plot(desc_times, desc_plot, '-g') 67 tdesc_plot = [d / max(desc)for d in tdesc]67 tdesc_plot = [d / desc_max for d in tdesc] 68 68 for stamp in onsets: 69 69 stamp /= float(samplerate)
Note: See TracChangeset
for help on using the changeset viewer.