# AcousticFeatures

This package implements a set of methods to compute generic acoustic features in AxisArrays for 1-D time series acoustic data.

The acoustic features are:

- Energy
- Myriad
- Frequency Contours
- Sound Pressure Level
- Impulse Statistics (number of impulses, mean and variance of inter-impulse intervals)
- Alpha Stable Statistics (α and scale)
- Entropy (temporal entropy, spectral entropy and entropy index)
- Zero Crossing Rate
- Spectral Centroid
- Spectral Flatness
- Permutation Entropy
- PSD
- Acoustic Complexity Index
- Statistical Complexity

## Installation

`using Pkg; pkg"add https://github.com/ymtoo/AcousticFeatures.jl.git"`

## Usage

```
using AcousticFeatures, DSP, SignalAnalysis, Plots
function compare(sc1, sc2)
plot(sc1.axes[1] ./ fs, vec(sc1.data),
xlabel = "Time (sec)",
ylabel = "Permutation Entropy",
label = "without chirp",
color = :blue,
dpi = 150,
thickness_scaling = 1.0,
legend=:bottomleft
)
plot!(sc2.axes[1] ./ fs, vec(sc2.data),
xlabel = "Time (sec)",
ylabel = "Permutation Entropy",
label = "with chirp",
color = :red,
dpi = 150,
thickness_scaling = 1.0,
legend=:bottomleft
)
end
N = 2400
fs = 2400
v = randn(Float64, 3*N)
s = real(chirp(500, 1000, 1.0, fs))
x = copy(v);
x[N:2*N-1] += s
specgram(signal(x,fs); fs=fs,nfft=128)
```

```
winlen = 2400
noverlap = 1200
pe = PermutationEntropy(5, 1, true, true)
sc1 = Score(
pe,
v;
winlen = winlen,
noverlap = noverlap
)
sc2 = Score(
pe,
x;
winlen = winlen,
noverlap = noverlap
)
compare(sc1, sc2)
```

```
N = 2400
fs = 2400
v = randn(Float64, 3*N)
Ns = fs ÷ 100
bpf = fir(13, 500, 1000; fs=fs)
s = 10 .* filtfilt(bpf, randn(Float64, Ns)) #real(chirp(500, 1100, 0.1, fs))
x = copy(v);
Ngap = fs ÷ 10
x[N:N+Ns-1] += s
x[N+5Ngap:N+5Ngap+Ns-1] += s
x[N+9Ngap:N+9Ngap+Ns-1] += s
specgram(signal(x,fs); nfft=128, fs=fs)
```

```
winlen = 2400
noverlap = 1200
pe = PermutationEntropy(5, 1, true, true)
sc1 = Score(
pe,
v;
winlen = winlen,
noverlap = noverlap,
)
sc2 = Score(
pe,
x;
winlen = winlen,
noverlap = noverlap,
)
compare(sc1, sc2)
```