MixingWave problem

Aug 5 at 7:53 AM
Edited Aug 5 at 1:03 PM
hi
I use MixingWaveProvider32 to get a mixture of the three signals.
But while playing I hear the clicks at regular intervals ~ 1 second (stuttering, I do not know how to be more precise to call this sound).
What could be the problem?
var sineWaveProvider = new SineWaveProvider32();
sineWaveProvider.SetWaveFormat(44100, 2);
sineWaveProvider.Frequency = 261.6f;
sineWaveProvider.Amplitude = 0.5f;
                
var sineWaveProvider2 = new SineWaveProvider32();
ineWaveProvider2.SetWaveFormat( 44100, 2 );
sineWaveProvider2.Frequency = 329.6f;
sineWaveProvider2.Amplitude = 0.5f;
                
var sineWaveProvider3 = new SineWaveProvider32();
sineWaveProvider3.SetWaveFormat( 44100, 2 );
sineWaveProvider3.Frequency = 392.0f;
sineWaveProvider3.Amplitude = 0.5f;

var providersList = new List<WaveProvider32>();
providersList.Add(sineWaveProvider);
providersList.Add(sineWaveProvider2);
providersList.Add(sineWaveProvider3);
                
var mixer = new MixingWaveProvider32(providersList);


recorder = new WaveRecorder( mixer, @"C:\1.wav" );
                waveOut = new WaveOut();
                waveOut.Init( recorder );
                waveOut.Play();



public class SineWaveProvider32 : WaveProvider32 {
        int sample;

        public SineWaveProvider32 ( ) {
            Frequency = 1000;
            Amplitude = 0.25f; // let's not hurt our ears            
        }

        public float Frequency { get; set; }
        public float Amplitude { get; set; }

        public override int Read ( float[] buffer, int offset, int sampleCount ) {
            int sampleRate = WaveFormat.SampleRate;
            for ( int n = 0; n < sampleCount; n++ ) {
                buffer[n + offset] = (float) (Amplitude * Math.Sin( (2 * Math.PI * sample * Frequency) / sampleRate ));
                //sample++;
                // http://mark-dot-net.blogspot.ru/2009/10/playback-of-sine-wave-in-naudio.html
                // Rudi's comment
                // fix Bad work with stereo 
                if ( this.WaveFormat.Channels == 1 || (n + offset) % 2 == 0 ) sample++; 
                if ( sample >= sampleRate ) sample = 0;
            }
Aug 6 at 7:03 AM
Edited Aug 6 at 7:21 AM
stuttering occurs when the value of the frequency is an integer number
With 500Hz no stuttering. at 500.1 - there is stuttering. Does anyone have any idea why there is stuttering?
Coordinator
Aug 6 at 9:40 AM
it's the line setting sample to 0. Comment that out and see if it improves things.
Alternatively make sample a double and subtract sampleRate from it rather than setting it to zero.