// TODO(anokta): Note structure should be restructured! protected override void noteOn(Note note) { int index = (int)(note.Index - (int)rootNote) / 12; if (index >= 0 && index < voices.Count) { voices[index].Gain = note.Loudness; voices[index].Start(); } }
protected override void noteOff(Note note) { if (Sustained) { int index = (int)(note.Index - (int)rootNote); if (index >= 0 && index < voices.Count) { voices[index].Stop(); } } }
protected override void noteOff(Note note) { foreach (Voice voice in activeList) { if (voice.Pitch == note.Pitch) { voice.Stop(); activeList.Remove(voice); freeList.AddLast(voice); break; } } }
protected override void noteOn(Note note) { Voice voice; if (freeList.Count > 0) { // are any voices free? voice = freeList.First.Value; freeList.RemoveFirst(); activeList.AddLast(voice); } else { // if not, steal the first used one voice = activeList.First.Value; } voice.Pitch = note.Pitch; voice.Gain = note.Loudness; voice.Start(); }
protected abstract void noteOn(Note note);
public virtual void PlayNote(Note note) { if (note.IsNoteOn) { noteOn(note); } else { noteOff(note); } }