Sound: To Polygon...

A command that creates a Polygon from a selected Sound, where the Polygon's points are defined by the (time, amplitude) pairs of the sound.

Settings

Channel
defines which channel of the sound is used.
Time range (s)
defines the part of the sound whose (time, amplitude) pairs have to be included.
Vertical range
defines the vertical limits, larger amplitudes will be clipped.
Connection y-value
defines the y-value of the first and last point of the Polygon. This gives the opportunity to draw a closed Polygon with the horizontal connection line at any position you like.

Example

The following script paints the area under a sound curve in red and the area above in green.

s = Create Sound from formula: "s", 1, 0, 1, 10000, ~ 0.5*sin(2*pi*5*x)
#Connection y-value is at amplitude -1: area under the curve.
p1 = To Polygon: 1, 0, 0, -1, 1, -1
Paint: "{1,0,0}", 0, 0, -1, 1
selectObject: s
#Connection y-value is now at amplitude 1: area above the curve.
p2 = To Polygon: 1, 0, 0, -1, 1, 1
Paint: "{0,1,0}", 0, 0, -1, 1


© djmw, August 29, 2017