SEGMENT evaluates a segment expression in various ways, returning a string
bseg eseg lseg
indicating the begin (bseg), the end (eseg) and the length (lseg) of the segment addressed by the respective segment expression.
Based on the current sound file
SEGMENT segexpr [ /Silent | /? ]
- the segment expression to be evaluated
- silent error handling; generate warnings rather than errors.
Based on supplied data
Evaluate the segment expression segexpr, using the specified sampling rate and length.
SEGMENT segexpr sr l [ /Silent | /? ]
- sampling rate in Hz
- maximum signal duration in samples
Based on data from an XML segment definition
Evaluate the segment expression segexpr, using the sampling rate and the segment definitions stored in the XML file item xmlfile.
SEGMENT segexpr xmlfile srattr segtag idattr pattr lattr [ /Silent | /? ]
- an XML file item containing the metadata; the selected element must contain sound file metadata, and the segment definitions must be stored as child elements
- the XML attribute of the selected element containing the sampling rate (in Hz)
- the XML element tag used for segment definitions
- idattr, pattr and lattr
- the XML attributes used in the segment definition elements to specifiy the segment id (idattr) and its starting position (pattr) and length (lattr)
bseg eseg lseg- the return value is the begin (bseg), the end (eseg) and the length (lseg) of the segment specified by the segment expression. The variable RC is set to 0.
- Note: If the segment expression specifies a label at position lpos, the return value is
lpos lpos 0.
- the command returns an empty string. As usual, the error, or warning code (0 on success) is stored in the variable RC.
STx uses a special syntax to address a segment of a sound file. The syntax allows for the mixed use of segment names and time values in a complex expression known as a segment expression. Segment expressions may be used in all commands and dialogs where a signal segment (or a position/duration) may be specified (exceptions are described in the Command Reference). In dialogs, the supported value formats/types are always described in the control/dialog caption.
A segment expression addresses a part of a sound file with a non-zero duration. It can consist of (1) a segment name, or (2) of two label expressions (see below) specifying the beginning and the end of the segment, or (3) of two label expressions (see below) specifying the position of the segment and its duration.
|labelexpression_labelexpression||(beginning and end)|
|labelexpression_+labelexpression||(beginning and duration)|
|labelexpression_-labelexpression||(end and duration)|
- A label expression is a position in a sound file (e.g. the begin/end of a segment) or the duration of a segment. A label expression may consist of a sign (+/-) and one or more values formatted as described below and combined with the operators + (add) or – (subtract). If a label expression contains blanks, it must be quoted when used as an argument.
|label expression||description||value in samples||comment|
|xs||x seconds||x * sr|
|xms||x milliseconds||x / 1000 * sr|
|xHz||periode of a signal with x Hz||sr / x|
|xkHz||periode of a signal with x kHz||sr / (x * 1000)|
|x%||x percent of the signal length||l * x / 100||only with this and that version of the |
|x%%||x per mill of the signal length||l * x / 1000||only with this and that version of the |
|segid||begin and length of the segment with id segid||only with this version of the |
|segid:b||begin of the segment with id segid||only with this version of the |
|segid:e||end of the segment with id segid||only with this version of the |
|segid:l||length of the segment with id segid||only with this version of the |
|Where:||x||is a number|
|sr||is the signal sampling rate in Hz|
|l||is the signal length in samples (e.g. soundfile length)|
|segid||is the ID of a segment defined in the XML file|
Below you will find a short list of examples.
- addresses the segment from sample 0 (the beginning) to 4 seconds into the file
- addresses 100 samples after the beginning of an existing segment called "SegmentB" for a duration of ten seconds
- addresses an existing segment called "SegmentB"
- addresses the range from the beginning of SegmentA to the end of SegmentB
- addresses the range starting 100 milliseconds before the end of SegmentB and ending at the end of SegmentB
For some expressions, the values
number% (percentage of the full duration) and
number%% (thousandths of the full duration) can be used, but only if the full signal is available/defined (e.g. for envelopes of sequence signals). A
segmentname can only be used if a sound file or an audio-element of an XML file is involved in the expression evaluation. Segment names are case sensitive.
Address 0 samples to 4 seconds of the current soundfile:
Address 2 seconds in the middle of the current soundfile:
Address 1 second to 1 second plus 100 samples of a signal with a 10kHz sampling rate and a 5 seconds duration:
segment 1s_+100 10000 5*10000
Note: XML attributes and element names and segment ids are case sensitive!
Address the whole signal of segment seg1:
segment seg1 xmlfile SR ASeg ID P L
Address the signal from the beginning of seg1 to the end of seg1 plus 2 seconds:
segment seg1:b_seg2:e+2s xmlfile SR ASeg ID P L