void GetTimeBase(double[] f0, int f0Length, int startSample, int numberOfSamples) { var coarseTimeAxis = new double[f0Length + Handoff]; var coarseF0 = new double[f0Length + Handoff]; var coarseVUV = new double[f0Length + Handoff]; GetTemporalParametersForTimeBase(f0, f0Length, coarseTimeAxis, coarseF0, coarseVUV); var interpolatedF0 = new double[numberOfSamples]; var timeAxis = Enumerable.Range(0, numberOfSamples).Select((i) => (i + startSample) / (double)SampleRate).ToArray(); var pointer = Buffer.HeadIndex; MatlabFunctions.Interp1(coarseTimeAxis, coarseF0, timeAxis, interpolatedF0); MatlabFunctions.Interp1(coarseTimeAxis, coarseVUV, timeAxis, Buffer.InterpolatedVUV[pointer]); var interpolatedVUV = Buffer.InterpolatedVUV[pointer]; for (var i = 0; i < numberOfSamples; i++) { interpolatedVUV[i] = interpolatedVUV[i] > 0.5 ? 1.0 : 0.0; interpolatedF0[i] = interpolatedVUV[i] == 0.0 ? DefaultF0 : interpolatedF0[i]; } GetPulseLocationsForTimeBase(interpolatedF0, timeAxis, numberOfSamples, coarseTimeAxis[0]); HandoffF0 = interpolatedF0[numberOfSamples - 1]; }
void GetAperiodicity(double[] coarseFrequencyAxis, double[] coarseAperiodicity, int numberOfAperiodicities, double[] frequencyAxis, int fftSize, double[] aperiodicity) { MatlabFunctions.Interp1(coarseFrequencyAxis.SubSequence(0, numberOfAperiodicities + 2), coarseAperiodicity, frequencyAxis.SubSequence(0, fftSize / 2 + 1), aperiodicity); for (int i = 0, limit = fftSize / 2; i <= limit; i++) { aperiodicity[i] = Math.Pow(10.0, aperiodicity[i] / 20.0); } }
int GetTimeBase(double[] f0, int f0Length, int fs, double framePeriod, int yLength, double lowestF0, double[] pulseLocations, int[] pulseLocationsIndex, double[] pulseLocationsTimeShift, double[] interpolatedVUV) { var timeAxis = new double[yLength]; var coarseTimeAxis = new double[f0Length + 1]; var coarseF0 = new double[f0Length + 1]; var coarseVUV = new double[f0Length + 1]; GetTemporalParametersForTimeBase(f0, f0Length, fs, yLength, framePeriod, lowestF0, timeAxis, coarseTimeAxis, coarseF0, coarseVUV); var interpolatedF0 = new double[yLength]; MatlabFunctions.Interp1(coarseTimeAxis, coarseF0, timeAxis, interpolatedF0); MatlabFunctions.Interp1(coarseTimeAxis, coarseVUV, timeAxis, interpolatedVUV); for (var i = 0; i < yLength; i++) { interpolatedVUV[i] = interpolatedVUV[i] > 0.5 ? 1.0 : 0.0; interpolatedF0[i] = interpolatedVUV[i] == 0.0 ? DefaultF0 : interpolatedF0[i]; } return(GetPulseLocationsForTimeBase(interpolatedF0, timeAxis, yLength, fs, pulseLocations, pulseLocationsIndex, pulseLocationsTimeShift)); }