This project has moved and is read-only. For the latest updates, please go here.

writing a tone to a file

May 14, 2014 at 7:41 PM
I am trying to write a tone to a file
this is my code
:
  SaveFileDialog save1 = new SaveFileDialog();
                    save1.Filter = "Wave file (*.wav)|*.wav;";
                    if (save1.ShowDialog() != DialogResult.OK) return;
                    WaveFileWriter wavefile = new WaveFileWriter(save1.FileName, sineWaveProvider.WaveFormat);
                    int f2 = 0;
                    if (flagtype == 0)
                    {
                        flagtype = 0;
                        if (Beat == 0)
                        {
                            f2 = 0;
                        }
                        else
                        {
                            f2 = Convert.ToInt16(Frequencytxt.Text) - Convert.ToInt16(beattxt.Text);
                        }
                        for (double n = 0; n < time; n++)
                        {
                            wavefile.WriteSample((float)(Amplitude * Math.Sin((2 * Math.PI * n * Frequency) / 44100)) + (float)(Amplitude * Math.Sin((2 * Math.PI * n * f2) / 44100)));  
                        }
                        wavefile.Flush();
                        file.Add(save1.FileName);
but when I try and open the file, it will not play
why?
May 14, 2014 at 8:09 PM
never mind I got it
Marked as answer by btb4198 on 5/14/2014 at 12:09 PM