private int GetSampleLength(string path) { IAudioSource audioSource; audioSource = AudioReadWrite.GetAudioSource(path); audioSource.Close(); if ((audioSource.BitsPerSample != 16) || (audioSource.ChannelCount != 2) || (audioSource.SampleRate != 44100) || (audioSource.Length > Int32.MaxValue)) { throw new Exception("Audio format is invalid."); } return((int)audioSource.Length); }
private IAudioSource GetAudioSource(int sourceIndex) { SourceInfo sourceInfo = _sources[sourceIndex]; IAudioSource audioSource; if (sourceInfo.Path == null) { audioSource = new SilenceGenerator(sourceInfo.Offset + sourceInfo.Length); } else { audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path); } audioSource.Position = sourceInfo.Offset; return(audioSource); }
private IAudioDest GetAudioDest(string path, int finalSampleCount) { IAudioDest dest = AudioReadWrite.GetAudioDest(path, 16, 2, 44100, finalSampleCount); if (dest is FLACWriter) { FLACWriter w = (FLACWriter)dest; w.CompressionLevel = _flacCompressionLevel; w.Verify = _flacVerify; } if (dest is WavPackWriter) { WavPackWriter w = (WavPackWriter)dest; w.CompressionMode = _wvCompressionMode; w.ExtraMode = _wvExtraMode; } return(dest); }