/// <summary>
        /// Default Constructor.
        /// </summary>
        /// <param name="elt">Reference to the media element of the GUI</param>
        protected IFrequencySequencer(MediaElement elt, int buffer)
        {
            this._elt       = elt;
            this._sequencer = new SequencerExt();

            this._intervalVoices = new Dictionary <int, ISampleMaker>();

            SynthMediaStreamSource source = new SynthMediaStreamSource(44100, 2, buffer);

            source.SampleMaker = this._sequencer;

            this._sequencer.Tempo = 60;             // 1 beat per second
            this._sequencer.Tempo = 60 * 10;        // 1 beat per 100 ms
            this._sequencer.Tempo = 60 * 10 * 2;    // 1 beat per 50 ms
            this._sequencer.Tempo = 60 * 10 * 4;    // 1 beat per 25 ms
            this._elt.SetSource(source);
        }
示例#2
0
                void setSequencer(int interIdx)
        {
            this.intervalVoices = new Dictionary<int, ISampleMaker>();

            int inc = 0;
            int intervalNb = interIdx;

            double[] inter={5000.0,3000.0,5000.0};

            this.sequencer.StepCount = 15+5;
            IWaveForm form = new SineWaveForm();


            double percent = 5 / 100d;
            uint value = (uint)(15000 * percent);

            for (inc = 0; inc < intervalNb; inc++)
            {
                //Pitch pitch = new Pitch(11, 3);
                Oscillator osc1 = new Oscillator();
                osc1.WaveForm = form;

                Voice voice = new Voice();
                voice.Attenuation = 0;
                voice.Oscillators.AddRange(new List<Oscillator>() { osc1});
                voice.Frequency = inter[inc];//pitch.Frequency;
                voice.Envelope.Attack = value;
                voice.Envelope.Decay = value;
                this.intervalVoices.Add(inc, voice);

                this.sequencer.AddNote(voice, (3+2)*inc+1, 3);

            }

            SynthMediaStreamSource source = new SynthMediaStreamSource(44100, 2);
            source.SampleMaker = this.sequencer;
            this.sequencer.Tempo = 360;
            this.media.SetSource(source);
            this.media.Stop();
            this.sequencer.StepIndex = this.sequencer.StepCount - 1;
            //      
        }
        protected IFrequencySequencer(MediaElement elt)
        {
            this._elt       = elt;
            this._sequencer = new SequencerExt();


            //this._sequencer._stepChangedHook += new SequencerExt.StepChanged(_sequencer__stepChangedHook);
            //this._sequencer._stepEndedHook += new SequencerExt.StepEnded(_sequencer__stepEndedHook);
            //this._sequencer._stepStartedHook += new SequencerExt.StepStarted(_sequencer__stepStartedHook);

            this._intervalVoices = new Dictionary <int, ISampleMaker>();

            SynthMediaStreamSource source = new SynthMediaStreamSource(44100, 2);

            source.SampleMaker = this._sequencer;

            this._sequencer.Tempo = 60;             // 1 beat per second
            this._sequencer.Tempo = 60 * 10;        // 1 beat per 100 ms
            this._sequencer.Tempo = 60 * 10 * 2;    // 1 beat per 50 ms
            this._sequencer.Tempo = 60 * 10 * 4;    // 1 beat per 25 ms
            this._elt.SetSource(source);
        }