for i in range(len(fil)): if (fil[i] < 20): fil[i] = 0 pitches = np.asarray(fil, dtype=float) #remove silent sections index = np.argwhere(pitches == 0.0) #print index pitches_with_no_zero = np.delete(pitches, index) ''' plt.plot(t,pitches_with_no_zero) plt.xlabel('time') plt.ylabel('frequency hz') plt.show() ''' hz_to_cents.convert_to_cents(pitches_with_no_zero, cent_vals) #cut frequencies below 3000 cents cents = np.asarray(cent_vals, dtype=float) t = np.arange(0, len(cents)) plt.plot(t, cents) plt.xlabel('time') plt.ylabel('frequency cents') plt.show() ''' f,axarr=plt.subplots(2,sharex=True) axarr[0].plot(t,pitches_with_no_zero) axarr[0].set_ylabel('hz') axarr[1].plot(t,cents) axarr[1].set_ylabel('cents') plt.show()
new_part = '.notes.csv' new_fname = base + new_part with open(new_fname, 'rb') as f: reader = csv.reader(f) for row in reader: times.append(round(float(row[0]), 3)) durations.append(round(float(row[1]), 3)) notes.append(row[2]) #get_the_gap(4.362,,time_start,pitch_values) for i in range(len(times)): get_the_gap(times[i], times[i] + durations[i], time_start, diffs, int(notes[i])) diffs_normal = [] hz_to_cents.convert_to_cents(diffs, diffs_normal) #diffs.append(100) ''' for i in range(len(diffs)): if(diffs[i]<=100): diffs_normal.append(diffs[i]) ''', diff_np = np.asarray(diffs_normal, dtype=float) time_np = np.arange(0, len(diff_np), 1) plt.figure plt.plot(time_np, diff_np, 'b') plt.xlabel('note') plt.ylabel('FO CENTS') plt.title(base)