Пример #1
0
        private void playSoundPlaybackBox_Click(object sender, EventArgs e)
        {
            try
            {
                player.Stop();
                player.Dispose();
            }
            catch { }

            try
            {
                waveStream.Dispose();
                waveChannel.Dispose();
            }
            catch { }

            //Convert swav to wav.
            swav s = new swav();

            swavFile = file.data[0].files[tree.SelectedNode.Index];
            s.load(swavFile);
            player             = new WaveOutEvent();
            waveStream         = new WaveFileReader(new MemoryStream(s.toRIFF().toBytes()));
            waveChannel        = new WaveChannel32(waveStream);
            waveChannel.Volume = (float)volume.Value * (float).01;
            player.Init(waveChannel);
            player.Play();
            //loopRef = s;
            s.data.info.loopFlag = 0;
            if (s.data.info.loopFlag == 1)
            {
                player.PlaybackStopped += new EventHandler(loopSound);
            }
            else
            {
                player.PlaybackStopped += new EventHandler(stopSoundPlaybackBox_Click);
            }
            if (s.data.info.loopFlag != 1)
            {
                Thread.Sleep(500);
            }
        }
Пример #2
0
        private void Export_Click(object sender, EventArgs e)
        {
            SaveFileDialog f = new SaveFileDialog();

            f.Filter   = "Supported Files|*.swav;*.wav|Swav File|*.swav|Wave|*.wav";
            f.Title    = "Export the file";
            f.FileName = tree.SelectedNode.Text;
            f.ShowDialog();

            if (f.FileName != "")
            {
                if (f.FileName.EndsWith(".swav"))
                {
                    f.FilterIndex = 1;
                }
                if (f.FileName.EndsWith(".wav"))
                {
                    f.FilterIndex = 2;
                }

                if (f.FilterIndex == 1)
                {
                    File.WriteAllBytes(f.FileName, file.data[0].files[tree.SelectedNode.Index]);
                }
                else
                {
                    swav s = new swav();
                    s.load(file.data[0].files[tree.SelectedNode.Index]);
                    bool includeLoop = false;
                    if (s.data.info.loopFlag == 1)
                    {
                        includeLoop = true;
                    }
                    File.WriteAllBytes(f.FileName, s.toRIFF().toBytes(true, includeLoop));
                }
            }
        }