| 1 |
<html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 |
<title>Script for onset detection</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 |
Script for onset detection |
| 13 |
</b></font></table></table> |
| 14 |
<p>"Can anybody provide me with a script that detects the onset of sound (i.e. the end of silence)."</p> |
| 15 |
<p>You can create an Intensity contour and look for the first frame that is above some predefined threshold:</p> |
| 16 |
<code> To Intensity: 100, 0<br></code> |
| 17 |
<code> n = Get number of frames<br></code> |
| 18 |
<code> for i to n<br></code> |
| 19 |
<code> intensity = Get value in frame: i<br></code> |
| 20 |
<code> if intensity > 40<br></code> |
| 21 |
<code> time = Get time from frame: i<br></code> |
| 22 |
<code> writeInfoLine: "Onset of sound at: ", fixed$ (time, 3), " seconds."<br></code> |
| 23 |
<code> exit<br></code> |
| 24 |
<code> endif<br></code> |
| 25 |
<code> endfor<br></code> |
| 26 |
<p>Since the intensity is computed with rather long windows, the result may be 0.01 or 0.02 seconds before the actual start of sound.</p> |
| 27 |
<h3>Links to this page</h3> |
| 28 |
<ul> |
| 29 |
<li><a href="Scripting_examples.html">Scripting examples</a> |
| 30 |
</ul> |
| 31 |
<hr> |
| 32 |
<address> |
| 33 |
<p>© ppgb 20140112</p> |
| 34 |
</address> |
| 35 |
</body> |
| 36 |
</html> |