Class MUS

java.lang.Object
net.mtrop.doom.sound.MUS
All Implemented Interfaces:
Iterable<MUS.Event>, BinaryObject

public class MUS extends Object implements BinaryObject, Iterable<MUS.Event>
Abstraction of MUS formatted music sequence data.
Author:
Matthew Tropiano
  • Field Details

    • MUS_ID

      public static final byte[] MUS_ID
    • NOTE_NAMES

      public static final String[] NOTE_NAMES
    • SYSTEM_EVENT_NAME

      public static final String[] SYSTEM_EVENT_NAME
    • CONTROLLER_NAME

      public static final String[] CONTROLLER_NAME
    • INSTRUMENT_NAME

      public static final String[] INSTRUMENT_NAME
    • DRUM_INSTRUMENT_NAME

      public static final String[] DRUM_INSTRUMENT_NAME
    • CHANNEL_DRUM

      public static final int CHANNEL_DRUM
      See Also:
  • Constructor Details

    • MUS

      public MUS()
      Creates a blank MUS lump with no events.
  • Method Details

    • getPrimaryChannelCount

      public int getPrimaryChannelCount()
      Returns:
      the amount of primary channels (from channel 0).
    • getSecondaryChannelCount

      public int getSecondaryChannelCount()
      Returns:
      the amount of secondary channels (from channel 10).
    • getInstrumentPatchCount

      public int getInstrumentPatchCount()
      Returns:
      the amount of instrument patches.
    • getInstrumentPatch

      public int getInstrumentPatch(int index)
      Gets an instrument patch to preload.
      Parameters:
      index - the instrument patch list index.
      Returns:
      the instrument at the corresponding index.
      Throws:
      ArrayIndexOutOfBoundsException - of index is < 0 or > getInstrumentPatchCount().
    • getSequencer

      public MUS.Sequencer getSequencer(MUS.SequencerListener listener)
      Gets a new sequencer object for playing through an MUS's event sequence, tic by tic.
      Parameters:
      listener - the listener to emit events to per tic.
      Returns:
      a new Sequencer.
      See Also:
    • iterator

      public Iterator<MUS.Event> iterator()
      Specified by:
      iterator in interface Iterable<MUS.Event>
    • readBytes

      public void readBytes(InputStream in) throws IOException
      Description copied from interface: BinaryObject
      Reads from an InputStream and sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!
      Specified by:
      readBytes in interface BinaryObject
      Parameters:
      in - the InputStream to read from.
      Throws:
      IOException - if a read error occurs.
    • writeBytes

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.