Maple driver for microphone input devices
More...
|
file | sip.h |
| Definitions for using the Sound Input Peripheral.
|
|
Maple driver for microphone input devices
◆ SIP_DEFAULT_GAIN
#define SIP_DEFAULT_GAIN 0x0F |
◆ SIP_MAX_GAIN
#define SIP_MAX_GAIN 0x1F |
◆ SIP_MIN_GAIN
#define SIP_MIN_GAIN 0x00 |
◆ SIP_SAMPLE_11KHZ
#define SIP_SAMPLE_11KHZ 0x00 |
Record samples at 11.025kHz.
◆ SIP_SAMPLE_16BIT_SIGNED
#define SIP_SAMPLE_16BIT_SIGNED 0x00 |
Record 16-bit signed integer samples.
◆ SIP_SAMPLE_8BIT_ULAW
#define SIP_SAMPLE_8BIT_ULAW 0x01 |
Record 8-bit ulaw samples.
◆ SIP_SAMPLE_8KHZ
#define SIP_SAMPLE_8KHZ 0x01 |
◆ SIP_SUBCOMMAND_BASIC_CTRL
#define SIP_SUBCOMMAND_BASIC_CTRL 0x02 |
Start and stop sampling.
This subcommand is used with the MAPLE_COMMAND_MICCONTROL command to start and stop sampling on the microphone.
◆ SIP_SUBCOMMAND_GET_SAMPLES
#define SIP_SUBCOMMAND_GET_SAMPLES 0x01 |
Get recorded samples from the microphone device.
This subcommand is used with the MAPLE_COMMAND_MICCONTROL command to fetch samples from the microphone.
◆ sip_sample_cb
Type for a microphone sample callback.
This is the signature that is required for a function to accept samples from the microphone as it is sampling. This function will be called about once per frame, and in an interrupt context (so it should be pretty quick to execute). Basically, all you should do in one of these is copy the samples out to your own buffer – do not do any processing on the samples in your callback other than to copy them out!
- Parameters
-
dev | The device the samples are coming from. |
samples | Pointer to the sample buffer. |
len | The number of bytes in the sample buffer. |
◆ sip_set_frequency()
Set the sample frequency to be recorded by the microphone.
This function sets the sample frequency that the microphone will record. The default value for this is about 11.025kHz samples. You must call this prior to sip_start_sampling() if you wish to change it from the default.
- Parameters
-
dev | The microphone device to set sample type on. |
freq | The type of samples requested. |
- Return values
-
MAPLE_EOK | On success. |
MAPLE_EINVALID | If freq is invalid. |
MAPLE_EFAIL | If the microphone is sampling. |
- See also
- SIP_SAMPLE_11KHZ
-
SIP_SAMPLE_8KHZ
◆ sip_set_gain()
Set the microphone's gain value.
This function sets the gain value of the specified microphone device to the value given. This should only be called prior to sampling so as to keep the amplification constant throughout the sampling process, but can be changed on the fly if you really want to.
- Parameters
-
dev | The microphone device to set gain on. |
g | The value to set as the gain. |
- Return values
-
MAPLE_EOK | On success. |
MAPLE_EINVALID | If g is out of range. |
- See also
- SIP_MIN_GAIN
-
SIP_DEFAULT_GAIN
-
SIP_MAX_GAIN
◆ sip_set_sample_type()
Set the sample type to be recorded by the microphone.
This function sets the sample type that the microphone will return. The default value for this is 16-bit signed integer samples. You must call this prior to sip_start_sampling() if you wish to change it from the default.
- Parameters
-
dev | The microphone device to set sample type on. |
type | The type of samples requested. |
- Return values
-
MAPLE_EOK | On success. |
MAPLE_EINVALID | If type is invalid. |
MAPLE_EFAIL | If the microphone is sampling. |
- See also
- SIP_SAMPLE_16BIT_SIGNED
-
SIP_SAMPLE_8BIT_ULAW
◆ sip_start_sampling()
Start sampling on a microphone.
This function informs a microphone it should start recording samples.
- Parameters
-
dev | The device to start sampling on. |
cb | A callback to call when samples are ready. |
block | Set to 1 to wait for the SIP to start sampling. Otherwise check the is_sampling member of the status for dev to know when it has started. |
- Return values
-
MAPLE_EOK | On success. |
MAPLE_EAGAIN | If the command couldn't be sent, try again later. |
MAPLE_EFAIL | If the microphone is already sampling or the callback function is NULL. |
MAPLE_ETIMEOUT | If the command timed out while blocking. |
◆ sip_stop_sampling()
Stop sampling on a microphone.
This function informs a microphone it should stop recording samples.
- Parameters
-
dev | The device to stop sampling on. |
block | Set to 1 to wait for the SIP to stop sampling. Otherwise check the is_sampling member of the status for dev to know when it has finished. |
- Return values
-
MAPLE_EOK | On success. |
MAPLE_EAGAIN | If the command couldn't be sent, try again later. |
MAPLE_EFAIL | If the microphone is not sampling. |
MAPLE_ETIMEOUT | If the command timed out while blocking. |