Class RhythmVoice

java.lang.Object
org.jjazz.rhythm.api.RhythmVoice
Direct Known Subclasses:
RhythmVoiceDelegate, UserRhythmVoice

public class RhythmVoice extends Object
Describe a voice for which a Rhythm will generate music.

This is an immutable class.

  • Constructor Details

    • RhythmVoice

      public RhythmVoice(Rhythm container, RhythmVoice.Type type, String name, Instrument instrument, int preferredChannel)
      Create a RhythmVoice for a non-drums voice with a default InstrumentSettings.
      Parameters:
      container - The Rhythm this RhythmVoice belongs to.
      type - DRUMS or PERCUSSION not allowed.
      name -
      instrument - The instrument to be used by default. Can't be null. Must have getSubstitute() defined.
      preferredChannel - Preferred Midi channel
    • RhythmVoice

      public RhythmVoice(Rhythm container, RhythmVoice.Type type, String name, Instrument ins, InstrumentSettings is, int preferredChannel)
      Create a RhythmVoice for a non-drums voice.
      Parameters:
      container - The Rhythm this RhythmVoice belongs to.
      type - DRUMS or PERCUSSION not allowed.
      name - Name of the RhythmVoice
      ins - The recommended instrument. Can't be null. Must have getSubstitute() defined.
      is - The recommended InstrumentSettings.
      preferredChannel - The preferred Midi channel for this voice.
    • RhythmVoice

      public RhythmVoice(DrumKit drumKit, Rhythm container, RhythmVoice.Type type, String name, Instrument ins, int preferredChannel)
      Create a drums/percussion RhythmVoice with a default InstrumentSettings.
      Parameters:
      drumKit -
      container -
      type - Must be DRUMS or PERCUSSION.
      name -
      ins - The recommended instrument. Can't be null. Does not need to have getSubstitute() defined.
      preferredChannel -
    • RhythmVoice

      public RhythmVoice(DrumKit drumKit, Rhythm container, RhythmVoice.Type type, String name, Instrument ins, InstrumentSettings is, int preferredChannel)
      Create a RhythmVoice for Drums/Percussion instruments.

      Parameters:
      drumKit -
      container - The Rhythm this RhythmVoice belongs to.
      type - Must be DRUMS or PERCUSSION.
      name - Name of the RhythmVoice
      ins - The recommended instrument. Can't be null. Does not need to have getSubstitute() defined.
      is - The recommended InstrumentSettings.
      preferredChannel - The preferred Midi channel for this voice.
  • Method Details

    • isDrums

      public boolean isDrums()
      Returns:
      True if this object's type is Drums or Percussion.
    • getDrumKit

      public DrumKit getDrumKit()
      Get the DrumKit.
      Returns:
      Null if this is not a Drums/Percussion rhythm voice.
    • getContainer

      public Rhythm getContainer()
      Returns:
      The Rhythm for which this RhythmVoice is set.
    • getPreferredChannel

      public int getPreferredChannel()
    • getType

      public RhythmVoice.Type getType()
      Returns:
      The type of the rhythm voice.
    • getName

      public String getName()
      Returns:
      E.g. "Horn riffs", "walking bass"
    • getPreferredInstrument

      public Instrument getPreferredInstrument()
      The preferred Instrument for this voice.
      Returns:
      Can't be null. Except for Drums/Percussion, returned instrument is guaranteed to have its method getSubstitute() defined
    • getPreferredInstrumentSettings

      public InstrumentSettings getPreferredInstrumentSettings()
      Recommended instrument settings to be used for this voice.
      Returns:
      A copy of this rhythmVoice's InstrumentSettings. Can't be null.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toLongString

      public String toLongString()
    • toString

      public String toString()
      Overrides:
      toString in class Object