-
Notifications
You must be signed in to change notification settings - Fork 17
/
compute_indices.html
156 lines (149 loc) · 15 KB
/
compute_indices.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module compute_indices_object</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>compute_indices_object</strong></big></big> (version 0.2)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/guyot/Documents/Workspaces/Python/Acoustic_Indices/compute_indices_object.py">/Users/guyot/Documents/Workspaces/Python/Acoustic_Indices/compute_indices_object.py</a></font></td></tr></table>
<p><tt>Set of functions to compute acoustic indices in the framework of Soundscape Ecology.<br>
<br>
Some features are inspired or ported from those proposed in:<br>
- seewave R package (<a href="http://rug.mnhn.fr/seewave/">http://rug.mnhn.fr/seewave/</a>) / Jerome Sueur, Thierry Aubin and Caroline Simonis<br>
- soundecology R package (<a href="http://cran.r-project.org/web/packages/soundecology/index.html">http://cran.r-project.org/web/packages/soundecology/index.html</a>) / Luis J. Villanueva-Rivera and Bryan C. Pijanowski<br>
<br>
This file use an object oriented type for audio files described in the file "acoustic_index.py".</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
</td><td width="25%" valign=top><a href="scipy.signal.html">scipy.signal</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-compute_ACI"><strong>compute_ACI</strong></a>(spectro, j_bin)</dt><dd><tt>Compute the Acoustic Complexity Index from the spectrogram of an audio signal.<br>
<br>
Reference: Pieretti N, Farina A, Morri FD (2011) A new methodology to infer the singing activity of an avian community: the Acoustic Complexity Index (ACI). Ecological Indicators, 11, 868-873.<br>
<br>
Ported from the soundecology R package.<br>
<br>
spectro: the spectrogram of the audio signal<br>
j_bin: temporal size of the frame (in samples)</tt></dd></dl>
<dl><dt><a name="-compute_ADI"><strong>compute_ADI</strong></a>(spectro, freq_band_Hz, max_freq<font color="#909090">=10000</font>, db_threshold<font color="#909090">=-50</font>, freq_step<font color="#909090">=1000</font>)</dt><dd><tt>Compute Acoustic Diversity Index.<br>
<br>
spectro: spectrogram of the audio signal<br>
freq_band_Hz: frequency band (in Hertz)<br>
max_freq: the maximum frequency to consider (in Hertz)<br>
db_threshold: the minimum dB value to consider for the bins of the spectrogram<br>
freq_step: width of the frequency bands that are considered<br>
<br>
<br>
Ported from the soundecology R package.</tt></dd></dl>
<dl><dt><a name="-compute_AEI"><strong>compute_AEI</strong></a>(spectro, freq_band_Hz, max_freq<font color="#909090">=10000</font>, db_threshold<font color="#909090">=-50</font>, freq_step<font color="#909090">=1000</font>)</dt><dd><tt>Compute Acoustic Evenness Index of an audio signal.<br>
<br>
spectro: spectrogram of the audio signal<br>
freq_band_Hz: frequency band (in Hertz)<br>
max_freq: the maximum frequency to consider (in Hertz)<br>
db_threshold: the minimum dB value to consider for the bins of the spectrogram<br>
freq_step: width of the frequency bands that are considered<br>
<br>
Ported from the soundecology R package.</tt></dd></dl>
<dl><dt><a name="-compute_BI"><strong>compute_BI</strong></a>(spectro, frequencies, min_freq<font color="#909090">=2000</font>, max_freq<font color="#909090">=8000</font>)</dt><dd><tt>Compute the Bioacoustic Index from the spectrogram of an audio signal.<br>
In theis code, the Bioacoustic Index correspond to the area under the mean spectre (in dB) minus the minimum frequency value of this mean spectre.<br>
<br>
Reference: Boelman NT, Asner GP, Hart PJ, Martin RE. 2007. Multi-trophic invasion resistance in Hawaii: bioacoustics, field surveys, and airborne remote sensing. Ecological Applications 17: 2137-2144.<br>
<br>
spectro: the spectrogram of the audio signal<br>
min_freq: minimum frequency (in Hertz)<br>
max_freq: maximum frequency (in Hertz)<br>
<br>
Ported from the soundecology R package.</tt></dd></dl>
<dl><dt><a name="-compute_NDSI"><strong>compute_NDSI</strong></a>(file, windowLength<font color="#909090">=1024</font>, anthrophony<font color="#909090">=[1000, 2000]</font>, biophony<font color="#909090">=[2000, 11000]</font>)</dt><dd><tt>Compute Normalized Difference Sound Index from an audio signal.<br>
This function compute an estimate power spectral density using Welch's method.<br>
<br>
Reference: Kasten, Eric P., Stuart H. Gage, Jordan Fox, and Wooyeong Joo. 2012. The Remote Environ- mental Assessment Laboratory's Acoustic Library: An Archive for Studying Soundscape Ecology. Ecological Informatics 12: 50-67.<br>
<br>
windowLength: the length of the window for the Welch's method.<br>
anthrophony: list of two values containing the minimum and maximum frequencies (in Hertz) for antrophony.<br>
biophony: list of two values containing the minimum and maximum frequencies (in Hertz) for biophony.<br>
<br>
Inspired by the seewave R package, the soundecology R package and the original matlab code from the authors.</tt></dd></dl>
<dl><dt><a name="-compute_SH"><strong>compute_SH</strong></a>(spectro)</dt><dd><tt>Compute Spectral Entropy of Shannon from the spectrogram of an audio signal.<br>
<br>
spectro: the spectrogram of the audio signal<br>
<br>
Ported from the seewave R package.</tt></dd></dl>
<dl><dt><a name="-compute_TH"><strong>compute_TH</strong></a>(file, integer<font color="#909090">=True</font>)</dt><dd><tt>Compute Temporal Entropy of Shannon from an audio signal.<br>
<br>
file: an instance of the AudioFile class.<br>
integer: if set as True, the Temporal Entropy will be compute on the Integer values of the signal. If not, the signal will be set between -1 and 1.<br>
<br>
Ported from the seewave R package.</tt></dd></dl>
<dl><dt><a name="-compute_rms_energy"><strong>compute_rms_energy</strong></a>(file, windowLength<font color="#909090">=512</font>, windowHop<font color="#909090">=256</font>, integer<font color="#909090">=False</font>)</dt><dd><tt>Compute the RMS short time energy.<br>
<br>
file: an instance of the AudioFile class.<br>
windowLength: size of the sliding window (samples)<br>
windowHop: size of the lag window (samples)<br>
integer: if set as True, the Temporal Entropy will be compute on the Integer values of the signal. If not, the signal will be set between -1 and 1.<br>
<br>
return: a list of values (rms energy for each window)</tt></dd></dl>
<dl><dt><a name="-compute_spectral_centroid"><strong>compute_spectral_centroid</strong></a>(spectro, frequencies)</dt><dd><tt>Compute the spectral centroid of an audio signal from its spectrogram</tt></dd></dl>
<dl><dt><a name="-compute_spectrogram"><strong>compute_spectrogram</strong></a>(file, windowLength<font color="#909090">=512</font>, windowHop<font color="#909090">=256</font>, scale_audio<font color="#909090">=True</font>, square<font color="#909090">=True</font>, windowType<font color="#909090">='hanning'</font>, centered<font color="#909090">=False</font>, normalized<font color="#909090">=False</font>)</dt><dd><tt>Compute a spectrogram of an audio signal.<br>
Return a list of list of values as the spectrogram, and a list of frequencies.<br>
<br>
Keyword arguments:<br>
file -- the real part (default 0.0)<br>
<br>
Parameters:<br>
@param sig: the audio signal samples (read for example from a .wav with scipy.io.wavfile)<br>
wLen: length of the fft window (in samples)<br>
wHop: hop size of the fft window (in samples)<br>
scale_audio: if set as True, the signal samples are scale between -1 and 1 (as the audio convention). If false the signal samples remains Integers (as output from scipy.io.wavfile)<br>
square: if set as True, the spectrogram is computed as the square of the magnitude of the fft. If not, it is the magnitude of the fft.<br>
hamming: if set as True, the spectrogram use a correlation with a hamming window.<br>
centered: if set as true, each resulting fft is centered on the corresponding sliding window<br>
normalized: if set as true, divide all values by the maximum value</tt></dd></dl>
<dl><dt><a name="-compute_zcr"><strong>compute_zcr</strong></a>(file, windowLength<font color="#909090">=512</font>, windowHop<font color="#909090">=256</font>)</dt><dd><tt>Compute the Zero Crossing Rate of an audio signal.<br>
<br>
file: an instance of the AudioFile class.<br>
windowLength: size of the sliding window (samples)<br>
windowHop: size of the lag window (samples)<br>
<br>
return: a list of values (number of zero crossing for each window)</tt></dd></dl>
<dl><dt><a name="-gini"><strong>gini</strong></a>(values)</dt><dd><tt>Compute the Gini index of values.<br>
<br>
values: a list of values<br>
<br>
Inspired by <a href="http://mathworld.wolfram.com/GiniCoefficient.html">http://mathworld.wolfram.com/GiniCoefficient.html</a> and <a href="http://en.wikipedia.org/wiki/Gini_coefficient">http://en.wikipedia.org/wiki/Gini_coefficient</a></tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>__author__</strong> = 'Patrice Guyot'<br>
<strong>__credits__</strong> = ['Patrice Guyot', 'Alice Eldridge', 'Mika Peck']<br>
<strong>__status__</strong> = 'Development'<br>
<strong>__version__</strong> = '0.2'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Patrice Guyot</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">['Patrice Guyot', 'Alice Eldridge', 'Mika Peck']</td></tr></table>
</body></html>