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; // }
/// <summary> /// Initialise the voices of the sequencer. /// </summary> /// <param name="interIdx"></param> protected void setSequencer(int interIdx) { this._intervalVoices = new Dictionary <int, ISampleMaker>(); int inc = 0; //int intervalNb = 2;// interIdx; //double[] inter = { 5000.0, 3000.0, 1000.0, 3000.0 }; this._sequencer.VoiceCount = 1; double percent = 10 / 100d; uint value = (uint)(15000 * percent); uint value2 = (uint)(15000 * percent); //int[] pos = { 0, 2, 7, 2,0,19}; Stimulus st = null; for (int i = 0; i < _StimuliStructure.Count; i++) { st = _StimuliStructure[i]; if (st._isSilent) { continue; } IWaveForm wform = new SineWaveForm(); Oscillator osc1 = new Oscillator(); osc1.WaveForm = wform; Oscillator osc2 = new Oscillator(); osc2.WaveForm = wform; Voice voice = new Voice(); voice.Attenuation = -10; voice.Envelope.Attack = value; voice.Envelope.Decay = value2; voice.Oscillators.AddRange(new List <Oscillator>() { osc1 }); voice.Frequency = st._frequency; this._intervalVoices.Add(inc++, voice); this._sequencer.AddNote(voice, st._start, st._duration); } this._sequencer.StepCount = st._duration + st._start; /* for (inc = 0; inc < intervalNb; inc++) * { * //Pitch pitch = new Pitch(11, 3); * IWaveForm form = new SineWaveForm(); * Oscillator osc1 = new Oscillator(); * Oscillator osc2 = new Oscillator(); * osc1.WaveForm = new SineWaveForm(); * osc2.WaveForm = new SineWaveForm(); * * 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); * this._sequencer.AddNote(voice, pos[2 * inc], pos[2 * inc + 1]); * * }*/ if (false) { //Pitch pitch = new Pitch(11, 3); IWaveForm form = new SineWaveForm(); Oscillator osc1 = new Oscillator(); Oscillator osc2 = new Oscillator(); osc1.WaveForm = new WhiteNoiseWaveForm(); osc2.WaveForm = form; Voice voice = new Voice(); voice.Attenuation = -70; voice.Oscillators.AddRange(new List <Oscillator>() { osc1, osc2 }); voice.Frequency = 400; //voice.Envelope.Attack = value; //voice.Envelope.Decay = value; this._intervalVoices.Add(inc, voice); //this.sequencer.AddNote(voice, (3 + 2) * inc + 1, 3); this._sequencer.AddNote(voice, 0, this._sequencer.StepCount); } this._elt.Stop(); this._sequencer.StepIndex = -1;// this._sequencer.StepCount - 1; }