| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Sound: Draw 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: Draw where... |
| 13 | </b></font></table></table> |
| 14 | <p>A command to draw only those parts of a <a href="Sound.html">Sound</a> where a condition holds.</p> |
| 15 | <h2>Settings</h2> |
| 16 | <p align=middle><img height=363.99999999999994 width=540 src=Sound__Draw_where____1.png></p><dl> |
| 17 | <dt><b>Time range (s)</b> |
| 18 | <dd>selects the time domain for the drawing.</dd> |
| 19 | <dt><b>Vertical range</b> |
| 20 | <dd>defines the vertical limits; larger amplitudes will be clipped.</dd> |
| 21 | <dt><b>Draw only those parts where the following condition holds</b> |
| 22 | <dd>determines the part of the sound that will be drawn. All parts where the formula evaluates to true will be drawn. 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> |
| 23 | </dl> |
| 24 | <h2>Example 1</h2> |
| 25 | <p>The following script draws all amplitudes larger than one in red.</p> |
| 26 | <code> Create Sound from formula: "s", "Mono", 0, 1, 2000, ~ 1.8*sin(2*pi*5*x)+randomGauss(0,0.1)<br></code> |
| 27 | <code> Colour: "Red"<br></code> |
| 28 | <code> Draw where: 0, 0, -2, 2, "no", "Curve", ~ abs(self)>1<br></code> |
| 29 | <code> Colour: "Black"<br></code> |
| 30 | <code> Draw where: 0, 0, -2, 2, "yes", "Curve", ~ not (abs(self)>1)<br></code> |
| 31 | <p align=middle><img height=300 width=800 src=Sound__Draw_where____2.png></p><h2>Example 2</h2> |
| 32 | <p>Draw the second half of a sound:</p> |
| 33 | <code> Draw where: 0, 0, -1, 1, "no", "Curve", ~ x > xmin + (xmax - xmin) / 2<br></code> |
| 34 | <h2>Example 3</h2> |
| 35 | <p>Draw only positive amplitudes:</p> |
| 36 | <code> Draw where: 0, 0, -1, 1, "no", "Curve", ~ self > 0<br></code> |
| 37 | <h2>Example 4</h2> |
| 38 | <p>Draw parts where pitch is larger than 300 Hz in red:</p> |
| 39 | <code> s = selected ("Sound")<br></code> |
| 40 | <code> p = To Pitch: 0, 75, 600<br></code> |
| 41 | <code> pt = Down to PitchTier<br></code> |
| 42 | <code> selectObject: s<br></code> |
| 43 | <code> Colour: ~ Red<br></code> |
| 44 | <code> Draw where: 0, 0, -1, 1, "yes", "Curve", ~ object (pt, x) > 300<br></code> |
| 45 | <code> Colour: ~ Black<br></code> |
| 46 | <code> Draw where: 0, 0, -1, 1, "yes", "Curve", ~ not (object (pt, x) > 300)<br></code> |
| 47 | <h3>Links to this page</h3> |
| 48 | <ul> |
| 49 | <li><a href="What_was_new_in_5_2_.html">What was new in 5.2?</a> |
| 50 | </ul> |
| 51 | <hr> |
| 52 | <address> |
| 53 | <p>© djmw 20170829</p> |
| 54 | </address> |
| 55 | </body> |
| 56 | </html> |