예제 #1
0
파일: Wave.cs 프로젝트: andrich48/pcsconv
        public static void WriteToFile(string file, Array samples, int sampleRate = 44100)
        {
            var writer = new WaveWriter();

            writer.SampleRate = sampleRate;
            using (var stream = new FileStream(file, FileMode.Create))
            {
                writer.WriteWave(stream, samples);
            }
        }
예제 #2
0
파일: Wave.cs 프로젝트: andrich48/pcsconv
        public void PlayWave(ISound wave, bool sync = false)
        {
            var samples = CreateWave <short>(wave);

            using (var buffer = new MemoryStream())
            {
                var writer = new WaveWriter();
                writer.SampleRate = SampleRate;
                writer.WriteWave(buffer, samples);
                buffer.Position = 0;

                var player = new SoundPlayer(buffer);
                if (sync)
                {
                    player.PlaySync();
                }
                else
                {
                    player.Play();
                }
            }
        }