- Timestamp:
- Mar 8, 2013, 7:13:43 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:
- 9582713
- Parents:
- e6f7a4a
- Location:
- python/demos
- Files:
-
- 2 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_onset.py
re6f7a4a r459e46f 19 19 s = source(filename, samplerate, hop_s) 20 20 samplerate = s.samplerate 21 o = onset("default", win_s, hop_s )21 o = onset("default", win_s, hop_s, samplerate) 22 22 23 # onset detection delay, in blocks 23 # onset detection delay, in samples 24 # default to 4 blocks delay to catch up with 24 25 delay = 4. * hop_s 25 26 27 # list of onsets, in samples 26 28 onsets = [] 29 30 # total number of frames read 27 31 total_frames = 0 28 32 while True: -
python/demos/demo_onset_plot.py
re6f7a4a r459e46f 19 19 s = source(filename, samplerate, hop_s) 20 20 samplerate = s.samplerate 21 o = onset("default", win_s, hop_s )21 o = onset("default", win_s, hop_s, samplerate) 22 22 23 # onset detection delay, in blocks 23 # onset detection delay, in samples 24 # default to 4 blocks delay to catch up with 24 25 delay = 4. * hop_s 25 26 27 # list of onsets, in samples 26 28 onsets = [] 27 29 … … 32 34 downsample = 2 # to plot n samples / hop_s 33 35 36 # total number of frames read 34 37 total_frames = 0 35 38 while True: … … 39 42 this_onset = int(total_frames - delay + is_onset[0] * hop_s) 40 43 print "%f" % (this_onset / float(samplerate)) 41 onsets.append(this_onset / float(samplerate))44 onsets.append(this_onset) 42 45 # keep some data to plot it later 43 46 new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0) … … 59 62 plt1.plot(allsamples_max_times, allsamples_max, '-b') 60 63 plt1.plot(allsamples_max_times, -allsamples_max, '-b') 61 for stamp in onsets: plt1.plot([stamp, stamp], [-1., 1.], '-r') 64 for stamp in onsets: 65 stamp /= float(samplerate) 66 plt1.plot([stamp, stamp], [-1., 1.], '-r') 62 67 plt1.axis(xmin = 0., xmax = max(allsamples_max_times) ) 63 68 plt1.xaxis.set_visible(False) … … 67 72 plt2.plot(desc_times, desc_plot, '-g') 68 73 tdesc_plot = [d / max(desc) for d in tdesc] 69 for stamp in onsets: plt2.plot([stamp, stamp], [min(tdesc_plot), max(desc_plot)], '-r') 74 for stamp in onsets: 75 stamp /= float(samplerate) 76 plt2.plot([stamp, stamp], [min(tdesc_plot), max(desc_plot)], '-r') 70 77 plt2.plot(desc_times, tdesc_plot, '-y') 71 78 plt2.axis(ymin = min(tdesc_plot), ymax = max(desc_plot))
Note: See TracChangeset
for help on using the changeset viewer.