Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: savefile

$
0
0
i am making my own tones, and mix then with other files...
is that a way to add a timer ? so it will stop.
this is what I am doing now:
{
    public class BinauralBeats : WaveProvider32
    {
        int sample;
        Boolean counter;
       public BinauralBeats()
        {
            RightF = 500;
            LeftF = 410; 
            Amplitude = 0.25f; // let's not hurt our ears  
            counter = true;
        }
       public float RightF { get; set; }
       public float Amplitude { get; set; }
       public float LeftF { get; set; }
       public override int Read(float[] buffer, int offset, int sampleCount)
       {
           int sampleRate = WaveFormat.SampleRate;
           for (int n = 0; n < sampleCount; n++)
           {
               if (counter == true)
               {
                   buffer[n + offset] = (float)(Amplitude * Math.Sin((2 * Math.PI * sample * RightF) / sampleRate));
                   sample++;
                   counter = false; 
                   if (sample >= sampleRate) sample = 0;
               }
               else
               {
                   counter = true;
                   buffer[n + offset] = (float)(Amplitude * Math.Sin((2 * Math.PI * sample * LeftF) / sampleRate));
                   sample++;
                   if (sample >= sampleRate) sample = 0;

               }
           }
           return sampleCount;
          
       }
ok is works if I mex the files without adding a tone... so you are right the tones are not stop ...
how can i add a time for them?
like if I only want them to play for 10s?

Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>