Ejemplo n.º 1
0
 public Main()
 {
     try
     {
         InitializeComponent();
         logText.ScrollBars = ScrollBars.Vertical;
         logText.ReadOnly   = true;
     }
     catch (Exception e)
     {
         ExceptionForm form = new ExceptionForm(e.Message);
         form.Show();
     }
 }
Ejemplo n.º 2
0
        //JOINS WAVE FILES TOGETHER USING NAUDIO LIBRARY
        public static void Concatenate(string outputFile, IEnumerable <string> sourceFiles)
        {
            byte[]         buffer         = new byte[1024];
            WaveFileWriter waveFileWriter = null;

            try
            {
                foreach (string sourceFile in sourceFiles)
                {
                    using (WaveFileReader reader = new WaveFileReader(sourceFile))
                    {
                        if (waveFileWriter == null)
                        {
                            waveFileWriter = new WaveFileWriter(outputFile, reader.WaveFormat);
                        }
                        else
                        {
                            if (!reader.WaveFormat.Equals(waveFileWriter.WaveFormat))
                            {
                                throw new InvalidOperationException("Can't concatenate a WAV file with another format!");
                            }
                        }

                        int read;
                        while ((read = reader.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            waveFileWriter.Write(buffer, 0, read);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionForm form = new ExceptionForm(e.Message);
                form.Show();
            }
            finally
            {
                if (waveFileWriter != null)
                {
                    waveFileWriter.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        private void annihilateClick(object sender, EventArgs e)
        {
            DialogResult box = MessageBox.Show("Are you sure you want to delete " +
                                               "all the generated files? " +
                                               "\nWARNING: All WAV files in each " +
                                               "Creations subfolder will be DELETED.",
                                               "Warning!", MessageBoxButtons.YesNo,
                                               MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

            if (box == DialogResult.Yes)
            {
                DirectoryInfo di  = new DirectoryInfo(formPath + "\\Creations\\VOX");
                DirectoryInfo di2 = new DirectoryInfo(formPath + "\\Creations\\HEV");
                DirectoryInfo di3 = new DirectoryInfo(formPath + "\\Creations\\Human Grunt");

                FileInfo[] files = di.GetFiles("*.wav")
                                   .Where(p => p.Extension == ".wav").ToArray();
                FileInfo[] files2 = di2.GetFiles("*.wav")
                                    .Where(p => p.Extension == ".wav").ToArray();
                FileInfo[] files3 = di3.GetFiles("*.wav")
                                    .Where(p => p.Extension == ".wav").ToArray();
                foreach (FileInfo file in files)
                {
                    try
                    {
                        file.Attributes = FileAttributes.Normal;
                        File.Delete(file.FullName);
                    }
                    catch (IOException ioexc)
                    {
                        ExceptionForm form = new ExceptionForm(ioexc.Message);
                        form.Show();
                    }
                }
                foreach (FileInfo file in files2)
                {
                    try
                    {
                        file.Attributes = FileAttributes.Normal;
                        File.Delete(file.FullName);
                    }
                    catch (IOException ioexc)
                    {
                        ExceptionForm form = new ExceptionForm(ioexc.Message);
                        form.Show();
                    }
                }
                foreach (FileInfo file in files3)
                {
                    try
                    {
                        file.Attributes = FileAttributes.Normal;
                        File.Delete(file.FullName);
                    }
                    catch (IOException ioexc)
                    {
                        ExceptionForm form = new ExceptionForm(ioexc.Message);
                        form.Show();
                    }
                }
                logText.Text += "Cleared all user generated sentences." + Environment.NewLine;
            }
            else if (box == DialogResult.No)
            {
                return;
            }
        }