Sound: Draw where...

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

Settings

Time range (s)
selects the time domain for the drawing.
Vertical range
defines the vertical limits; larger amplitudes will be clipped.
Draw only those parts where the following condition holds
determines the part of the sound that will be drawn. All parts where the formula evaluates to true will be drawn. This formula may not contain references to the sampling of the sound, i.e. don't use 'col', 'x1', 'dx' and 'ncol' in it.

Example 1

The following script draws all amplitudes larger than one in red.

Create Sound from formula: "s", "Mono", 0, 1, 2000, ~ 1.8*sin(2*pi*5*x)+randomGauss(0,0.1)
Colour: "Red"
Draw where: 0, 0, -2, 2, "no", "Curve", ~ abs(self)>1
Colour: "Black"
Draw where: 0, 0, -2, 2, "yes", "Curve", ~ not (abs(self)>1)

Example 2

Draw the second half of a sound:

Draw where: 0, 0, -1, 1, "no", "Curve", ~ x > xmin + (xmax - xmin) / 2

Example 3

Draw only positive amplitudes:

Draw where: 0, 0, -1, 1, "no", "Curve", ~ self > 0

Example 4

Draw parts where pitch is larger than 300 Hz in red:

s = selected ("Sound")
p = To Pitch: 0, 75, 600
pt = Down to PitchTier
selectObject: s
Colour: ~ Red
Draw where: 0, 0, -1, 1, "yes", "Curve", ~ object (pt, x) > 300
Colour: ~ Black
Draw where: 0, 0, -1, 1, "yes", "Curve", ~ not (object (pt, x) > 300)

Links to this page


© djmw, August 29, 2017