public void ModifyNote(ISampleMaker voice, int step, int newDuration) { StepEvent stepEvent = null; if (this.stepEvents.ContainsKey(step)) { stepEvent = this.stepEvents[step]; stepEvent.VoiceNotes[voice].Duration = newDuration; } else { throw new SequencerException("Step not found at position '" + step.ToString() + "' to modify."); } }
public void ModifyNote(ISampleMaker voice, ISampleMaker newVoice, int step) { StepEvent stepEvent = null; if (this.stepEvents.ContainsKey(step)) { stepEvent = this.stepEvents[step]; if (stepEvent.VoiceNotes.ContainsKey(voice)) { int duration = stepEvent.VoiceNotes[voice].Duration; stepEvent.VoiceNotes.Remove(voice); this.AddNote(newVoice, step, duration); } } }
public void AddNote(ISampleMaker voice, int step, int duration) { StepEvent stepEvent = null; if (this.stepEvents.ContainsKey(step)) { stepEvent = this.stepEvents[step]; } else { stepEvent = new StepEvent(); this.stepEvents.Add(step, stepEvent); } stepEvent.Step = step; VoiceNote note = new VoiceNote(); note.Duration = duration; note.Voice = voice; stepEvent.VoiceNotes.Add(voice, note); }
public void DeleteNote(ISampleMaker voice, int step) { StepEvent stepEvent = null; if (this.stepEvents.ContainsKey(step)) { stepEvent = this.stepEvents[step]; } else { return; } if (stepEvent.VoiceNotes.ContainsKey(voice)) { bool f = stepEvent.VoiceNotes.Remove(voice); this.stepEvents.Remove(step); ////Debug.WriteLine(f); this.stepChanged = true; } }
virtual protected void ProcessCurrentStep() { if (this.stepIndex == 0) { for (int i = this.voicesInPlay.Count - 1; i >= 0; i--) { VoiceNote note = this.voicesInPlay[i]; note.Elapsed = 0; note.Voice.Reset(); if (note.Voice is IVoice) { ((IVoice)note.Voice).Envelope.Reset(); } this.voicesInPlay.RemoveAt(i); } } //Increment duration of voices in play foreach (VoiceNote item in this.voicesInPlay) { item.Elapsed++; } //remove voices whose duration has completed for (int i = this.voicesInPlay.Count - 1; i >= 0; i--) { VoiceNote note = this.voicesInPlay[i]; if (note.Voice is IVoice) { if (note.Elapsed >= note.Duration) { IVoice voice = (IVoice)note.Voice; if (!voice.Envelope.Releasing) { voice.Envelope.Release(); } else if (!voice.Envelope.Active) { this.voicesInPlay.RemoveAt(i); note.Elapsed = 0; note.Voice.Reset(); voice.Envelope.Reset(); } } } else { if (note.Elapsed >= note.Duration) { this.voicesInPlay.RemoveAt(i); note.Elapsed = 0; note.Voice.Reset(); if (note.Voice is IVoice) { ((IVoice)note.Voice).Envelope.Reset(); } } } if ((note.Voice is IVoice == false && note.Elapsed >= note.Duration) || (note.Voice is IVoice && note.Elapsed >= note.Duration && ((IVoice)note.Voice).Envelope.Active == false)) { this.voicesInPlay.RemoveAt(i); note.Elapsed = 0; note.Voice.Reset(); if (note.Voice is IVoice) { ((IVoice)note.Voice).Envelope.Reset(); } } } //add new notes on this step if (this.stepEvents.ContainsKey(this.stepIndex)) { StepEvent stepEvent = this.stepEvents[this.stepIndex]; foreach (ISampleMaker key in stepEvent.VoiceNotes.Keys) { this.voicesInPlay.Add(stepEvent.VoiceNotes[key]); } } }