Class Score_hkn.Expansion

java.lang.Object
eu.bandm.music.haken.Score_hkn.Expansion
Enclosing class:
Score_hkn

public class Score_hkn.Expansion extends Object
An expansion is a collection of voices which contain only RelWert instead of Haken and DoppelHaken. It is characterized by a selection of voices, because the disjunction/union of all Tps in these voices will be mapped to a RelWert.

ADDITIONAL Tps may be synthesized, if necessary. All Tps are found in tps. The corresponding expanded data is expanded.

For convenience of the calling code, which realizes the specific interpretation of a bundle of voices for different parameters, a voice reference==null may be included, which means that no voice has been assigned to a particular parameter. This will be excluded before any procesing.

Usage: Create an instance (giving all voices to take part) and call expand(). The subsequent application-specific evaluations work exclusively on tps and expanded, which run in parallel.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Main result of expansion: a list of expanded RelWert per Vox.
    protected boolean
    Flag that the expanded values are valid.
    (package private) Set<Tp>
    Temporary set of Tps before which one additional tp must be synthesized for the expansion of a Haken.
    (package private) Set<Tp>
    Temporary set of Tps before which an additional tp must be synthesized, or indeterminstically before its successor.
    final List<Tp>
    All time points taking part in this Expansion.
    (package private) Set<Tp>
    Temporary set of Tps before which two additional tp-s must be synthesized for the expansion of a Haken.
    final Set<Vox>
    All voices taking part in this expansion, as given finally on constrcution.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Expansion(@Opt Vox... voices)
    Gives the set of voices, the data and time points of which shall be considered.
    Expansion(Set<@Opt Vox> voices)
    Gives the set of voices, the data and time points of which shall be considered.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Collect all requirements of additional Tps into global output registers.
    protected void
    collectTps(Set<Tp> res, Vox v)
    Collect all Tps of all events of the given voice into one set.
    protected void
    dhPut(List<RelWert> result, RelWert v, int c)
    Put one segement of a DoppelHaken
    void
    Auxiliary print of all voices and their values, for debugging and demonstration.
    protected void
    Translates sybolic input voices (="K-Voices", containing RelWert, Haken and Doppelhaken references as their events) to sequences of RelWert, for a set of K-voices which together define one instrument.
    protected void
    expandHaken(Vox v, List<RelWert> result)
    Returns a list of RelWert values by copying these from the K-voice input and translating all Haken and DoppelHaken into these.
    protected void
    flushPendingDoppelHaken(List<RelWert> result, int length, @Opt Event doppelhaken, boolean forceOverlap, boolean mayOverlap)
    Expand the last recognized DoppelHaken to a sequence of single "O/M/U" RelWert events, Fills the time from its start up to "currentPos", because the next haken/event (or the end of input) is reached in the K-voice (=symbolic input voice).
    protected void
    flushPendingHaken(List<RelWert> result, int length, @Opt Event haken, boolean forceOverlap)
    Expand the last recognized Haken to a sequence of single "O/M/U" RelWert events, Fills the time from its start up to "currentPos", because the next haken/event (or the end of input) is reached in the K-voice (=symbolic input voice).
    protected void
    makeTps(ListIterator<Tp> it, Tp tp0, Tp tp1, int cnt)
    Instert additional synthetic time points as needed for the expansion of a Haken.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • tps

      public final List<Tp> tps
      All time points taking part in this Expansion. The list is a subset of all Tps occuring in the tscore, as given by Score_hkn.tp2rat. Synthesized new Tp-s are entered there and here.
    • voices

      public final Set<Vox> voices
      All voices taking part in this expansion, as given finally on constrcution. (No null is contained)
    • expanded

      public final Map<Vox,List<RelWert>> expanded
      Main result of expansion: a list of expanded RelWert per Vox. Those lists run all in parallel (same index = same event) and in parallel with tps.
    • isExpanded

      protected boolean isExpanded
      Flag that the expanded values are valid.
    • oneMore

      Set<Tp> oneMore
      Temporary set of Tps before which one additional tp must be synthesized for the expansion of a Haken.
    • twoMore

      Set<Tp> twoMore
      Temporary set of Tps before which two additional tp-s must be synthesized for the expansion of a Haken.
    • oneMoreOrNext

      Set<Tp> oneMoreOrNext
      Temporary set of Tps before which an additional tp must be synthesized, or indeterminstically before its successor.
  • Constructor Details

    • Expansion

      public Expansion(Set<@Opt Vox> voices)
      Gives the set of voices, the data and time points of which shall be considered. For convenience of the calle, the set may contain the value null which will be removed.
    • Expansion

      public Expansion(@Opt @Opt Vox... voices)
      Gives the set of voices, the data and time points of which shall be considered. For convenience of the calle, the set may contain the value null which will be removed.
  • Method Details

    • dump

      public void dump(PrintStream os)
      Auxiliary print of all voices and their values, for debugging and demonstration.
    • makeTps

      protected void makeTps(ListIterator<Tp> it, Tp tp0, Tp tp1, int cnt)
      Instert additional synthetic time points as needed for the expansion of a Haken. The time points are inserted in the network of TDivision, (which is global to the underlying t-score) and in the local list tps.
      Every new time point gets its rational value (in Score_hkn.tp2rat, which always matters only w.r.t. the sequential order.

      ATTENTION: Tps created here are NOT related to Tps in other, parallel K-voices, even of the same configuration. (This will not do any harm as long as they will be evaluated K-voice by K-voice, when generating the V-voices.)

      Parameters:
      it - is an output parameter used for changing the list tps. It is the ListIterator contolled by Iterators.Pairwise and currently (on entering this method) points to the successor of the later item "tp1". It is used for inserting in to the underlying list of time points by ListIterator.add(Object), but reset to its entering value when returing.
      tp0 - after which the synthetic tp-s shall be entered.
      tp1 - on call time: the successor of tp0 = the node before which the synthetic tp-s shall be entered.
      cnt - number by which the interval tp1-tp0 shall be divided, i.e. one larger than the number of new synthetic nodes.
    • expand

      protected void expand()
      Translates sybolic input voices (="K-Voices", containing RelWert, Haken and Doppelhaken references as their events) to sequences of RelWert, for a set of K-voices which together define one instrument. (Pauses contained in a voice are ignored.)
      1. First collect all tps appearing in any event in any voice.
      2. Then synthesize additional time points for hook expansion, if necessary. The final sequence of Tps will be contained in tps.
      3. Finally expand the haken and doppelhaken in the K-voices into sequences of RelWert, which will be contained in expanded.
      This method may only be called once, which is controlled by the flag isExpanded.
      Throws:
      IllegalStateException - if called twice.
    • collectTps

      protected void collectTps(Set<Tp> res, Vox v)
      Collect all Tps of all events of the given voice into one set.
    • collectAdditionalTpRequirements

      protected void collectAdditionalTpRequirements(Vox v)
      Collect all requirements of additional Tps into global output registers. (The actual generation of these time points is done after all voices have benn asked.) The necessity is calculated by the distance to the preceding Haken, measures in (currently exisitng) time points. Examples of K-tps and K-events for the necessity to synthesize time points:
             0    1    2    3
             M    M    M    M
             OM             O   => dist>=3 => nothing required.
             OM        M        => dist=2 and overlap =>  nothing required.
             OM        O        => dist=2 and no overlap => require 1 additional before pos 1 
                                                OR or 1 additional before pos 2, NOT DETERMIN!
             OM   M             => dist=1 and overlap =>  require 1 additional before pos 1
             OM   O             => dist=1 and no overlap =>  require 2 additional before pos 1 
             OM   'MU           => dto., overlap explicitly forbidden.
        
      Has only any effect if distance from a Haken to its successor K-event is <=2. In this case "overlapping" is considered true, if the values permit and not forbidden by Score_hkn.event2noOverlap_start.

      Attention: Currently only Haken, not DoppelHaken do cause additional Timepoints to be synthesized. (The degree of freedom with overlapping DoppelHaken can become so large that humans cannot control the consequences anymore!-)

    • expandHaken

      protected void expandHaken(Vox v, List<RelWert> result)
      Returns a list of RelWert values by copying these from the K-voice input and translating all Haken and DoppelHaken into these. Input is a list of Tp (time points) which are all time points which have to be filled, i.e. after additionally required Tps have been synthesized. The expansion process will generate overlaps iff it is necessary by missing space or explicitly requested by Score_hkn.event2forceOverlap_end.
      Parameters:
      v - the voice to expand. For convenience of the calling code, which realizes the specific interpretation of a bundle of voices for different parameters, a value v==null means that no voice has been assigned to a particular parameter and a sequence of RelWert.M of the approriate length is returned.
    • flushPendingHaken

      protected void flushPendingHaken(List<RelWert> result, int length, @Opt @Opt Event haken, boolean forceOverlap)
      Expand the last recognized Haken to a sequence of single "O/M/U" RelWert events, Fills the time from its start up to "currentPos", because the next haken/event (or the end of input) is reached in the K-voice (=symbolic input voice). An overlap is only done when forced by explicit K-Input (reflected in parameter "forceOverlap") or if space is <3.
      Parameters:
      result - the list of RelWert, grown exaxtly to the start point of the Haken to expand.
      length - the number of tp to realize this Haken
      haken - the event which carries this haken info (for getting location and form of Haken)
      forceOverlap - if overlap requested explicitly by the tscore input.
    • flushPendingDoppelHaken

      protected void flushPendingDoppelHaken(List<RelWert> result, int length, @Opt @Opt Event doppelhaken, boolean forceOverlap, boolean mayOverlap)
      Expand the last recognized DoppelHaken to a sequence of single "O/M/U" RelWert events, Fills the time from its start up to "currentPos", because the next haken/event (or the end of input) is reached in the K-voice (=symbolic input voice).
                       0  1  2  3  4  5  6
                       MUM         M          overlap
                       M  O  U  O  M
                       MUM            'M      no overlap
                       M  O  U  O  M  M
                       MUUM           M       overlap
                       M  O  U  U  O  M  
                       MUUM              'M   no overlap
                       M  O  U  U  O  M  M
        
      No additional space has been synthesized (as for Haken), but parallel K-voices must provide the required space. An overlap is forced by explicit notation in the K-voice input or can be caused by lack of space (NOT IMPLEMENTED FIXME)
      Parameters:
      result - where to put the expansion RelWert
      length - how many Tp-s will be filled by the expansion
      doppelhaken - the Event, for getting Location and form of DoppelHaken
      forceOverlap - whether the K-voice input contains the operator "tilde" for the end of the DoppelHaken, as in "MOM~".
      mayOverlap - whether the DoppelHaken ends with the same RelWert as its successor begins.
    • dhPut

      protected void dhPut(List<RelWert> result, RelWert v, int c)
      Put one segement of a DoppelHaken
      Parameters:
      result - where to add.
      v - the value to add.
      c - number of positions to add, maybe == null.