private Measurements[] GetFileMeasurements() { if (windows.Count == 0) return null; int numberOfWindows = windows.Count; Measurements[] fileMeasurements = new Measurements[numberOfWindows]; for (int i = 0; i < numberOfWindows; i++) //-1 because we always throw away the last window { fileMeasurements[i] = windows[i].Measurements; } return fileMeasurements; }
private void SetMeasurements() { if (!Done) return; double averagePitch = 0; double averageEnergy = 0; for (int i = 0; i < windowSize; i++) { averagePitch += blocks[i].pitch; averageEnergy += blocks[i].energy; } averagePitch /= windowSize; averageEnergy /= windowSize; double pitchSTD = 0; double energySTD = 0; for (int i = 0; i < windowSize; i++) { pitchSTD += Math.Pow(blocks[i].pitch - averagePitch, 2); energySTD += Math.Pow(blocks[i].energy - averageEnergy, 2); } pitchSTD /= windowSize; energySTD /= windowSize; measurements = new Measurements(averagePitch, Math.Sqrt(pitchSTD), Math.Sqrt(energySTD)); }