Class Utilities

java.lang.Object
org.jjazz.rhythmmusicgeneration.api.Utilities

public class Utilities extends Object
Phrase manipulation methods.
  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • fitMelodyPhrase2ChordSymbol

      public static Phrase fitMelodyPhrase2ChordSymbol(SourcePhrase pSrc, ExtChordSymbol ecsDest, boolean chordMode)
      Adapt the notes from a melody-oriented source phrase to a destination chord symbol.

      Notes are transposed to the destination root note and adapted to the destination chord type degrees.
      Ex: if pSrc=C3,G3,B3,E4 and ecsSrc=C7M and ecsDest=F7b5, then destination phrase=F3,B3,Eb4,Ab4

      Each destination note of the resulting phrase stores its corresponding source note in the PARENT_NOTE client property.

      Parameters:
      pSrc - The source phrase
      ecsDest - The destination extended chord symbol.
      chordMode - True if source phrase is a chord phrase for which we want the melodic handling.
      Returns:
      A new phrase with destination notes.
    • fitBassPhrase2ChordSymbol

      public static Phrase fitBassPhrase2ChordSymbol(SourcePhrase pSrc, ExtChordSymbol ecsDest)
      Adapt the notes from a bass melody-oriented source phrase to a destination chord symbol.

      Notes are transposed to the destination root note and adapted to the destination chord type degrees.
      If destination symbol bass note is different from the root note, it is used instead of the root note. The method takes also into account the ChordRenderingInfo.BassLineModifiers of the chord symbol.
      Ex: if pSrc=C3,G3,B3,E4 and ecsSrc=C7M and ecsDest=F7b5/A, then destination phrase=A3,B3,Eb4,Ab4.

      Each destination note of the resulting phrase stores its corresponding source note in the PARENT_NOTE client property.

      Parameters:
      pSrc - The source phrase
      ecsDest - The destination extended chord symbol.
      Returns:
      A new phrase with destination notes.
    • fitChordPhrase2ChordSymbol

      public static Phrase fitChordPhrase2ChordSymbol(SourcePhrase pSrc, ExtChordSymbol ecsDest)
      Adapt the notes from a chord-oriented source phrase to a destination chord symbol.

      Same as fitMelodyPhrase2ChordSymbol() except:
      - we must select which destination degrees are used if destination chord is more complex than source chord (eg C=>C7b9)
      - if destination chord is less complex than source chord (eg C7M=>C), which dest degree should be reused ?
      - we search all the possible chord inversions to find the best matching destination (eg which minimize top voice motion).

      Ex: if pSrc=C3,G3,B3,E4 and ecsSrc=C7M and ecsDest=F7b5, then destination phrase=F3,B3,Eb4,Ab4

      Each destination note of the resulting phrase stores its corresponding source note in the PARENT_NOTE client property.

      Parameters:
      pSrc - The source phrase
      ecsDest - The destination extended chord symbol.
      Returns:
      A new phrase with destination notes.
    • getRelativePitches

      public static List<Integer> getRelativePitches(int rootPitch, Degree[] degrees)
      Get the relative pitches corresponding to the degrees for a chord symbol whose root=rootPitch.

      Ex: rootPitch=0, degrees=ROOT,FIFTH => return [0,7]=[C,G]

      Parameters:
      rootPitch -
      degrees -
      Returns: