Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          patterns/composite/music-elements/Note.cs - The class Note.Lecture 8 - slide 23 : 37
Program 2

using System;

public class Note: MusicElement{
  
  private byte value;
  private int duration;
  private byte volume;
  private Instrument instrument;

  public Note(byte value, int duration, byte volume, 
              Instrument instrument){
    this.value = value;
    this.duration = duration;
    this.volume = volume;
    this.instrument = instrument;
  }

  public Note(byte value, int duration):
   this(value, duration, 64, Instrument.Piano){
  }

  public override int Duration{
    get{
      return duration;
    }
  }

  public override TimedNote[] Linearize(int startTime){
    TimedNote[] result = new TimedNote[1];
    result[0] = new TimedNote(startTime, value, duration, volume, 
                              instrument);
    return result;
  }

  public override MusicElement Transpose(int levels){
     return new Note(Util.ByteBetween(value + levels, 0, 127),
                     duration, volume, instrument);
  }
}