|
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.
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 20170829