/// ------------------------------------------------------------------------------------ /// <summary> /// Converts the specified millisecond value to a byte offset used (and only understood /// by SA) for altered speed playback in SA. /// </summary> /// ------------------------------------------------------------------------------------ public static long MillisecondValueToBytes(long millisecondVal, string filename) { using (var reader = new AudioReader()) { if (reader.Initialize(filename) == AudioReader.InitResult.FileNotFound) { return(0); } // Assume the bytes per second is 44100, which it will be if the audio file // is not a wave file. long bytesPerSecond = 44100; if (reader.IsValidWaveFile()) { bytesPerSecond = reader.BytesPerSecond; } return((millisecondVal * bytesPerSecond) / 1000); } }