private static async Task <CachedSound> CreateFromFile(string filePath) { using (var audioFileReader = await WaveFormatFactory.GetResampledAudioFileReader(filePath, WaveStreamType).ConfigureAwait(false)) { var wholeData = new List <float>((int)(audioFileReader.Length / 4)); var readBuffer = new float[audioFileReader.WaveFormat.SampleRate * audioFileReader.WaveFormat.Channels]; int samplesRead; while ((samplesRead = audioFileReader.Read(readBuffer, 0, readBuffer.Length)) > 0) { wholeData.AddRange(readBuffer.Take(samplesRead)); } var cachedSound = new CachedSound(filePath) { AudioData = wholeData.ToArray(), Duration = audioFileReader.TotalTime, WaveFormat = audioFileReader.WaveFormat, }; return(cachedSound); } }
protected bool Equals(CachedSound other) { return(SourcePath == other.SourcePath); }
public CachedSoundSampleProvider(CachedSound cachedSound) { SourceSound = cachedSound; //Length = cachedSound.Length; }