def __init__(self, pitch): self.ji_intervals = np.array([ -2400, -2289, -2197, -2085, -2014, -1902, -1791, -1699, -1587, -1516, -1404, -1312, -1200, -1089, -997, -885, -814, -702, -591, -499, -387, -316, -204, -112, 0, 111, 203, 315, 386, 498, 609, 701, 813, 884, 996, 1088, 1200, 1311, 1403, 1515, 1586, 1698, 1809, 1901, 2013, 2084, 2196, 2288, 2400, 2511, 2603, 2715, 2786, 2898, 3009, 3101, 3213, 3284, 3396, 3488, 3600, 3711, 3803, 3915, 3986, 4098, 4209, 4301, 4413, 4484, 4596, 4688, 4800 ]) self.pitch_obj = intonation.Pitch(pitch[:, 0], pitch[:, 1]) self.rec = intonation.Recording(self.pitch_obj) self.intonation_profile = None
def hz2centsRafa(timeVec, pitchInHz, tonic=261.626, plotHisto=False, saveHisto=False, title=None): # with open(document, 'r') as f: # data = f.readlines() # # data2 = [] # for i in range(len(data)): # x = [] # time = float(data[i].split('\t')[0]) # x.append(time) # value = float(data[i].split('\t')[1].rstrip('\r\n')) # x.append(value) # data2.append(x) cents = [-10000] * len(pitchInHz) for i in xrange(len(pitchInHz)): if pitchInHz[i] > 0: cents[i] = 1200 * np.log2(1.0 * pitchInHz[i] / tonic) data = zip(timeVec, cents) data_hist = np.array(data) pitch_obj = intonation.Pitch(data_hist[:, 0], data_hist[:, 1]) #print data_hist[:,0], data_hist[:,1] rec_obj = intonation.Recording(pitch_obj) rec_obj.compute_hist() # draw this histogram rec_obj.histogram.plot() if not isinstance(title, unicode): title = title.decode('utf8') # decode the ascii to utf8 if plotHisto == True: drawTitle(title, fontproperties=droidTitle) show() if saveHisto == True: drawTitle(title, fontproperties=droidTitle) savefig(title[:-4] + '-singingHisto.png', dpi=150, bbox_inches='tight') rec_obj.histogram.get_peaks() peaks = rec_obj.histogram.peaks return peaks['peaks']
# ##Have a look at the data, it always does good! # <codecell> plot(data[52000:53000, 0], data[52000:53000, 1]) ylim(200, 1000) # <markdowncell> # ##Load the data into a pitch object # You can avail a number of different method on pitch object to study different aspects of intervals. Let's also look at what methods are # available and what they do. # <codecell> pitch_obj = intonation.Pitch(data[:, 0], data[:, 1]) help(pitch_obj) # <markdowncell> # ##Load the recording object # Recording object takes the pitch object, and defines methods that access pitch data and functions defined over it, to create # histogram and intonation profile of the corresponding recording. Load it and check the methods available on it. # <codecell> rec_obj = intonation.Recording(pitch_obj) help(rec_obj) # <markdowncell>