Class MidiNotePlayer

java.lang.Object
mars.mips.instructions.syscalls.MidiNotePlayer

public class MidiNotePlayer extends Object
Used by the MIDI syscalls to play MIDI notes on demand.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default MIDI channel of the tone: 0 (channel 1).
    static final int
    The default duration of the tone: 1000 milliseconds.
    static final byte
    The default instrument of the tone: 0 / piano.
    static final byte
    The default pitch value for the tone: 60 / middle C.
    static final byte
    The default volume of the tone: 100 (of 127).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static ScheduledFuture<?>
    playNote(int pitch, int duration, int instrument, int volume)
    Play a note with the specified pitch, duration, and instrument, and volume, returning immediately.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_PITCH

      public static final byte DEFAULT_PITCH
      The default pitch value for the tone: 60 / middle C.
      See Also:
    • DEFAULT_DURATION

      public static final int DEFAULT_DURATION
      The default duration of the tone: 1000 milliseconds.
      See Also:
    • DEFAULT_INSTRUMENT

      public static final byte DEFAULT_INSTRUMENT
      The default instrument of the tone: 0 / piano.
      See Also:
    • DEFAULT_VOLUME

      public static final byte DEFAULT_VOLUME
      The default volume of the tone: 100 (of 127).
      See Also:
    • DEFAULT_CHANNEL

      public static final int DEFAULT_CHANNEL
      The default MIDI channel of the tone: 0 (channel 1).
      See Also:
  • Constructor Details

    • MidiNotePlayer

      public MidiNotePlayer()
  • Method Details

    • playNote

      public static ScheduledFuture<?> playNote(int pitch, int duration, int instrument, int volume)
      Play a note with the specified pitch, duration, and instrument, and volume, returning immediately.
      Parameters:
      pitch - The desired pitch in semitones - 0-127 where 60 is middle C.
      duration - The desired duration in milliseconds.
      instrument - The desired instrument (or patch) represented by a positive byte value (0-127). See the general MIDI instrument patch map for more instruments associated with each value.
      volume - The desired volume of the initial attack of the note (MIDI velocity) represented by a positive byte value (0-127).