Exemple #1
0
        private void tsbOpen_Click(object sender, EventArgs e)
        {
            if (ofdAudio.ShowDialog() == DialogResult.OK)
            {
                string       fileName = ofdAudio.FileName;
                IAudioReader arw      = null;
                switch (Path.GetExtension(fileName.ToLower()))
                {
                case ".avi":
                    arw = new AviReader(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                    if (!((AviReader)arw).HasAudio)
                    {
                        MessageBox.Show(string.Format("'{0}' file is not contains audio data", fileName));
                        return;
                    }
                    break;

                case ".au":
                case ".snd":
                    arw = new AuReader(File.OpenRead(fileName));
                    break;

                case ".wav":
                    arw = new WaveReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                    break;

                case ".mp3":
                    arw = new Mp3ReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                    break;

                default:
                    arw = new DsReader(fileName);
                    if (!((DsReader)arw).HasAudio)
                    {
                        MessageBox.Show(string.Format("'{0}' file is not contains audio data", fileName));
                        return;
                    }
                    break;
                    //FormatDialog fd = new FormatDialog(false);
                    //if (fd.ShowDialog() == DialogResult.OK)
                    //{
                    //    arw = new RawReadWriter(stream, fd.Format);
                    //    break;
                    //}
                    //else
                    //{
                    //    return;
                    //}
                }
                rp.Open(arw);
            }
        }
Exemple #2
0
        private void tsbNew_Click(object sender, EventArgs e)
        {
            if (sfdAudio.ShowDialog() == DialogResult.OK)
            {
                string           fileName = sfdAudio.FileName;
                Stream           stream   = null;
                IAudioReadWriter arw      = null;
                FormatDialog     fd       = null;
                switch (Path.GetExtension(fileName.ToLower()))
                {
                case ".wav":
                    fd = new FormatDialog(false);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new WaveReadWriter(stream, AudioCompressionManager.FormatBytes(fd.Format));
                        rp.Open(arw);
                    }
                    break;

                case ".mp3":
                    fd = new FormatDialog(true);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new Mp3ReadWriter(stream, fd.Format);
                        rp.Open(arw);
                    }
                    break;

                default:
                    fd = new FormatDialog(false);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new RawReadWriter(stream, fd.Format);
                        rp.Open(arw);
                    }
                    return;
                }
            }
        }
Exemple #3
0
 private void tsbOpen_Click(object sender, EventArgs e)
 {
     if (ofdAudio.ShowDialog() == DialogResult.OK)
     {
         string fileName = ofdAudio.FileName;
         IAudioReader arw = null;
         switch (Path.GetExtension(fileName.ToLower()))
         {
             case ".avi":
                 arw = new AviReader(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                 if (!((AviReader)arw).HasAudio)
                 {
                     MessageBox.Show(string.Format("'{0}' file is not contains audio data", fileName));
                     return;
                 }
                 break;
             case ".au":
             case ".snd":
                 arw = new AuReader(File.OpenRead(fileName));
                 break;
             case ".wav":
                 arw = new WaveReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                 break;
             case ".mp3":
                 arw = new Mp3ReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
                 break;
             default:
                 arw = new DsReader(fileName);
                 if (!((DsReader)arw).HasAudio)
                 {
                     MessageBox.Show(string.Format("'{0}' file is not contains audio data", fileName));
                     return;
                 }
                 break;
             //FormatDialog fd = new FormatDialog(false);
                 //if (fd.ShowDialog() == DialogResult.OK)
                 //{
                 //    arw = new RawReadWriter(stream, fd.Format);
                 //    break;
                 //}
                 //else
                 //{
                 //    return;
                 //}
         }
         rp.Open(arw);
     }
 }
Exemple #4
0
 private void tsbNew_Click(object sender, EventArgs e)
 {
     if (sfdAudio.ShowDialog() == DialogResult.OK)
     {
         string fileName = sfdAudio.FileName;
         Stream stream = null;
         IAudioReadWriter arw = null;
         FormatDialog fd = null;
         switch (Path.GetExtension(fileName.ToLower()))
         {
             case ".wav":
                 fd = new FormatDialog(false);
                 if (fd.ShowDialog() == DialogResult.OK)
                 {
                     stream = File.Create(fileName);
                     arw = new WaveReadWriter(stream, AudioCompressionManager.FormatBytes(fd.Format));
                     rp.Open(arw);
                 }
                 break;
             case ".mp3":
                 fd = new FormatDialog(true);
                 if (fd.ShowDialog() == DialogResult.OK)
                 {
                     stream = File.Create(fileName);
                     arw = new Mp3ReadWriter(stream, fd.Format);
                     rp.Open(arw);
                 }
                 break;
             default:
                 fd = new FormatDialog(false);
                 if (fd.ShowDialog() == DialogResult.OK)
                 {
                     stream = File.Create(fileName);
                     arw = new RawReadWriter(stream, fd.Format);
                     rp.Open(arw);
                 }
                 return;
         }
     }
 }