Troubleshooting Wavefile Tones: Fixing Unwanted Low Tone Beats in Your Code

  • Thread starter btb4198
  • Start date
In summary, the conversation is about creating a tone file that is not sounding the way the speaker wants it to sound. They are using code and have added a low tone beat to the file, but they do not know why it is there. The speaker is using two channels for the audio and is writing the sample twice in two different places. They also mention using a frequency of 180 Hz, an amplitude of 0.05 db, and a beat of 10 Hz.
  • #1
btb4198
572
10
I am trying to make a tone file and it is working. but it is not sounding the way I want it to sound. There is a low tone beat in the file. that I did not add to it. And I do not know why it is there.. here is my code:

Code:
   wavefile = new WaveFileWriter(save1.FileName, tone.WaveFormat);
   double counter2 = 0;
   double Frequency3 = Convert.ToDouble(FREtx3.Text);
   double Amplitude3 = Convert.ToDouble(PeakTXT3.Text);
   Beat = Convert.ToDouble(isochronictxt.Text);
   if (Beat != 0)
   {
      Beat = (1 / Beat);
   }
   else
  {
      Beat = 0;
  }
  for (int n = 0; n < time; n++)
  {
      if (counter2 >= Beat)
     {
          for (int t = 0; t < 10000; t++)
          {
               wavefile.WriteSample(0F);
               wavefile.WriteSample(0F);
                                    
          }

          counter2 = 0;
     }
     else
     {
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          counter2 = counter2 + (1D / 44100D);     
     }
  }
  wavefile.Flush();
  wavefile.Dispose();
  file.Add(save1.FileName);
 }
where is that tone coming from ?
https://onedrive.live.com/redir?resid=CC8AF223519E2440!114&authkey=!ADGTKdZEpF4F4Q4&ithint=file,.wav

you can download the song file there...
where is that lost tone coming from ??
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
btb4198 said:
I am trying to make a tone file and it is working. but it is not sounding the way I want it to sound. There is a low tone beat in the file. that I did not add to it. And I do not know why it is there.. here is my code:

Code:
   wavefile = new WaveFileWriter(save1.FileName, tone.WaveFormat);
   double counter2 = 0;
   double Frequency3 = Convert.ToDouble(FREtx3.Text);
   double Amplitude3 = Convert.ToDouble(PeakTXT3.Text);
   Beat = Convert.ToDouble(isochronictxt.Text);
   if (Beat != 0)
   {
      Beat = (1 / Beat);
   }
   else
  {
      Beat = 0;
  }
  for (int n = 0; n < time; n++)
  {
      if (counter2 >= Beat)
     {
          for (int t = 0; t < 10000; t++)
          {
               wavefile.WriteSample(0F);
               wavefile.WriteSample(0F);
                                    
          }

          counter2 = 0;
     }
       }else
     {
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          counter2 = counter2 + (1D / 44100D);     
     }

  wavefile.Flush();
  wavefile.Dispose();
  file.Add(save1.FileName);
 }


where is that tone coming from ?
https://onedrive.live.com/redir?resid=CC8AF223519E2440!114&authkey=!ADGTKdZEpF4F4Q4&ithint=file,.wav

you can download the song file there...
where is that lost tone coming from ??

Why are you writing the sample twice (in two places)? The places I'm referring to are here
Code:
for (int t = 0; t < 10000; t++)
          {
               wavefile.WriteSample(0F);
               wavefile.WriteSample(0F);
                                    
          }
and here
Code:
else
     {
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          wavefile.WriteSample((float)Math.Abs((Amplitude3 * Math.Sin((2 * Math.PI * n * Frequency3) / 44100))));
          counter2 = counter2 + (1D / 44100D);     
     }
Just a guess, but the sound you're hearing might be the part of the audio at the end of the first write and at the beginning of the next.

Also, it might be informative to know what frequency, amplitude, and beat you're using, all of which apparently come from some text files.
 
  • #3
I am using two channels, so i want both changes to play the same points and the same time. so the even indices are like the right channel and the old indices are the left channel.

Also I do not understand what you mean by "Just a guess, but the sound you're hearing might be the part of the audio at the end of the first write and at the beginning of the next."Frequency is 180 Hz
amplitude is 0.05 db
and beat is 10 Hz
 

What is a Wavefile tone?

A Wavefile tone is a type of audio file that represents sound as a series of digital samples. It is commonly used in digital audio recording and playback.

How is a Wavefile tone created?

A Wavefile tone is typically created by converting an analog signal into a digital one through a process called sampling. This involves taking measurements of the sound wave at regular intervals and converting them into binary code.

What are the characteristics of a Wavefile tone?

A Wavefile tone can vary in characteristics such as frequency, amplitude, and duration. It can also have different formats, such as mono or stereo, and different bit depths and sample rates.

What are the common uses of Wavefile tones?

Wavefile tones are commonly used in audio recording, playback, and editing software. They are also used in creating sound effects, music, and other audio content for various multimedia applications.

How do Wavefile tones differ from other audio file formats?

Wavefile tones are uncompressed, meaning they retain all of the original audio data without any loss. This makes them larger in size compared to compressed audio formats, but they offer higher sound quality and are more versatile in terms of editing and processing capabilities.

Similar threads

Replies
18
Views
2K
Back
Top