Changeset 459e46f for python/demos


Ignore:
Timestamp:
Mar 8, 2013, 7:13:43 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

python/demos/: update and add some demos

Location:
python/demos
Files:
2 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • python/demos/demo_onset.py

    re6f7a4a r459e46f  
    1919s = source(filename, samplerate, hop_s)
    2020samplerate = s.samplerate
    21 o = onset("default", win_s, hop_s)
     21o = onset("default", win_s, hop_s, samplerate)
    2222
    23 # onset detection delay, in blocks
     23# onset detection delay, in samples
     24# default to 4 blocks delay to catch up with
    2425delay = 4. * hop_s
    2526
     27# list of onsets, in samples
    2628onsets = []
     29
     30# total number of frames read
    2731total_frames = 0
    2832while True:
  • python/demos/demo_onset_plot.py

    re6f7a4a r459e46f  
    1919s = source(filename, samplerate, hop_s)
    2020samplerate = s.samplerate
    21 o = onset("default", win_s, hop_s)
     21o = onset("default", win_s, hop_s, samplerate)
    2222
    23 # onset detection delay, in blocks
     23# onset detection delay, in samples
     24# default to 4 blocks delay to catch up with
    2425delay = 4. * hop_s
    2526
     27# list of onsets, in samples
    2628onsets = []
    2729
     
    3234downsample = 2  # to plot n samples / hop_s
    3335
     36# total number of frames read
    3437total_frames = 0
    3538while True:
     
    3942        this_onset = int(total_frames - delay + is_onset[0] * hop_s)
    4043        print "%f" % (this_onset / float(samplerate))
    41         onsets.append(this_onset / float(samplerate))
     44        onsets.append(this_onset)
    4245    # keep some data to plot it later
    4346    new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
     
    5962    plt1.plot(allsamples_max_times,  allsamples_max, '-b')
    6063    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')
    6267    plt1.axis(xmin = 0., xmax = max(allsamples_max_times) )
    6368    plt1.xaxis.set_visible(False)
     
    6772    plt2.plot(desc_times, desc_plot, '-g')
    6873    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')
    7077    plt2.plot(desc_times, tdesc_plot, '-y')
    7178    plt2.axis(ymin = min(tdesc_plot), ymax = max(desc_plot))
Note: See TracChangeset for help on using the changeset viewer.