0

When I play my tune I made with AudioTrack, there are pauses in the sound. It is a sinwave and there should be none but there are pauses. why? here is my code:

        public IsochonicTone () : base(Stream.Music, 44100, ChannelOut.Mono, Encoding.Pcm16bit,52920, AudioTrackMode.Stream)
    {
        n2 = 0;
        Frequency = 1000;
        Amplitude = 1;
        flag = true;
        min = 52920;
    }

    public void play()
    {
        short[] buffer = new short[min];
        Play();
        while (n2 < 529200) 
        {
            for (int n = 0; n < min;n++) {

                    float temp1 = (float)( Amplitude * Math.Sin ((2 * Math.PI * Frequency * n2) / 44100D));
                    buffer [n] = (short)(temp1 * short.MaxValue);

                }
                n2++;
            }
            Write (buffer, 0, min);
        }

so you all know n2 is a static int. also I do have play() running on a different thread.

button.Click += delegate {

            track = new IsochonicTone();
            track.Frequency = Convert.ToDouble(Frequencytext.Text);
            ThreadPool.QueueUserWorkItem(o=> track.play());
            test1.Text = string.Format ("{0}", track.State);

        };

0 Answers0