Exemplo n.º 1
0
        private double GetCurrentAmplitude(int sampleNumber)
        {
            var timePass    = sampleNumber / Processor.SampleRate;
            var currentTime = _time + timePass;
            var sample      = WaveGenerator.GenerateNextSample(OscillatorType.Value, Frequency.Value, currentTime);

            return(sample);
        }
Exemplo n.º 2
0
        private void GenerateToneToStream(Tone tone)
        {
            var leftChannel  = _stream.Channels[0];
            var rightChannel = _stream.Channels[1];

            double timeDelta = 1.0 / Processor.SampleRate;
            var    count     = Processor.CurrentStreamLenght;

            for (int i = 0; i < count; ++i)
            {
                var frequency = GetToneFrequency(tone.Note, i);
                var sample    = WaveGenerator.GenerateNextSample(OscillatorType.Value, frequency, tone.Time);

                sample *= Volume.ProcessedValue(i);

                var panR = Panning.ProcessedValue(i);
                var panL = 1 - panR;

                leftChannel.Samples[i]  += sample * panL;
                rightChannel.Samples[i] += sample * panR;

                tone.Time += timeDelta;
            }
        }