Skip to content

Microphone Settings

Alex Rogers edited this page Nov 21, 2024 · 13 revisions

The microphone of the AudioMoth is powered up and enabled using the function below.

void AudioMoth_enableMicrophone(AM_gainRange_t gainRange, AM_gainSetting_t gain, uint32_t clockDivider, uint32_t acquisitionCycles, uint32_t oversampleRate);

Understanding how to set these arguments requires some knowledge of the hardware configuration of the AudioMoth device.

Gain Range: This is the most straightforward. The analogue microphone signal is passed through a 2-stage amplifier whose gain can be controlled via software. The gain range can be AM_LOW_GAIN_RANGE or AM_NORMAL_GAIN_RANGE.

Gain: The actual gain of the 2-stage amplifier AM_GAIN_LOW, AM_GAIN_LOW_MEDIUM, AM_GAIN_MEDIUM, AM_GAIN_MEDIUM_HIGH, or AM_GAIN_HIGH, with the default value being AM_GAIN_MEDIUM.

Clock Divider: The ADC clock is derived from the main system clock (either the external 48MHz crystal oscillator or any of the internal RC oscillator bands) divided by a constant factor (from 1 to 128). The ADC clock determines the rate at which ADC conversion takes place and the maximum ADC clock speed is 14MHz.

Acquisition Cycles: Before the ADC conversion takes place, the ADC must capture the input voltage on the ADC. The duration of this capture is determined by this argument. The acquisition time can take values of 1, 2, 4, 8 and 16. The minimum acquisition time of 1 cycle is generally too short to capture good quality audio. In the default AudioMoth application we use an acquisition time of 16 cycles.

Oversample Rate: A single ADC conversion results in a 12 bit two's complement sample. It is possible to oversample in hardware from 1 to 128 times (restricted to 2^n values) with each multiple adding another bit to the ADC precision up to a maximum of 16 bits. In our default AudioMoth application the oversampling is done in software rather than hardware.

The arguments above give rise to a maximum possible sample rate:

Maximum Sample Rate = (2 + OverSample Rate * (Acquisition Cycles + 12)) / (Clock Frequency / Clock Divider)

The application should ensure that the sample rate requested in the AudioMoth_startMicrophoneSamples call is less than this value.

The default AudioMoth application uses the following settings:

Clock Divider = 4
Acquisition Cycles = 16
Oversample Rate = 1

All sample rates then use a baseline sampling rate of 250 or 384kHz, with software oversampling used to generate the slower rates.

The different sampling rates generate samples of different precision. The raw samples are always 12-bit values. Each halving of the sample rate adds another bit of precision up to the maximum of 16 bits supported by the WAV file format used. The overall amplitude is always normalised to cover the full 16 bits of the WAV file format.

Clone this wiki locally