Debian Codegraph @

docs/manual/Get_sample_number_from_time___.html

raw
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Get sample number from time...</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 Get sample number from time...
13 </b></font></table></table>
14 <p>A command that becomes available in the <a href="Query_submenu.html">Query submenu</a> if you select a <a href="Sound.html">Sound</a> or <a href="LongSound.html">LongSound</a> object.</p>
15 <p>The Info window will tell you the sample number belonging to the time that you specify. The result is presented as a real number.</p>
16 <h2>Setting</h2>
17 <dl>
18 <dt><b>Time (s)</b>
19 <dd>the time (in seconds) for which you want to know the sample number.</dd>
20 </dl>
21 <h2>Example</h2>
22 <p>If the sound has a sampling frequency of 10 kHz, the sample number associated with a time of 0.1 seconds will usually be 1000.5.</p>
23 <h2>Scripting</h2>
24 <p>You can use this command to put the nearest sample number into a script variable:</p>
25 <code> selectObject: "Sound hallo"<br></code>
26 <code> sampleNumber = Get sample number from time... 0.1<br></code>
27 <code> nearestSample = round (sampleNumber)<br></code>
28 <p>In this case, the value will not be written into the Info window. To round down or up, use</p>
29 <code> leftSample = floor (sampleNumber)<br></code>
30 <code> rightSample = ceiling (sampleNumber)<br></code>
31 <h2>Algorithm</h2>
32 <p>the result is</p>
33 <table width="100%" style="white-space:pre-wrap"><tr><td align=middle>1 + (<i>time</i> &#8211; <i>t</i><sub>1</sub>) / &#916;<i>t</i></table>
34 <p>where <i>t</i><sub>1</sub> is the time associated with the first sample, and &#916;<i>t</i> is the sampling period.</p>
35 <h2>Details for hackers</h2>
36 <p>If you select a Sound or LongSound and click <a href="Inspect.html">Inspect</a>, you can see how the relation between sample numbers and times is stored in the object: <i>t</i><sub>1</sub> is the <b>x1</b> attribute, and &#916;<i>t</i> is the <b>dx</b> attribute.</p>
37 <hr>
38 <address>
39 <p>© ppgb 20221202</p>
40 </address>
41 </body>
42 </html>