Interface: moteiv.tos.sensorboards.invent.Microphone

interface Microphone

Interface for sampling data from a microphone.

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>

Commands
command result_t repeatStart(void *addr, uint16_t length) repeatStart() may only be called inside a "repeat()" event The purpose of this function is to keep the same settings but change the buffer used for sampling the microphone
command result_t start(void *addr, uint16_t length, uint16_t freq, bool repeat) Start receiving data from a microphone and store the data at a specified address in memory.
command result_t stop() Stop the current recording.

Events
event void done(void *addr, uint16_t length) Notification that the buffer is no longer in use.
event result_t repeat(void *addr, uint16_t length) Notification that the sampling process is repeating.

Commands - Details

repeatStart

command result_t repeatStart(void *addr, uint16_t length)

repeatStart() may only be called inside a "repeat()" event The purpose of this function is to keep the same settings but change the buffer used for sampling the microphone

Parameters:
addr - New address for the next set of samples
length - number of samples to acquire
Returns:
SUCCESS if the new settings are accepted

start

command result_t start(void *addr, uint16_t length, uint16_t freq, bool repeat)

Start receiving data from a microphone and store the data at a specified address in memory.

Parameters:
addr - Memory address of first sample
length - The length of the audio sample
freq - Time between samples in microseconds
repeat - TRUE to repeat the transfer and ask for the next buffer, FALSE to only take 'length' samples and then stop
Returns:
SUCCESS if the playback can begin immediately

stop

command result_t stop()

Stop the current recording. If no sampling is underway or if the samples cannot be stopped, FAIL will be returned by stop(). If a sample is being recorded, after it is stopped with the stop() command, a done() event will be signalled to notify the caller that the buffer is now free and recording has halted.

Returns:
SUCCESS if playback is halted (a done() event will be signalled), FAIL if no sample is playing or if it cannot be halted.

Events - Details

done

event void done(void *addr, uint16_t length)

Notification that the buffer is no longer in use. done() is fired after a single sample recording (start() with repeat = FALSE) or after stop() is called.

Parameters:
addr - Address of the audio sample
length - Length of the audio sample
freq - Frequency of the recorded audio sample (in us)

repeat

event result_t repeat(void *addr, uint16_t length)

Notification that the sampling process is repeating. A new buffer and length MUST BE IMMEDIATELY returned to the caller through the repeatStart() command. If FAIL is returned, recording halts and a done() event is signalled.