| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Sound: Paint where...</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 | Sound: Paint where... |
| 13 | </b></font></table></table> |
| 14 | <p>A command to paint only those parts of a <a href="Sound.html">Sound</a> where a condition holds. The painted area is the area between the Sound and a horizontal line at a certain level.</p> |
| 15 | <h2>Settings</h2> |
| 16 | <p align=middle><img height=404 width=540 src=Sound__Paint_where____1.png></p><dl> |
| 17 | <dt><b>Colour</b> |
| 18 | <dd>defines the <a href="Colour.html">colour</a> of the paint.</dd> |
| 19 | <dt><b>Time range (s)</b> |
| 20 | <dd>selects the time domain for the drawing.</dd> |
| 21 | <dt><b>Vertical range</b> |
| 22 | <dd>defines the vertical limits; larger amplitudes will be clipped.</dd> |
| 23 | <dt><b>Fill from level</b> |
| 24 | <dd>defines the level of the horizontal line. </dd> |
| 25 | <dt><b>Formula</b> |
| 26 | <dd>determines the part of the sound that will be painted. All parts where the formula evaluates to true will be painted. This formula may <b>not</b> contain references to the sampling of the sound, i.e. don't use 'col', 'x1', 'dx' and 'ncol' in it.</dd> |
| 27 | </dl> |
| 28 | <h2>Example 1</h2> |
| 29 | <p>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.</p> |
| 30 | <code> s = Create Sound from formula: "s", 1, 0, 1, 10000, ~ 0.5*sin(2*pi*5*x)<br></code> |
| 31 | <code> Paint where: "Red", 0, 0, -1, 1, -1, "yes", ~ 1<br></code> |
| 32 | <code> Paint where: "Green", 0, 0, -1, 1, 1, "no", ~ 1 <br></code> |
| 33 | <p align=middle><img height=500 width=800 src=Sound__Paint_where____2.png></p><h2>Example 2</h2> |
| 34 | <p>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.</p> |
| 35 | <code> s = Create Sound from formula: "s", 1, 0, 1, 10000, ~ 0.5*sin(2*pi*5*x)<br></code> |
| 36 | <code> Paint where: "Red", 0, 0, -1, 1, 0, "no", ~ self > 0<br></code> |
| 37 | <code> Paint where: "Green", 0, 0, -1, 1, 0, "yes", ~ self < 0<br></code> |
| 38 | <p align=middle><img height=500 width=800 src=Sound__Paint_where____3.png></p><h2>Example 3</h2> |
| 39 | <p>To give an indication that the area under a 1/x curve between the points <i>a</i> and <i>b</i> and the area between <i>c</i> and <i>d</i> are equal if <i>b</i>/<i>a</i> = <i>d</i>/<i>c</i>. For example, for <i>a</i>=1, <i>b</i>=2, <i>c</i>=4 and <i>d</i>=8: </p> |
| 40 | <code> Create Sound from formula: "1dx", "Mono", 0, 20, 100, ~ 1.0 / x <br></code> |
| 41 | <code> Draw: 0, 20, 0, 1.5, "yes", "Curve"<br></code> |
| 42 | <code> Paint where: "Grey", 0, 20, 0, 1.5, 0, "yes", ~ (x >= 1 and x < 2) or (x >= 4 and x < 8)<br></code> |
| 43 | <code> One mark bottom: 1, "yes", "yes", "no", ""<br></code> |
| 44 | <code> One mark bottom: 2, "yes", "yes", "no", ""<br></code> |
| 45 | <code> One mark bottom: 4, "yes", "yes", "no", ""<br></code> |
| 46 | <code> One mark bottom: 8, "yes", "yes", "no", ""<br></code> |
| 47 | <p align=middle><img height=500 width=800 src=Sound__Paint_where____4.png></p><hr> |
| 48 | <address> |
| 49 | <p>© djmw 20170829</p> |
| 50 | </address> |
| 51 | </body> |
| 52 | </html> |