soundscapecode

Python implemention of the soundscapecode, for analysing ecoacoustic soundscapes.

See the paper. This implementation is ported from a Matlab example.

Additionally, two sub-modules are provided:

  • soundscapecode.soundtrap contains utilities for working with data from soundtrap hydrophones.

  • soundscapecode.filters contains a highpass and bandpass filter compatible with Matlab filters of the same names.

Installation and Usage

pip install soundscapecode

Values can be calculated individually:

import soundscapecode as ssc

fs = 48000
mock_sound = np.random.rand(fs*60, 1)
periodicity = ssc.periodicity(mock_sound, fs)

Or to calculate all values for one recording:

from soundscapecode import SoundscapeCode

fs = 48000
n_mins = 3
mock_sound = np.random.rand(fs*n_mins*60, 1)
soundscape = SoundscapeCode(mock_sound, fs)
for dt in soundscape["dt"]:
    print(dt)

SoundscapeCode(sound, fs[, freq_range])

Wrapper for segmenting and calculating soundscape code metrics for a sound.

soundtrap.CalibrationData(serial, device, ...)

Holds soundtrap calibration information

max_spl(data[, reference_sound_pressure])

Calculates the maximum instantaneous sound pressure level for sound data.

rms_spl(data, fs[, reference_sound_pressure])

Calculates the root-mean-squared sound pressure level for sound data.

periodicity(data, fs)

Calculates the periodicity for sound data.

kurtosis(data)

Calculates the kurtosis for sound data.

temporal_dissimilarity(data_a, data_b)

Calculates the temporal dissimilarity between two sounds.

spectral_dissimilarity(m_freq_a, m_freq_b)

Calculates the spectral dissimilarity between two mean frequency inputs.

dissimilarity_index(data_a, data_b, ...)

Calculates the dissimilarity index between two sounds and the mean frequency inputs of the sounds.

soundtrap.soundtrap_conversion(signal, soundtrap)

Convert raw soundtrap values to uPa

soundtrap.get_soundtrap_calibration(serial)

Retrieve soundtrap information from OceanInstruments and save to output path

soundtrap.read_calibration(file_path)

Read soundtrap calibration information from file

soundtrap.open_wav(input_file[, channel, ...])

Open a wave file

filters.highpass(data, passband, fs[, ...])

Filter data with a highpass filter

filters.bandpass(data, band, fs[, ...])

Filter data with a bandpass filter