Пример #1
0
        public override void Init()
        {
            NAudio.CoreAudioApi.MMDeviceEnumerator a = new NAudio.CoreAudioApi.MMDeviceEnumerator();
            var dev = a.GetDefaultAudioEndpoint(NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.Role.Multimedia);
            o = new WasapiOut(dev,NAudio.CoreAudioApi.AudioClientShareMode.Shared,false, 50);

            //o = new WaveOut();
            bwp = new BufferedWaveProvider(WaveFormat.CreateIeeeFloatWaveFormat(16000, 1));
            bwp.BufferDuration = TimeSpan.FromMilliseconds(2000);
            bwp.DiscardOnBufferOverflow = true;
            o.Init(bwp);
            o.Play();
            //delaypos = 0;
        }
Пример #2
0
        public override void Init()
        {
            NAudio.CoreAudioApi.MMDeviceEnumerator a = new NAudio.CoreAudioApi.MMDeviceEnumerator();
            var dev = a.GetDefaultAudioEndpoint(NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.Role.Multimedia);

            o = new WasapiOut(dev, NAudio.CoreAudioApi.AudioClientShareMode.Shared, false, 50);

            //o = new WaveOut();
            bwp = new BufferedWaveProvider(WaveFormat.CreateIeeeFloatWaveFormat(16000, 1));
            bwp.BufferDuration          = TimeSpan.FromMilliseconds(2000);
            bwp.DiscardOnBufferOverflow = true;
            o.Init(bwp);
            o.Play();
            //delaypos = 0;
        }
Пример #3
0
 protected virtual void LoadAudio()
 {
     if ((Path.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase)) || (Path.EndsWith(".wav", StringComparison.OrdinalIgnoreCase)))
     {
         if (audio != null)
         {
             audio.Dispose();
         }
         audio = new NAudio.Wave.AudioFileReader(Path);
         output.Init(audio);
     }
     else
     {
         throw new FileTypeException("File type must be .mp3 or .wav");
     }
 }