Package eu.bandm.tscore.base
Class PatternDistributor
java.lang.Object
eu.bandm.tscore.base.PatternDistributor
Looks for repettions of a pattern in a certain parameter track
and distributes it event-wise to the successor events.
Usage: An instance is constructed. Then it is applied to a
Distribution is event-wise, means it does not look at any timing, and operates BEFORE any parsing of the parameter text, i.e. as a RAW text level pre-processor. The definition of a repeated pattern is started by a dedicated symbol prepended to the normal parameter values. (This sign defaults to "$").
The parameter text of all subsequent events (upto pattern end) form the pattern.
The end of the pattern definition is the start of its usage, indicated by a certain start marker, which defaults to "IDEM".
The end of the usage may be anywhere. It is caused by any explicit parameter value (possibly starting a new pattern), or by a special marker, which defaults to "TERM".
The repetition can be resumed after a certain pause: By the start marker again, it will start from its beginning, or by a special marker (which defaults to "CONT") it will resume with the same phase as its preceding use had been terminated.
All these special markers (but not the patter definition lead in) must be the only contents of the event's parameter.
Usage: An instance is constructed. Then it is applied to a
Vox
object
by calling process(Vox)
before any further processing of the voice data.
Afterwards the parameter texts in the Vox object are adjusted accordingly
and can be processed as usual (by applying Translet
parsers, etc.)
Distribution is event-wise, means it does not look at any timing, and operates BEFORE any parsing of the parameter text, i.e. as a RAW text level pre-processor. The definition of a repeated pattern is started by a dedicated symbol prepended to the normal parameter values. (This sign defaults to "$").
The parameter text of all subsequent events (upto pattern end) form the pattern.
The end of the pattern definition is the start of its usage, indicated by a certain start marker, which defaults to "IDEM".
The end of the usage may be anywhere. It is caused by any explicit parameter value (possibly starting a new pattern), or by a special marker, which defaults to "TERM".
The repetition can be resumed after a certain pause: By the start marker again, it will start from its beginning, or by a special marker (which defaults to "CONT") it will resume with the same phase as its preceding use had been terminated.
All these special markers (but not the patter definition lead in) must be the only contents of the event's parameter.
The patterns are collected and distributed in their textual representation, i.e. without and prior to any analysis.
The behaviour can be depicted by the following state machine:
start---> [INIT] | | "$xxx" V -----> [COLLECTING] <-------- ^^ | | ________ ) "$xxx" || | |"IDEM" || | | ||"$yyy" | V (starting from 0) <---- ||____ |[USING]_________________________) "IDEM" | | | <------------ | | | | | "TERM"| | | | | |"TERM"/"zzz" | |"$yyy" V V | "CONT"/"IDEM" ------- [SUSPENDED] ------------/
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
States of the state machine. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default forendUse
static final String
Default forresumeUse
static final String
Default forstartDef
static final String
Default forstartUse
protected final String
String constant ending the use of the pattern, when parsed in the parameter track.protected final MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>>
The drain of error messagesprotected final String
Name of the parameter track to process.protected List<CheckedList<CheckedPair_LR<eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier>,
String>>> Store for the parameter values which make up the pattern.protected int
Current counter for re-playing the pattern.protected PatternDistributor.Phase
State of the state machine, modelling recording and playback.protected final String
String constant ending the use of the pattern, when parsed in the parameter track.protected final String
String constant starting the definition/recording of a patternprotected final int
Holds the string length ofstartDef
, for conenience.protected final String
String constant starting the use of the pattern, when parsed in the parameter track. -
Constructor Summary
ConstructorDescriptionPatternDistributor
(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String pname) Constructor with default string values for the keywords.PatternDistributor
(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String pname, String startDef, String startUse, String endUse, String resumeUse) Constructor with explicit string values for the keywords. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Remove the "start pattern definition" prefixstartDef
from the parameter source text.protected void
copyFromPattern
(Event ev) Copy the parameter value back into the voice from the current pattern position.protected void
copyIntoPattern
(Event ev) Record the parameter value back fromt the voice into the pattern.(package private) void
exclusiveCheck
(eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> location, String paramName, String keyword, String input) Raises an error iff the keyword is not the only contents of the parameter source text.void
Service access point: Process this voice and replace the pattern keywords in its parameter track (with the name given when creating this instance) by pattern expansion.protected void
startUsing
(Event ev, String ptext, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, String keyword, boolean reset) Start with the given event the re-play of the pattern.
-
Field Details
-
msg
The drain of error messages -
paramName
Name of the parameter track to process. -
startDef
String constant starting the definition/recording of a pattern -
startDef_length
protected final int startDef_lengthHolds the string length ofstartDef
, for conenience. -
startUse
String constant starting the use of the pattern, when parsed in the parameter track. -
endUse
String constant ending the use of the pattern, when parsed in the parameter track. -
resumeUse
String constant ending the use of the pattern, when parsed in the parameter track. -
default_startDef
Default forstartDef
- See Also:
-
default_startUse
Default forstartUse
- See Also:
-
default_endUse
Default forendUse
- See Also:
-
default_resumeUse
Default forresumeUse
- See Also:
-
pattern
protected List<CheckedList<CheckedPair_LR<eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier>,String>>> patternStore for the parameter values which make up the pattern. -
patternphase
protected int patternphaseCurrent counter for re-playing the pattern. -
phase
State of the state machine, modelling recording and playback.
-
-
Constructor Details
-
PatternDistributor
public PatternDistributor(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String pname) Constructor with default string values for the keywords.- Parameters:
msg
- the drain for the error messages.pname
- the name of the parsameter track to process.
-
PatternDistributor
public PatternDistributor(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String pname, String startDef, String startUse, String endUse, String resumeUse) Constructor with explicit string values for the keywords.- Parameters:
msg
- the drain for the error messages.pname
- the name of the parameter track to process.
-
-
Method Details
-
copyFromPattern
Copy the parameter value back into the voice from the current pattern position. -
copyIntoPattern
Record the parameter value back fromt the voice into the pattern. -
adjust
Remove the "start pattern definition" prefixstartDef
from the parameter source text. (This includes adjustment of the location.) This is destructive: The event object will be altered. FIXME ginge auch NUR auf "pattern" !?!?! -
exclusiveCheck
void exclusiveCheck(eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> location, String paramName, String keyword, String input) Raises an error iff the keyword is not the only contents of the parameter source text. -
startUsing
protected void startUsing(Event ev, String ptext, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, String keyword, boolean reset) Start with the given event the re-play of the pattern.- Parameters:
ev
- the current eventptext
- the input value for this parameter (for error messageing only)loc
- the location of the parameters input text (for error messageing only)keyword
- the keyword found in the source text (for error messageing only)reset
- whether to start with the beginning of the pattern, not to resume it.
-
process
Service access point: Process this voice and replace the pattern keywords in its parameter track (with the name given when creating this instance) by pattern expansion.
-