Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, sampler
Children:
ee8a57c
Parents:
00d0275 (diff), 67b6618 (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.
Message:

Merge branch 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/demos/demo_onset_plot.py

    r00d0275 r155cc10  
    33import sys
    44from aubio import onset, source
    5 from numpy import array, hstack, zeros
     5from numpy import hstack, zeros
    66
    77win_s = 512                 # fft size
    8 hop_s = win_s / 2           # hop size
     8hop_s = win_s // 2          # hop size
    99
    1010if len(sys.argv) < 2:
    11     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     11    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1212    sys.exit(1)
    1313
     
    3535    samples, read = s()
    3636    if o(samples):
    37         print "%f" % (o.get_last_s())
     37        print("%f" % (o.get_last_s()))
    3838        onsets.append(o.get_last())
    3939    # 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)
    4141    allsamples_max = hstack([allsamples_max, new_maxes])
    4242    desc.append(o.get_descriptor())
     
    4747if 1:
    4848    # do plotting
    49     from numpy import arange
    5049    import matplotlib.pyplot as plt
    5150    allsamples_max = (allsamples_max > 0) * allsamples_max
     
    6362    plt1.yaxis.set_visible(False)
    6463    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]
    6666    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]
    6868    for stamp in onsets:
    6969        stamp /= float(samplerate)
Note: See TracChangeset for help on using the changeset viewer.