In [1]:
%matplotlib inline
import os
import json
import numpy as np
from alignedpitchfilter.alignedpitchfilter import AlignedPitchFilter
import matplotlib.pyplot as plt
In [2]:
examplefolder = 'ussak--sazsemaisi--aksaksemai----dede_salih_efendi'
pitchfile = os.path.join(examplefolder, 'pitch.json')
alignednotefile = os.path.join(examplefolder, 'alignedNotes.json')
savepitchfile = os.path.join(examplefolder, 'pitch_corrected.json')
savenotefile = os.path.join(examplefolder, 'alignedNotes_corrected.json')
# load the data
pitch = json.load(open(pitchfile, 'r'))['pitch']
notes = json.load(open(alignednotefile, 'r'))
# instantiate the alignedpitchfilter class
alignedpitchfilter = AlignedPitchFilter()
In [3]:
# filter
pitch_corrected, notes_corrected, synth_pitch = alignedpitchfilter.filter(
pitch, notes['notes'])
json.dump(pitch_corrected.tolist(), open(savepitchfile, 'w'), indent=4)
json.dump({'notes': notes_corrected}, open(savenotefile, 'w'), indent=4)
In [4]:
# plot
alignedpitchfilter.plot(pitch, pitch_corrected, notes_corrected)
plt.show()