Esempio n. 1
0
 ISoundOut CreateSoundOut(ref IWaveSource source)
 {
     ISoundOut soundOut;
     if (WasapiOut.IsSupportedOnCurrentPlatform)
         soundOut = new WasapiOut(true, AudioClientShareMode.Shared, 50);
     else
     {
         soundOut = new DirectSoundOut() { Latency = 100 };
         if (source.WaveFormat.BitsPerSample > 16)
             source = source.ToSampleSource().ToWaveSource(16);
     }
     return soundOut;
 }
        public void CanPlayMonoToStereoSourceTest()
        {
            var source = new StereoToMonoSource(CodecFactory.Instance.GetCodec(testfile));
            Assert.AreEqual(1, source.WaveFormat.Channels);

            var monoSource = new MonoToStereoSource(source);
            Assert.AreEqual(2, monoSource.WaveFormat.Channels);

            ISoundOut soundOut;
            if (WasapiOut.IsSupportedOnCurrentPlatform)
                soundOut = new WasapiOut();
            else
                soundOut = new DirectSoundOut();

            soundOut.Initialize(monoSource.ToWaveSource(16));
            soundOut.Play();

            Thread.Sleep((int)Math.Min(source.GetMilliseconds(source.Length), 60000));

            soundOut.Dispose();
        }
Esempio n. 3
0
        public void CanPlayStereoToMonoSource()
        {
            //in order to fix workitem 3

            var source = GlobalTestConfig.TestMp3().ToStereo();
            Assert.AreEqual(2, source.WaveFormat.Channels);

            var monoSource = new StereoToMonoSource(source.ToSampleSource());
            Assert.AreEqual(1, monoSource.WaveFormat.Channels);

            ISoundOut soundOut;
            if (WasapiOut.IsSupportedOnCurrentPlatform)
                soundOut = new WasapiOut();
            else
                soundOut = new DirectSoundOut();

            soundOut.Initialize(monoSource.ToWaveSource(16));
            soundOut.Play();

            Thread.Sleep((int)Math.Min(source.GetMilliseconds(source.Length), 20000));

            soundOut.Dispose();
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new CSCoreSoundProvider class.
 /// </summary>
 /// <param name="soundInitializer">The SoundInitializer.</param>
 internal DirectSoundProvider(ISoundInitializer soundInitializer)
 {
     _directSoundOut = new DirectSoundOut();
     SoundInitializer = soundInitializer;
     _directSoundOut.Stopped += DirectSoundOutStopped;
 }
Esempio n. 5
0
 /// <summary>
 /// Disposes the SoundProvider.
 /// </summary>
 /// <param name="disposing">The State.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (_directSoundOut != null)
         {
             Stop();
             _directSoundOut.Dispose();
             _directSoundOut = null;
         }
     }
     _disposed = true;
 }
Esempio n. 6
0
 public void OpenDirectSoundDevice()
 {
     DirectSoundOut dsoundOut = new DirectSoundOut();
     dsoundOut.Initialize(new CSCore.Streams.SineGenerator().ToWaveSource(16));
     dsoundOut.Dispose();
 }