Пример #1
0
        private void btnWav_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string sound = SaveFile();

            SaveFileDialog o = new SaveFileDialog();

            o.FileName = SearchFile().name;
            o.Filter   = "WAVE (*.wav)|*.wav";
            if (o.ShowDialog() == DialogResult.OK)
            {
                string wavSaved = o.FileName;

                switch (SearchFile().type)
                {
                case FormatSound.SWAV:
                    WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), false), wavSaved);
                    break;

                case FormatSound.STRM:
                    WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), false), wavSaved);
                    break;
                }
            }

            File.Delete(sound);
            this.Cursor = Cursors.Default;
        }
Пример #2
0
        private void btnReproducir_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                btnStop.PerformClick();

                if (File.Exists(wavFile))
                {
                    File.Delete(wavFile);
                }
                if (File.Exists(loopFile))
                {
                    File.Delete(loopFile);
                }

                string sound = SaveFile();
                wavFile = Path.GetTempFileName();
                if (checkLoop.Checked)
                {
                    loopFile = Path.GetTempFileName();
                }

                switch (SearchFile().type)
                {
                case FormatSound.SWAV:
                    WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), false), wavFile);
                    if (checkLoop.Checked)
                    {
                        WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), true), loopFile);
                    }
                    break;

                case FormatSound.STRM:
                    WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), false), wavFile);
                    if (checkLoop.Checked)
                    {
                        WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), true), loopFile);
                    }
                    break;
                }

                File.Delete(sound);

                if (checkLoop.Checked)
                {
                    bgdWorker = new Thread(bgdWorker_DoWork);
                    bgdWorker.Start(new String[] { wavFile, loopFile });
                }
                else
                {
                    soundPlayer = new SoundPlayer(wavFile);
                    soundPlayer.Play();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Пример #3
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            Sound  selectedFile = SearchFile();
            String fileout      = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName();

            OpenFileDialog o = new OpenFileDialog();

            o.CheckFileExists = true;
            o.AddExtension    = true;
            o.DefaultExt      = "wav";
            o.Filter          = "WAVE audio format (*.wav)|*.wav";
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            String filein = o.FileName;

            sWAV wav = new sWAV();

            try { wav = WAV.Read(filein); }
            catch (Exception ex) { MessageBox.Show(ex.Message); return; }

            NewAudioOptions dialog = new NewAudioOptions(pluginHost, (selectedFile.type == FormatSound.SWAV ? true : false));

            switch (selectedFile.type)
            {
            case FormatSound.STRM:
                sSTRM oldStrm = STRM.Read(SaveFile());
                dialog.Compression = oldStrm.head.waveType;
                dialog.BlockSize   = (int)oldStrm.head.blockLen;
                dialog.Loop        = (oldStrm.head.loop != 0 ? true : false);
                dialog.LoopOffset  = (int)oldStrm.head.loopOffset;
                dialog.SampleRate  = (int)wav.wave.fmt.sampleRate;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                sSTRM strm = STRM.ConvertToSTRM(wav, dialog.Compression);
                strm.head.loop       = (byte)(dialog.Loop ? 0x01 : 0x00);
                strm.head.loopOffset = (uint)dialog.LoopOffset;

                STRM.Write(strm, fileout);
                break;

            case FormatSound.SWAV:
                sSWAV oldSwav = SWAV.Read(SaveFile());
                dialog.Compression = oldSwav.data.info.nWaveType;
                dialog.Loop        = (oldSwav.data.info.bLoop != 0 ? true : false);
                dialog.LoopLength  = (int)oldSwav.data.info.nNonLoopLen;
                dialog.LoopOffset  = (int)oldSwav.data.info.nLoopOffset;
                dialog.SampleRate  = (int)wav.wave.fmt.sampleRate;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                sSWAV swav = SWAV.ConvertToSWAV(wav, dialog.Compression, dialog.Volume);

                swav.data.info.bLoop       = (byte)(dialog.Loop ? 0x01 : 0x00);
                swav.data.info.nLoopOffset = (ushort)dialog.LoopOffset;
                swav.data.info.nNonLoopLen = (uint)dialog.LoopLength;

                SWAV.Write(swav, fileout);
                break;

            case FormatSound.SSEQ:
            case FormatSound.SSAR:
            case FormatSound.SBNK:
            case FormatSound.SWAR:
            default:
                break;
            }

            if (!File.Exists(fileout))
            {
                return;
            }
            ChangeFile((int)selectedFile.id, fileout);
        }
Пример #4
0
        private void btnInfo_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> info = new Dictionary <string, string>();

            switch (SearchFile().type)
            {
            case FormatSound.STRM:
                info = STRM.Information(STRM.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAV:
                info = SWAV.Information(SWAV.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAR:
                info = SWAR.Information(SWAR.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SSEQ:
                break;

            case FormatSound.SSAR:
                break;

            case FormatSound.SBNK:
                break;

            default:
                break;
            }


            Form ven = new Form();

            ven.Size            = new System.Drawing.Size(260, 440);
            ven.FormBorderStyle = FormBorderStyle.FixedDialog;
            ven.ShowIcon        = false;
            ven.MaximizeBox     = false;
            ven.MinimizeBox     = false;
            ven.Icon            = Icon.FromHandle(Properties.Resources.information.GetHicon());

            ListView     list    = new ListView();
            ColumnHeader column1 = new ColumnHeader();

            column1.Text = columnCampo.Text;
            ColumnHeader column2 = new ColumnHeader();

            column2.Text = columnValor.Text;
            list.Columns.Add(column1);
            list.Columns.Add(column2);

            foreach (String value in info.Keys)
            {
                if (value.StartsWith("/b"))
                {
                    String text = value.Replace("/b", "");
                    list.Items.Add(text, text, 0);
                    list.Items[text].Font = new Font("Microsoft Sans Serif", 9, FontStyle.Bold);
                    list.Items[text].SubItems.Add(info[value]);
                }
                else
                {
                    list.Items.Add(value, value, 0);
                    list.Items[value].SubItems.Add(info[value]);
                }
            }
            list.Size = new System.Drawing.Size(250, 430);
            list.View = View.Details;
            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.Dock = DockStyle.Fill;
            ven.Controls.Add(list);
            ven.Text = btnInfo.Text;
            ven.Show();
        }