Ejemplo n.º 1
0
 // 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();
     }
 }
Ejemplo n.º 2
0
 protected override void noteOff(Note note)
 {
     if (Sustained) {
       int index = (int)(note.Index - (int)rootNote);
       if (index >= 0 && index < voices.Count) {
     voices[index].Stop();
       }
     }
 }
Ejemplo n.º 3
0
        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;
              }
            }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 protected abstract void noteOn(Note note);
Ejemplo n.º 6
0
 public virtual void PlayNote(Note note)
 {
     if (note.IsNoteOn) {
       noteOn(note);
     } else {
       noteOff(note);
     }
 }