-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from dingraha/generic_pbs
Add proportional bands and proportional band spectra, etc
- Loading branch information
Showing
13 changed files
with
4,476 additions
and
548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
name = "AcousticMetrics" | ||
uuid = "046f749b-9c1e-43ca-86bc-6902340f753e" | ||
authors = ["Ingraham, Daniel James (GRC-LTV0) <[email protected]>"] | ||
version = "0.6.1" | ||
authors = ["Ingraham, Daniel James (GRC-LTV0) <[email protected]> and contributors"] | ||
version = "0.7.0" | ||
|
||
[deps] | ||
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471" | ||
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" | ||
FLOWMath = "6cb5d3fb-0fe8-4cc2-bd89-9fe0b19a99d3" | ||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | ||
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" | ||
|
||
[compat] | ||
julia = "1.8.2" | ||
ConcreteStructs = "0.2.2" | ||
FFTW = "1.4.3" | ||
FLOWMath = "0.3.3" | ||
ForwardDiff = "0.10.19" | ||
OffsetArrays = "1.10.4" | ||
julia = "1.8.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,92 @@ | ||
```@meta | ||
CurrentModule = AMDocs | ||
``` | ||
|
||
# API Reference | ||
|
||
```@autodocs | ||
Modules = [AcousticMetrics] | ||
## Fourier Transforms | ||
```@docs | ||
AcousticMetrics.rfft! | ||
AcousticMetrics.irfft! | ||
``` | ||
|
||
## Pressure Time History | ||
```@docs | ||
AbstractPressureTimeHistory | ||
PressureTimeHistory | ||
AcousticMetrics.pressure | ||
AcousticMetrics.inputlength | ||
AcousticMetrics.timestep(pth::AbstractPressureTimeHistory) | ||
AcousticMetrics.starttime(pth::AbstractPressureTimeHistory) | ||
AcousticMetrics.time | ||
``` | ||
|
||
## Narrowband Metrics | ||
```@docs | ||
AbstractNarrowbandSpectrum | ||
AcousticMetrics.halfcomplex | ||
AcousticMetrics.timestep(sm::AbstractNarrowbandSpectrum) | ||
AcousticMetrics.starttime(sm::AbstractNarrowbandSpectrum) | ||
AcousticMetrics.samplerate | ||
AcousticMetrics.frequency | ||
AcousticMetrics.frequencystep | ||
AcousticMetrics.istonal | ||
PressureSpectrumAmplitude | ||
PressureSpectrumPhase | ||
MSPSpectrumAmplitude | ||
MSPSpectrumPhase | ||
PowerSpectralDensityAmplitude | ||
PowerSpectralDensityPhase | ||
``` | ||
|
||
### Proportional Bands and Proportional Band Spectra | ||
```@docs | ||
AbstractProportionalBands | ||
AcousticMetrics.octave_fraction | ||
AcousticMetrics.lower_center_upper | ||
AcousticMetrics.freq_scaler | ||
AcousticMetrics.band_start | ||
AcousticMetrics.band_end | ||
AcousticMetrics.lower_bands | ||
AcousticMetrics.upper_bands | ||
AcousticMetrics.center_bands | ||
AcousticMetrics.cband_number | ||
ExactProportionalBands | ||
ExactOctaveCenterBands | ||
ExactOctaveLowerBands | ||
ExactOctaveUpperBands | ||
ExactThirdOctaveCenterBands | ||
ExactThirdOctaveLowerBands | ||
ExactThirdOctaveUpperBands | ||
ApproximateThirdOctaveBands | ||
ApproximateThirdOctaveCenterBands | ||
ApproximateThirdOctaveLowerBands | ||
ApproximateThirdOctaveUpperBands | ||
ApproximateOctaveBands | ||
ApproximateOctaveCenterBands | ||
ApproximateOctaveLowerBands | ||
ApproximateOctaveUpperBands | ||
AbstractProportionalBandSpectrum | ||
AcousticMetrics.has_observer_time | ||
AcousticMetrics.observer_time | ||
AcousticMetrics.timestep(pbs::AbstractProportionalBandSpectrum) | ||
AcousticMetrics.amplitude | ||
AcousticMetrics.time_period | ||
AcousticMetrics.time_scaler | ||
LazyNBProportionalBandSpectrum | ||
AcousticMetrics.frequency_nb | ||
AcousticMetrics.lazy_pbs | ||
ProportionalBandSpectrum | ||
LazyPBSProportionalBandSpectrum | ||
ProportionalBandSpectrumWithTime | ||
AcousticMetrics.combine | ||
``` | ||
|
||
## Weighting | ||
```@docs | ||
W_A | ||
``` | ||
|
||
## Integrated Metrics | ||
```@docs | ||
OASPL | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
module AcousticMetrics | ||
|
||
using ConcreteStructs: @concrete | ||
using Base.Iterators: Iterators | ||
using Base.Order: ord, Forward | ||
using FFTW: r2r!, R2HC, HC2R, rfftfreq | ||
using FLOWMath: abs_cs_safe | ||
using ForwardDiff: ForwardDiff | ||
using OffsetArrays: OffsetArray | ||
|
||
include("constants.jl") | ||
|
||
include("fourier_transforms.jl") | ||
|
||
include("narrowband.jl") | ||
export AbstractPressureTimeHistory, PressureTimeHistory | ||
export AbstractNarrowbandSpectrum | ||
export PressureSpectrumAmplitude, PressureSpectrumPhase, MSPSpectrumAmplitude, MSPSpectrumPhase, PowerSpectralDensityAmplitude, PowerSpectralDensityPhase | ||
|
||
include("integrated.jl") | ||
export OASPL | ||
|
||
include("proportional_bands.jl") | ||
export AbstractProportionalBands | ||
export ExactProportionalBands | ||
export ExactOctaveCenterBands, ExactOctaveLowerBands, ExactOctaveUpperBands | ||
export ExactThirdOctaveCenterBands, ExactThirdOctaveLowerBands, ExactThirdOctaveUpperBands | ||
export ApproximateOctaveBands, ApproximateOctaveCenterBands, ApproximateOctaveLowerBands, ApproximateOctaveUpperBands | ||
export ApproximateThirdOctaveBands, ApproximateThirdOctaveCenterBands, ApproximateThirdOctaveLowerBands, ApproximateThirdOctaveUpperBands | ||
export AbstractProportionalBandSpectrum, LazyNBProportionalBandSpectrum, ProportionalBandSpectrum, ProportionalBandSpectrumWithTime, LazyPBSProportionalBandSpectrum | ||
|
||
include("weighting.jl") | ||
export W_A | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
OASPL(ap::AbstractPressureTimeHistory) | ||
Return the overall sound pressure level of a pressure time history. | ||
""" | ||
function OASPL(ap::AbstractPressureTimeHistory) | ||
p = pressure(ap) | ||
n = inputlength(ap) | ||
p_mean = sum(p)/n | ||
msp = sum((p .- p_mean).^2)/n | ||
return 10*log10(msp/p_ref^2) | ||
end | ||
|
||
""" | ||
OASPL(ap::AbstractNarrowbandSpectrum) | ||
Return the overall sound pressure level of a narrowband spectrum. | ||
""" | ||
function OASPL(sp::AbstractNarrowbandSpectrum) | ||
amp = MSPSpectrumAmplitude(sp) | ||
msp = sum(@view amp[begin+1:end]) | ||
return 10*log10(msp/p_ref^2) | ||
end |
Oops, something went wrong.