# 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
                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])],
                                                                                   'part': part,
                                                                                   'roletype': row[1]}
                                                                                   # 'shengqiang': row[2],
                                                                                   # 'banshi': row[3],
                                                                                   # 'couplet': row[4]}
                    except ValueError:
                        print(aria_name_old + '_' + str(line_number) + ' ' + 'valueError: ' + row[6] + ' ' + row[7])

        return dict_score_info

def getScores(key, dict_score_info):
    score_filename = key.split('_')[0]
    start = dict_score_info['startEndOffset'][0]
    end = dict_score_info['startEndOffset'][1]
    part = dict_score_info['part']
    score_file_path = path.join(score_path,score_filename)

# 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

                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])],
                                                                                   'part': part,
                                                                                   'roletype': row[1]}
                                                                                   # 'shengqiang': row[2],
                                                                                   # 'banshi': row[3],
                                                                                   # 'couplet': row[4]}
                    except ValueError:
                        print(aria_name_old + '_' + str(line_number) + ' ' + 'valueError: ' + row[6] + ' ' + row[7])

        return dict_score_info

def getScores(key, dict_score_info):
    score_filename = key.split('_')[0]
    start = dict_score_info['startEndOffset'][0]
    end = dict_score_info['startEndOffset'][1]
    part = dict_score_info['part']
    score_file_path = path.join(score_path,score_filename)

    line = getMelodicLine(score_file_path, start, end, partIndex=part, show=False)