Type:
fragm: segment x real x real -> segment
fragm: sequence x real x real -> sequence
Call syntax:
fragm(segm,
pstart,
plen)
Description:
fragm returns the fragment of segment segm
beginning at beat position pstart
with a relative duration of plen beats.
The firsts beat of segm has beat position 0;
beat positions or relative durations are uniquely determined
by the values of the notes and rests in segm.
If necessary, fragm splits note to extract the
specified fragment (see examples).
If pstart is a negative number, the fragment is extracted beginning at d - |pstart|, where d is the duration of segm, i.e. the beat position of its right margin.
If plen is a negative number, pstart specifies the right margin of the fragment to be extracted, while the actual start-position (left margin) is calculated as pstart - |plen|.
fragm can also be applied to note sequences.
Error conditions:
fragm returns an empty segment (or sequence),
if both pstart and
pstart
+plan are outside the range of valid beat positions
of segm.
Example:
> sg:={[e/2 f],[g/2 a]}
> fragm(sg,0,3/4)
Result= SEGM([ e1/2 f1/4 ],[ g1/2 a1/4 ])
> fragm(sg,1,-1/4)
Result= SEGM([ f1/4 ],[ a1/4 ])
> fragm(sg,-1/2,-1/4)
Result= SEGM([ e1/4 ],[ g1/4 ])
> fragm(sg,3/2,-1/2)
Result= SEGM([ ],[ ])
> gMajor:=[g a h c2 d e f#]
> fragm(gMajor, 1/16, 3/4)
Result= [ g1*3/16 a1/4 h1/4 c2/16 ]
> fragm(gMajor, 3/8, 3/4)
Result= [ a1/8 h1/4 c2/4 d2/8 ]