gain = 29 f0 = 440*2**(1/12) hwidth = 10 step = 1 f = np.arange(f0-hwidth, f0+hwidth+step, step) bandwidth = np.zeros(len(f)) det_char = np.array(list(zip(f, bandwidth))) det = DetectorBank(sr, audio.astype(np.float32), 4, det_char, method|f_norm|a_norm, d, gain) buflen = det.getBuflen() channels = det.getChans() z = np.zeros((len(f),len(audio)), dtype=np.complex128) r = np.zeros(z.shape) det.seek(0) det.getZ(z) m = det.absZ(r, z) ######## matching straight line and decaying exponential ## get portion of response that corresponds to single note #t = np.linspace(0, len(audio), len(audio)) t0 = 6*sr t1 = int(9*sr)
bandwidth = np.zeros(len(f)) det_char = np.array(list(zip(f, bandwidth))) det = DetectorBank(sr, audio.astype(np.float32), 4, det_char, method | f_norm | a_norm, d, gain) p = Producer(det) seg_len = sr // 2 cache = DetectorCache(p, 2, seg_len) channels = det.getChans() N = 1000 prep = Preprocessor(cache, seg_len, np.arange(channels, dtype=np.int_), N) od = OnsetDetector(prep, np.arange(channels, dtype=np.int_), sr) gradient = np.array([od.do_stuff(n) for n in range(det.getBuflen())]) onsets = od.onsets offsets = od.offsets # reset DetectorBank to beginning and get values (for plotting) z = np.zeros((len(f), len(audio)), dtype=np.complex128) r = np.zeros(z.shape) det.seek(0) det.getZ(z) det.absZ(r, z) t = np.linspace(0, len(audio) / sr, len(audio)) c = [ 'black', 'blue', 'chocolate', 'cyan', 'darkmagenta', 'darkorange',