Class SongSequenceBuilder

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

public class SongSequenceBuilder extends Object
Methods to convert a Song into Phrases and Midi sequence.

  • Field Details

  • Constructor Details

    • SongSequenceBuilder

      public SongSequenceBuilder(SongContext context)
      Parameters:
      context - The songContext to build the sequence.
  • Method Details

    • buildAll

      public SongSequenceBuilder.SongSequence buildAll(boolean silent) throws MusicGenerationException
      Call buildMapRvPhrase() then buildSongSequence().
      Parameters:
      silent - If true do not show a progress dialog while generating the musical phrases
      Returns:
      Throws:
      MusicGenerationException
      See Also:
    • buildMapRvPhrase

      public Map<RhythmVoice,Phrase> buildMapRvPhrase(boolean silent) throws MusicGenerationException
      Build the RhythmVoice phrases for the defined context.

      - Perform some checks on the context (start chord on each section start, no overlapping chord symbols)
      - Ask each used rhythm in the song to produce music (one Phrase per RhythmVoice) via its MusicGenerator implementation.
      - Add the user phrases if any
      - Apply on each channel possible instrument transpositions, velocity shift, mute (RP_SYS_Mute).
      - Apply the RP_SYS_DrumsMix velocity changes. Note that it is expected that, if there is an AdaptedRhythm for a Rhythm which uses RP_SYS_DrumsMix, the AdaptedRhythm reuses the same RP_SYS_DrumsMix instance.
      - Apply the RP_SYS_CustomPhrase changes
      - Apply the RP_SYS_DrumsTransform changes
      - Apply drums rerouting if needed
      - Handle the NC chord symbols

      Phrases for RhythmVoiceDelegates are merged into the phrases of the source RhythmVoices.

      Parameters:
      silent - If true do not show a progress dialog
      Returns:
      The returned phrases always start at beat/bar 0 (i.e phrases are shifted if context start bar is not bar 0).
      Throws:
      MusicGenerationException
    • buildSongSequence

      public SongSequenceBuilder.SongSequence buildSongSequence(Map<RhythmVoice,Phrase> rvPhrases)
      Build the SongSequence from the specified RhythmVoice phrases for the defined context.

      - Create a track 0 with no notes but MidiEvents for song name, time signature changes, TEMPO_FACTOR_META_EVENT_TYPE MetaMessages for the RP_SYS_TempoFactor value (if used by a rhythm).
      - Then create a track per RhythmVoice.

      If songContext range start bar is > 0, the Midi events are shifted to start at sequence tick 0.

      Parameters:
      rvPhrases - The RhythmVoice phrases such as produced by buildMapRvPhrase(boolean), must start at beat 0.
      Returns:
      A Sequence containing accompaniment tracks for the songContext, including time signature change Midi meta events and JJazz custom Midi controller messages (MidiConst.CTRL_CHG_JJAZZ_TEMPO_FACTOR) for tempo factor changes.
      See Also:
    • makeSequenceExportable

      public void makeSequenceExportable(SongSequenceBuilder.SongSequence songSequence, boolean ignoreMidiMixMute)
      Update the Midi sequence so that it can be exported to external tools (sequencers, Midi editors, etc.).

      Get rid of all JJazzLab-only MidiEvents and add some initialization events:
      - add copyright message
      - remove JJazzLab-specific tempo factor and beat
      - add tempo events
      - add GM/GS/XG/GM2 reset messages depending of the current OutputSynth configuration
      - add reset controllers for each RhythmVoice track
      - add bank/program and volume/effects events for each RhythmVoice track
      - add a marker for each chord symbol

      Parameters:
      songSequence - Must have been created using buildSongSequence() for the current SongContext
      ignoreMidiMixMute - If true, a track will sound even if it was muted in the context MidiMix
      See Also:
      • #buildSongSequence(java.util.Map, boolean)
    • getSongContext

      public SongContext getSongContext()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • buildTrackName

      public static String buildTrackName(RhythmVoice rv, int channel)
      Built the Midi track name from the specified parameters.
      Parameters:
      rv -
      channel -
      Returns:
    • getTempoFactorMetaMessage

      public static MetaMessage getTempoFactorMetaMessage(float tempoFactor)
      Get a Meta message which encodes a JJazz tempo factor.
      Parameters:
      tempoFactor - A percentage in the [.5;2.0] range.
      Returns:
      A MetaMessage with type==TEMPO_FACTOR_META_EVENT_TYPE
    • getTempoFactor

      public static float getTempoFactor(MetaMessage tempoFactorMm)
      Get the tempo factor [.5;2.0] from the specified MetaMessage.
      Parameters:
      tempoFactorMm - MetaMessage type must be TEMPO_FACTOR_META_EVENT_TYPE
      Returns: