Class RunningOctaveCollector<P extends PitchModOctave & Comparable<P>>

java.lang.Object
eu.bandm.music.entities.RunningOctaveCollector<P>
Type Parameters:
P - the type of the pitch classes.

public class RunningOctaveCollector<P extends PitchModOctave & Comparable<P>> extends Object
Collects and distributes the octave information over a sequence of incomplete pitch information. "Running octave" is a principle for the convenience of noatation, well proven in musictex, musixtex, lilypond etc. It means that partial information which gives only a pitch class means the concrete pitch with the minimal distance to its predecessor. Ergo only functional intervals up to a fourth are generated in this case.

For its definition/realization, it requires a notion of "nearest" pitch w.r.t a particular pitch of the predecessor and a particular pitchModOctave. The CWN convention, as implemened here, requires that there are "WhiteKeys" as the basis for notation, and "nearest" is defined on these.

The input grammar accepted by this pre-processor is

  pitch ::=      (octUp | octDown)? pitchModOctave
             |   pitchModOctave octaveRegister
 
Usage: Create an instance, apply the Translet.Parser resturned by parser(), and finally call reify(MessageReceiver,Iterable,Map).
  • Field Details

    • parserPitchClass

      final Translet.Parser<P extends PitchModOctave & Comparable<P>> parserPitchClass
      Construction parameter: parser for the pitch class.
    • parserOctaveRegister

      final Translet.Parser<OctaveRegister> parserOctaveRegister
      Construction parameter: parser for an explicit octave register.
    • octUp

      final String octUp
      Construction parameter: inut string meaning "one octave higher than the min distance."
    • octDown

      final String octDown
      Construction parameter: inut string meaning "one octave lower than the min distance."
    • stripAlterations

      final Function<P extends PitchModOctave & Comparable<P>,WhiteKeyModOctave> stripAlterations
      Function to get from the pitch type (which is a parameter) to a whitekey.
    • pitches

      protected final Map<Event,P extends PitchModOctave & Comparable<P>> pitches
      Intermediate store between parsing and reification: pitches by events.
    • explicitOcts

      protected final Map<Event,OctaveRegister> explicitOcts
      Intermediate store between parsing and reification: explicit changes of octave.
    • jumps

      protected final Map<Event,Integer> jumps
      Intermediate store between parsing and reification: explicit additional octave jump.
  • Constructor Details

  • Method Details

    • parser

      public final Translet.Parser<?> parser()
      Return the parser. Must be applied to the parameter track of the voice, and stores the results in the intermediate storages for a subsequent call of reify(MessageReceiver,Iterable,Map)
    • reify

      public void reify(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, Iterable<Event> evs, Map<Event,PitchAndOctave<OctaveRegister,P>> result)
      Steps through the sequence of events "evs" and combines the already parsed pitch and the (partial) "explicit octave" and "jump" information into the combined data type, taking the "shortest notational distance" as a default.