Esempio n. 1
0
        public static void CreateWave(Stream oggStream, Stream wavStream)
        {
            VorbisWaveReader       vorbisReader = new VorbisWaveReader(oggStream);
            SampleToWaveProvider16 converter    = new SampleToWaveProvider16(vorbisReader);

            using (var writer = new WaveFileWriter(wavStream, converter.WaveFormat))
            {
                int loopCount = 0;
                var buffer    = new byte[converter.WaveFormat.AverageBytesPerSecond * 4];
                while (true)
                {
                    loopCount++;
                    Debug.WriteLine("looped: " + loopCount.ToString());

                    int bytesRead = converter.Read(buffer, 0, buffer.Length);
                    if (bytesRead == 0)
                    {
                        // end of source provider
                        break;
                    }

                    // Write will throw exception if WAV file becomes too large
                    writer.Write(buffer, 0, bytesRead);
                }
            }

            vorbisReader.Dispose();
        }
Esempio n. 2
0
 public void StopSound(string id)
 {
     NAudio.Vorbis.VorbisWaveReader data = _soundMap[id];
     if (data != null)
     {
         soundPlayer.Stop();
         data.Position = 0;
         data.Dispose();
         _soundMap.Remove(id);
     }
 }
Esempio n. 3
0
 public void StopMusic(string id)
 {
     NAudio.Vorbis.VorbisWaveReader data = _musicMap[id];
     if (data != null)
     {
         musicPlayer.Stop();
         data.Position = 0;
         data.Dispose();
         _musicMap.Remove(id);
     }
 }