Sound: Paint where...

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.

Settings

Colour
defines the colour of the paint.
Time range (s)
selects the time domain for the drawing.
Vertical range
defines the vertical limits; larger amplitudes will be clipped.
Fill from level
defines the level of the horizontal line.
Formula
determines the part of the sound that will be painted. All parts where the formula evaluates to true will be painted. 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 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", 1, 0, 1, 10000, ~ 0.5*sin(2*pi*5*x)
Paint where: "Red", 0, 0, -1, 1, -1, "yes", ~ 1
Paint where: "Green", 0, 0, -1, 1, 1, "no", ~ 1

Example 2

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", 1, 0, 1, 10000, ~ 0.5*sin(2*pi*5*x)
Paint where: "Red", 0, 0, -1, 1, 0, "no", ~ self > 0
Paint where: "Green", 0, 0, -1, 1, 0, "yes", ~ self < 0

Example 3

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.0 / 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, "yes", "yes", "no", ""
One mark bottom: 2, "yes", "yes", "no", ""
One mark bottom: 4, "yes", "yes", "no", ""
One mark bottom: 8, "yes", "yes", "no", ""


© djmw, August 29, 2017