# Path: general/utilsFunctions.py
# def hz2cents(pitchInHz, tonic=261.626):
#     cents = 1200*np.log2(1.0*pitchInHz/tonic)
#     return cents
# 
# def pitchtrackInterp(pitchInCents):
#     x = np.linspace(0, 100, len(pitchInCents))
#     xvals = np.linspace(0, 100, sample_number_total)
#     pitchInCents_interp = np.interp(xvals, x, pitchInCents)
#     return pitchInCents_interp.tolist()


from jingjuScores import getMelodicLine
from general.filePath import *
from general.parameters import *
from general.utilsFunctions import hz2cents,pitchtrackInterp
from os import path
import numpy as np
import csv,json
#         return dict_score_info

def getDictScoreInfo(score_info_filepath):
    dict_score_info = {}
    with open(score_info_filepath, 'rb') as csvfile:
        score_info = csv.reader(csvfile,delimiter=";")

        aria_name_old = ''
        line_number = 0
        for row in score_info:
            if row[0] != 'File name':
                aria_name = row[0]
                if len(aria_name):
                    # row[0] != empty
                    line_number = 0
                    aria_name_old = aria_name
                    part = 1
                else:
                    line_number += 1

                if row[5][:4] == 'Part':
                    # if lyric is 'Part', redefine roleType and part
                    # roleType = row[1].split()[2]
                    part = int(row[5].split()[1])

                if row[5][:4] != 'Part':
                    try:
                        dict_score_info[aria_name_old + '_' + str(line_number)] = {'lyrics': row[5],
                                                                                   'startEndOffset': [float(row[6]),
                                                                                                      float(

# Path: general/utilsFunctions.py
# def hz2cents(pitchInHz, tonic=261.626):
#     cents = 1200*np.log2(1.0*pitchInHz/tonic)
#     return cents
# 
# def pitchtrackInterp(pitchInCents):
#     x = np.linspace(0, 100, len(pitchInCents))
#     xvals = np.linspace(0, 100, sample_number_total)
#     pitchInCents_interp = np.interp(xvals, x, pitchInCents)
#     return pitchInCents_interp.tolist()


# Path: melodicSimilarity/scoreManip.py
from jingjuScores import getMelodicLine
from general.filePath import *
from general.parameters import *
from general.utilsFunctions import hz2cents,pitchtrackInterp
from os import path
import numpy as np
import csv,json

#         return dict_score_info

def getDictScoreInfo(score_info_filepath):
    dict_score_info = {}
    with open(score_info_filepath, 'rb') as csvfile:
        score_info = csv.reader(csvfile,delimiter=";")

        aria_name_old = ''
        line_number = 0
        for row in score_info:
            if row[0] != 'File name':
                aria_name = row[0]
                if len(aria_name):
                    # row[0] != empty
                    line_number = 0
                    aria_name_old = aria_name
                    part = 1
                else:
                    line_number += 1

                if row[5][:4] == 'Part':
                    # if lyric is 'Part', redefine roleType and part
                    # roleType = row[1].split()[2]
                    part = int(row[5].split()[1])

                if row[5][:4] != 'Part':
                    try:
                        dict_score_info[aria_name_old + '_' + str(line_number)] = {'lyrics': row[5],
                                                                                   'startEndOffset': [float(row[6]),
                                                                                                      float(

                                                                                                          row[7])],