Ejemplo n.º 1
0
        public OscFMProgrammer(string name, Oscillator osc, EmptyMonoComponent emptyFMSource, AdsrEnvelope env1, AdsrEnvelope env2, Lfo lfo1, Lfo lfo2)
        {
            #region Require

            if (osc == null)
            {
                throw new ArgumentNullException("osc");
            }
            else if (emptyFMSource == null)
            {
                throw new ArgumentNullException("emptyFMSource");
            }
            else if (env1 == null)
            {
                throw new ArgumentNullException("env1");
            }
            else if (env2 == null)
            {
                throw new ArgumentNullException("env2");
            }
            else if (lfo1 == null)
            {
                throw new ArgumentNullException("lfo1");
            }
            else if (lfo2 == null)
            {
                throw new ArgumentNullException("lfo2");
            }

            #endregion

            this.name = name;
            this.osc = osc;
            this.emptyFMSource = emptyFMSource;
            this.env1 = env1;
            this.env2 = env2;
            this.lfo1 = lfo1;
            this.lfo2 = lfo2;
        }
Ejemplo n.º 2
0
        private void Initialize(SampleRate sampleRate, StereoBuffer buffer)
        {
            emptyFMModulator = new EmptyMonoComponent(sampleRate, new MonoBuffer(0));

            slewLimiter = new SlewLimiter(sampleRate, new MonoBuffer(0), "Portamento");
            slewLimiter.SynthesizeReplaceEnabled = true;

            envelope1 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 1");
            envelope1.SynthesizeReplaceEnabled = true;

            envelope2 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 2");
            envelope2.SynthesizeReplaceEnabled = true;

            lfo1 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 1");
            lfo1.SynthesizeReplaceEnabled = true;

            lfo2 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 2");
            lfo2.SynthesizeReplaceEnabled = true;

            Wavetable wave = Wavetable.Load("Sawtooth");

            osc1 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 1", wave, emptyFMModulator, slewLimiter);
            osc1.SynthesizeReplaceEnabled = true;

            osc2 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 2", wave, emptyFMModulator, slewLimiter);
            osc2.SynthesizeReplaceEnabled = true;

            filter = new StateVariableFilter(sampleRate, new MonoBuffer(0), "State Variable Filter", osc1, osc2, envelope2, lfo2, envelope1);
            filter.SynthesizeReplaceEnabled = true;

            converter = new MonoToStereoConverter(sampleRate, buffer, filter);
            converter.SynthesizeReplaceEnabled = false;

            oscWaveProgrammer1 = new OscWaveProgrammer("Oscillator 1", osc1);
            oscWaveProgrammer2 = new OscWaveProgrammer("Oscillator 2", osc2);

            oscFMProgrammer1 = new OscFMProgrammer("Oscillator 1", osc1, emptyFMModulator, envelope1, envelope2, lfo1, lfo2);
            oscFMProgrammer2 = new OscFMProgrammer("Oscillator 2", osc2, emptyFMModulator, envelope1, envelope2, lfo1, lfo2);

            AddComponent(emptyFMModulator);
            AddComponent(slewLimiter);
            AddComponent(osc1);
            AddComponent(osc2);
            AddComponent(envelope1);
            AddComponent(envelope2);
            AddComponent(lfo1);
            AddComponent(lfo2);
            AddComponent(filter);
            AddComponent(converter);

            AddParameters(slewLimiter);
            AddParameters(osc1);
            AddParameters(oscWaveProgrammer1);
            AddParameters(oscFMProgrammer1);
            AddParameters(osc2);
            AddParameters(oscWaveProgrammer2);
            AddParameters(oscFMProgrammer2);
            AddParameters(envelope1);
            AddParameters(envelope2);
            AddParameters(lfo1);
            AddParameters(lfo2);
            AddParameters(filter);

            AddBendable(osc1);
            AddBendable(osc2);

            AddControllable(lfo1);
            AddControllable(lfo2);
        }