- #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..
Someone told me to try fading out / fade in and not just going down to 0 and I did but it did not work.
can anyone help me ?
I just need to remove the ticking and output the right Frequency
here is my code:
What am I doing wrong?
here is how it sounds
https://onedrive.live.com/redir?resid=CC8AF223519E2440!119&authkey=!AAFtwo79tic33IA&ithint=file,.wav
Someone told me to try fading out / fade in and not just going down to 0 and I did but it did not work.
can anyone help me ?
I just need to remove the ticking and output the right Frequency
here is my code:
Code:
tone = new isochronicTone();
tone.SetWaveFormat(44100, 2);
double time = Convert.ToDouble(time2.Text) / 2.2675;
time = time * 50000D;
double Amplitude = Convert.ToDouble(Peaktxt.Text);
SaveFileDialog save1 = new SaveFileDialog();
save1.Filter = "Wave file (*.wav)|*.wav;";
if (save1.ShowDialog() != DialogResult.OK) return;
WaveFileWriter wavefile;
wavefile = new WaveFileWriter(save1.FileName, tone.WaveFormat);
double counter3 = 0;
double tenp = 0;
double Ptemp = Peak3 - 0.001D;
int newcounter = 0;
if (Beat3 != 0)
{
Beat3 = (1 / Beat3);
tenp = Beat3/(1D / 44100D);
}
else
{
Beat3 = 0;
}
for (int n = 0; n < time; n++)
{
if (counter3 >= Beat3 && Beat3 != 0)
{
for (int t = 0; t < tenp; t++)
{
if (Ptemp > 0.000005)
{
float temo = (float)(Ptemp * Math.Sin((((Math.PI * n * (Frequency3))/2) / 44100D)));
wavefile.WriteSample(temo);
wavefile.WriteSample(temo);
n++;
Ptemp = Ptemp - 0.001D;
newcounter++;
}
else if ((tenp - newcounter) <= 0 )
{
float temo = (float)(Ptemp * Math.Sin((((Math.PI * n * (Frequency3))/2) / 44100D)));
wavefile.WriteSample(temo);
wavefile.WriteSample(temo);
n++;
Ptemp = Ptemp + 0.001D;
}
else
{
wavefile.WriteSample(0F);
wavefile.WriteSample(0F);
n++;
}
}
counter3 = 0;
}
else
{
float temo = (float)(Peak3 * Math.Sin(((( Math.PI * n * (Frequency3))/2)/44100D)));
wavefile.WriteSample(temo);
wavefile.WriteSample(temo);
counter3 = counter3 + (1D / 44100D);
Ptemp = Peak3 - 0.001D;
newcounter = 0;
}
}
wavefile.Flush();
wavefile.Dispose();
if (waveout == null)
{
waveout = new WaveOut();
waveout.PlaybackStopped += onPlaybackStopped;
}
MixingSampleProvider mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100,2));
audioFileReader = new AudioFileReader(save1.FileName);
mixer.AddMixerInput((ISampleProvider)audioFileReader);
SampleToWaveProvider mixer3 = new SampleToWaveProvider(mixer);
try
{
waveout.Init(mixer3);
waveout.Play();
timer1.Start();
}
catch
{
MessageBox.Show(" Error retry");
waveout.Stop();
waveout.Dispose();
waveout = null;
return;
}
here is how it sounds
https://onedrive.live.com/redir?resid=CC8AF223519E2440!119&authkey=!AAFtwo79tic33IA&ithint=file,.wav