In [ ]:
%matplotlib inline
from fileoperations.fileoperations import getFileNamesInDir
import os
import json
import numpy as np
from alignednotemodel.PitchDistribution import hz_to_cent, cent_to_hz
from alignednotemodel import alignednotemodel
import matplotlib.pyplot as plt
import pdb
In [ ]:
datafolder = '../../data/'
pitchfiles, pitchfolders, pitchnames = getFileNamesInDir(datafolder,
keyword='correctedPredominantMelody.json')
tonicfiles = [os.path.join(pf, 'tonic.json') for pf in pitchfolders]
tuningfiles = [os.path.join(pf, 'tuning.json') for pf in pitchfolders]
notefiles = [os.path.join(pf, 'alignedNotes.json') for pf in pitchfolders]
savemodelfiles = [os.path.join(pf, 'noteModels.json') for pf in pitchfolders]
In [ ]:
for pf, tf, tu, nf, sm in zip(pitchfiles, tonicfiles, tuningfiles, notefiles, savemodelfiles):
pitch = np.array(json.load(open(pf, 'r'))['pitch'])
alignednotes = json.load(open(nf, 'r'))['notes']
tonic = json.load(open(tf, 'r'))['scoreInformed']
tuning = json.load(open(tu, 'r'))['scoreInformed']
noteModels, pitchDistibution, newTonic = alignednotemodel.getModels(pitch, alignednotes, tonic,
tuning, kernel_width=7.5)
json.dump(noteModels, open(sm, 'w'))
In [ ]:
#fig, (ax1, ax2) = alignednotemodel.plot(noteModels, pitchDistibution, alignednotes, pitch, tonic)
#plt.show()
In [ ]: