| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Sound: Fade in...</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: Fade in... |
| 13 | </b></font></table></table> |
| 14 | <p>A command to gradually increase the amplitude of a selected <a href="Sound.html">Sound</a>.</p> |
| 15 | <h2>Settings</h2> |
| 16 | <dl> |
| 17 | <dt><b>Channel</b> |
| 18 | <dd>determines whether you want to fade all channels or only a selected channel.</dd> |
| 19 | <dt><b>Time (s)</b> |
| 20 | <dd>determines where the fade-in will take place. If <i>time</i> is earlier than the start time of the sound, the start time of the sound wil be used.</dd> |
| 21 | <dt><b>Fade time (s)</b> |
| 22 | <dd>determines the start point and the endpoint of the fade-in with respect to the <i>time</i> argument. Depending on the sign of <i>fadeTime</i>, <i>time</i> is either the start or the end position of the fade-in. If <i>fadeTime</i> is positive, fade-in will take place between <i>time</i> and <i>time+fadeTime</i>. If <i>fadeTime</i> is negative, fade-in wil take place between <i>time+fadeTime</i> and <i>time</i>.</dd> |
| 23 | <dt><b>Silent from start</b> |
| 24 | <dd>when on, makes the sound silent before the fade-in starts. When off, the sound before the fade-in starts will not be changed. </dd> |
| 25 | </dl> |
| 26 | <h2>Algorithm</h2> |
| 27 | <p>Multiplication with the first half period of a (1-cos(x))/2 function. </p> |
| 28 | <h2>Cross-fading two sounds</h2> |
| 29 | <p>The following script cross-fades two sounds s1 and s2 at time 1 second and leaves the result in s2.</p> |
| 30 | <code> crossFTime = 0.5<br></code> |
| 31 | <code> t = 1<br></code> |
| 32 | <code> s = Create Sound from formula: "s1", 1, 0, 2, 44100, ~ sin(2*pi*500*x)<br></code> |
| 33 | <code> Fade out: 0, t-crossFTime/2, crossFTime, "yes"<br></code> |
| 34 | <code> Create Sound from formula: "s2", 1, 0, 2, 44100, ~ sin(2*pi*1000*x)<br></code> |
| 35 | <code> Fade in.: 0, t-crossFTime/2, crossFTime, "yes"<br></code> |
| 36 | <code> Formula: ~ self + object [s]<br></code> |
| 37 | <hr> |
| 38 | <address> |
| 39 | <p>© djmw 20170829</p> |
| 40 | </address> |
| 41 | </body> |
| 42 | </html> |