|
A command to paint only those parts of a Sound where a condition holds. The painted area is the area between the Sound and a horizontal line at a certain level.

The following script paints the area under a sine curve in red and the area above in green.For the first paint the horizontal line is at y=-1, for the second paint the line is at y=+1. The formula always evaluates to true.
s = Create Sound from formula... s Mono 0 1 10000 0.5*sin(2*pi*5*x)
Paint where... Red 0 0 -1 1 -1 y 1
Paint where... Green 0 0 -1 1 1 n 1

The following script paints the area below zero in red and the area above in green.The horizontal line is now always at y=0 and we use the formula to differentiate the areas.
s = Create Sound from formula... s Mono 0 1 10000 0.5*sin(2*pi*5*x)
Paint where... Red 0 0 -1 1 0 n self>0
Paint where... Green 0 0 -1 1 0 y self<0

To give an indication that the area under a 1/x curve between the points a and b and the area between c and d are equal if b/a = d/c. For example, for a=1, b=2, c=4 and d=8:
Create Sound from formula... 1dx Mono 0 20 100 1/x
Draw... 0 20 0 1.5 yes Curve
Paint where... Grey 0 20 0 1.5 0 yes (x >= 1 and x <2) or (x>=4 and x<8)
One mark bottom... 1 y y n
One mark bottom... 2 y y n
One mark bottom... 4 y y n
One mark bottom... 8 y y n

© djmw, February 13, 2011