예제 #1
0
        protected override double[] generate(int nSamples)
        {
            double[] outData = new double[nSamples];
            Random   rand    = new Random(); //if a new random is created every time, it doesn't update fast enough!

            int       freqInSamples = (int)((1 / freq) * SynthesisBase.SampleRate);
            int       numChunks     = nSamples / freqInSamples;
            WaveAudio chunk         = null;

            for (int i = 0; i < numChunks; i++)
            {
                if (i % this.chunksbeforeswitch == 0)
                {
                    if (chunk == null)
                    {
                        //seed with Sine wave
                        chunk = new Sine(210, amplitude / 4).CreateWaveAudio(1 / freq + 0.01);
                    }
                    else
                    {
                        WaveAudio newchunk = new RedNoise(amplitude, rednoisefactor, rand).CreateWaveAudio(1 / freq + 0.01);
                        chunk = WaveAudio.Mix(chunk, this.smoothing, newchunk, 1 - this.smoothing);
                    }
                }
                Array.Copy(chunk.data[0], 0, outData, i * freqInSamples, freqInSamples);
            }
            //fill in the rest
            if (numChunks * freqInSamples < nSamples)
            {
                Array.Copy(chunk.data[0], 0, outData, numChunks * freqInSamples, nSamples - numChunks * freqInSamples);
            }

            return(outData);
        }
예제 #2
0
        public override WaveAudio CreateWaveAudio(double fSeconds)
        {
            WaveAudio w1 = new CircleWave(frequency, amplitude).CreateWaveAudio(fSeconds);
            WaveAudio w2 = new CircleWave(frequency * 0.9939577, amplitude).CreateWaveAudio(fSeconds);
            WaveAudio w3 = new CircleWave(frequency * 0.98489425, amplitude).CreateWaveAudio(fSeconds);

            return(WaveAudio.Mix(WaveAudio.Mix(w1, 0.66, w2, 0.33), 0.66, w3, 0.33));
        }
예제 #3
0
        public static WaveAudio Flange(WaveAudio w1, double parameter)
        {
            WaveAudio w2 = Effects.ScalePitchAndDuration(w1, parameter);

            return(WaveAudio.Mix(w1, w2));
        }