Class ExtChordSymbol

java.lang.Object
org.jjazz.harmony.api.ChordSymbol
org.jjazz.chordleadsheet.api.item.ExtChordSymbol
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
AltExtChordSymbol, NCExtChordSymbol

public class ExtChordSymbol extends ChordSymbol implements Serializable
An extended chord symbol with additionnal features:

- Chord rendering information
- An optional conditionnally-enabled alternate chord symbol.

This is an immutable class.

See Also:
  • Constructor Details

    • ExtChordSymbol

      public ExtChordSymbol()
      Create a 'C' chord symbol with a standard rendering info and no alternate chord symbol.
    • ExtChordSymbol

      public ExtChordSymbol(Note rootDg, Note bassDg, ChordType ct)
      Create an ExtChordSymbol with a standard RenderingInfo and no alternate chord symbol.
      Parameters:
      rootDg -
      bassDg -
      ct -
    • ExtChordSymbol

      public ExtChordSymbol(ChordSymbol cs)
      Create an ExtChordSymbol with a standard RenderingInfo and no alternate chord symbol.
      Parameters:
      cs -
    • ExtChordSymbol

      public ExtChordSymbol(ChordSymbol cs, ChordRenderingInfo rInfo, AltExtChordSymbol altChordSymbol, AltDataFilter altFilter)
      Create an ExtChordSymbol from the specified ChordSymbol with the specified parameters.
      Parameters:
      cs -
      rInfo -
      altChordSymbol - Can be null if altFilter is also null
      altFilter - Can be null if altChordSymbol is also null
    • ExtChordSymbol

      public ExtChordSymbol(Note rootDg, Note bassDg, ChordType ct, ChordRenderingInfo rInfo, AltExtChordSymbol altChordSymbol, AltDataFilter altFilter)
      Create an ExtChordSymbol from the specified parameters.
      Parameters:
      rootDg -
      bassDg -
      ct -
      rInfo -
      altChordSymbol - Optional alternate chord symbol. If not null altFilter must be also non-null.
      altFilter - Optional filter to enable the use of the alternate chord symbol. If not null altChordSymbol must be also non-null.
  • Method Details

    • get

      public static ExtChordSymbol get(String s) throws ParseException
      Create a ChordSymbol from a chord string specification, with a standard RenderingInfo and no alternate chord symbol.

      If string contains a '/', use ChordRenderingInfo.BassLineModifier.PEDAL_BASS as bassLineModifier. If string is "NC" returns the special NCExtChordSymbol instance.

      Parameters:
      s - Eg 'C7' or 'NC'
      Returns:
      Throws:
      ParseException
    • get

      public static ExtChordSymbol get(String s, ChordRenderingInfo rInfo, AltExtChordSymbol altChordSymbol, AltDataFilter altFilter) throws ParseException
      Create a ChordSymbol from a chord string specification, with the specified RenderingInfo and alternate chord symbol.
      Parameters:
      s - Eg 'C7' or 'NC'
      rInfo - Can't be null
      altChordSymbol - Optional alternate chord symbol. If not null altFilter must be also non-null.
      altFilter - Optional filter to enable the use of the alternate chord symbol. If not null altChordSymbol must be also non-null.
      Returns:
      Throws:
      ParseException
    • getCopy

      public ExtChordSymbol getCopy(ChordSymbol cs, ChordRenderingInfo rInfo, AltExtChordSymbol altChordSymbol, AltDataFilter altFilter)
      Get a copy of this ExtChordSymbol, possibly modified with the specified parameters.
      Parameters:
      cs - If not null return value will use this parameter.
      rInfo - If not null return value will use this parameter.
      altChordSymbol - If not null return value will use this parameter. If not null altFilter must be also non-null.
      altFilter - If not null return value will use this parameter. If not null altChordSymbol must be also non-null.
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ChordSymbol
    • equals

      public boolean equals(Object obj)
      Description copied from class: ChordSymbol
      Comparison is based on rootNote and bassNote relative pitch, ChordType and originalName.

      Overrides:
      equals in class ChordSymbol
    • getChordSymbol

      public ExtChordSymbol getChordSymbol(String altDataFilterString)
      Get this object or the alternate chord symbol, depending on the specified string.

      Return this object if :
      - altDataFilterString is null, or
      - alternate ChordSymbol is null, or
      - the AltDataFilter is null, or
      - the non-null AltDataFilter does not accept the specified string.

      Otherwise return getAlternateChordSymbol().

      Parameters:
      altDataFilterString - String to be passed to the AltDataFilter
      Returns:
    • getAlternateChordSymbol

      public AltExtChordSymbol getAlternateChordSymbol()
      Get the optional alternate chord symbol.
      Returns:
      If null getAlternateFilter() will also return null.
    • getAlternateFilter

      public AltDataFilter getAlternateFilter()
      Get the optional filter used to check if we need to use the alternate chord symbol.

      Returns:
      If null getAlternateChordSymbol() will also return null.
    • fitNote

      public int fitNote(int srcRelPitch, ExtChordSymbol destEcs)
      Adapt a source note from this chord symbol to a destination chord symbol.

      If source note is a degree of the source chord symbol (ex: G=b7 for A7) :
      - Try to reapply it to the destination chord symbol. Ex: G becomes B for C7M dest chord.
      - If NOK(Ex: G=b7 becomes ? for C dest chord), try to use the destination scales if present.
      - If scales NOK, make some assumptions to find the "best" possible note.

      If source note is NOT a source chord symbol degree (ex: D for A7), return -1.

      Parameters:
      srcRelPitch - The relative pitch of the source note (eg 2 for note D)
      destEcs -
      Returns:
      The relative pitch of the destination note, or -1 if source note could not be fitted.
    • getRenderingInfo

      public ChordRenderingInfo getRenderingInfo()
      Returns:
      Additional info to help music generation programs render this chord. Can't be null.
    • getTransposedChordSymbol

      public ExtChordSymbol getTransposedChordSymbol(int t, Note.Alteration alt)
      Get a transposed ExtChordSymbol.
      Overrides:
      getTransposedChordSymbol in class ChordSymbol
      Parameters:
      t - The amount of transposition in semi-tons.
      alt - If not null alteration is unchanged, otherwise use alt
      Returns:
      A new transposed ExtChordSymbol.
    • isSameChordSymbol

      public boolean isSameChordSymbol(ChordSymbol cs)
      True if this object's chord type is the same that cs chord type, and if root/bass relative pitches are the same.
      Parameters:
      cs -
      Returns:
    • createRandomChordSymbol

      public static ExtChordSymbol createRandomChordSymbol()
      Returns:
      ExtChordSymbol A random chord symbol (random degree, random chord type)