|
A command to draw only those parts of a Sound where a condition holds.

The following script draws all amplitudes larger than one in red.
do ("Create Sound from formula...", "s", "Mono", 0, 1, 2000, "1.8*sin(2*pi*5*x)+randomGauss(0,0.1)")
do ("Colour...", "Red")
do ("Draw where...", 0, 0, -2, 2, "no", "Curve", "abs(self)>1")
do ("Colour...", "Black")
do ("Draw where...", 0, 0, -2, 2, "yes", "Curve", "not (abs(self)>1)")

Draw the second half of a sound:
do ("Draw where...", 0, 0, -1, 1, "no", "Curve", "x > xmin + (xmax - xmin) / 2")
Draw only positive amplitudes:
do ("Draw where...", 0, 0, -1, 1, "no", "Curve", "self>0")
Draw parts where pitch is larger than 300 Hz in red:
s = selected ("Sound")
p = do ("To Pitch...", 0, 75, 600)
pt = do ("Down to PitchTier")
selectObject (s)
do ("Colour...", "Red")
do ("Draw where...", 0, 0, -1, 1, "yes", "Curve", "Object_'pt'(x) > 300")
do ("Colour...", "Black")
do ("Draw where...", 0, 0, -1, 1, "yes", "Curve", "not (Object_'pt'(x) > 300)")
© djmw, April 9, 2013