/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var soundLocation = "";
var xTimeArray = [];
var yTimeArray = [];
var xFreqArray = [];
var yFreqArray = [];

function loadAudio(filePath) {
    soundLocation = filePath;
    //alert(soundLocation);
    document.ToneBender.analyzeSound(soundLocation);
}

function playOrgAudio() {
    document.ToneBender.playOriginalAudio();
}


function sendSoundStrings(timeX, timeY, freqX, freqY) {
    //alert(timeX); alert(timeY); alert(freqX); alert(freqY);
    document.ToneBender.playSynthesizedAudio(timeX, timeY, freqX, freqY);
    //alert("played synth audio");
}

function setFrequencyEnvelopeX() {
    xPointsFreq = document.ToneBender.getFrequencyEnvelopeX();
    xFreqArray = xPointsFreq.split(",");
}

function setFrequencyEnvelopeY() {
    yPointsFreq = document.ToneBender.getFrequencyEnvelopeY();

    yFreqArray = yPointsFreq.split(",");
}

function setAmplitudeEnvelopeX() {
    xPointsTime = document.ToneBender.getAmplitudeEnvelopeX();

    xTimeArray = xPointsTime.split(",");
}

function setAmplitudeEnvelopeY() {
    yPointsTime = document.ToneBender.getAmplitudeEnvelopeY();

    yTimeArray = yPointsTime.split(",");
}

function getAmplitudeLength() {
    numPoints = xTimeArray.length;
    return numPoints;
}

function getFrequencyLength() {
    numPoints = xFreqArray.length;
    return numPoints;
}

function getXFreqPoint(index){ return xFreqArray[index]; }

function getYFreqPoint(index){ return yFreqArray[index]; }

function getXTimePoint(index){ return xTimeArray[index]; }

function getYTimePoint(index){ return yTimeArray[index]; }


function getSNR(timeX, timeY, freqX, freqY) {
    SNR = document.ToneBender.calculateSNR(timeX, timeY, freqX, freqY);

    return SNR;
}