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

© djmw, May 2, 2013