Example #1
0
        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);
        }
Example #2
0
        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);
        }