KallistiOS
2.0.0
|
Definitions for using the Sound Input Peripheral. More...
Go to the source code of this file.
Data Structures | |
struct | sip_state |
SIP status structure. More... |
Macros | |
#define | SIP_SUBCOMMAND_GET_SAMPLES 0x01 |
Get recorded samples from the microphone device. | |
#define | SIP_SUBCOMMAND_BASIC_CTRL 0x02 |
Start and stop sampling. | |
#define | SIP_MIN_GAIN 0x00 |
Minimum microphone gain. | |
#define | SIP_DEFAULT_GAIN 0x0F |
Default microphone gain. | |
#define | SIP_MAX_GAIN 0x1F |
Maximum microphone gain. | |
#define | SIP_SAMPLE_16BIT_SIGNED 0x00 |
Record 16-bit signed integer samples. | |
#define | SIP_SAMPLE_8BIT_ULAW 0x01 |
Record 8-bit ulaw samples. | |
#define | SIP_SAMPLE_11KHZ 0x00 |
Record samples at 11.025kHz. | |
#define | SIP_SAMPLE_8KHZ 0x01 |
Record samples at 8kHz. |
Typedefs | |
typedef struct sip_state | sip_state_t |
SIP status structure. |
Functions | |
int | sip_set_gain (maple_device_t *dev, unsigned int g) |
Set the microphone's gain value. | |
int | sip_set_sample_type (maple_device_t *dev, unsigned int type) |
Set the sample type to be recorded by the microphone. | |
int | sip_set_frequency (maple_device_t *dev, unsigned int freq) |
Set the sample frequency to be recorded by the microphone. | |
int | sip_start_sampling (maple_device_t *dev, int block) |
Start sampling on a microphone. | |
int | sip_stop_sampling (maple_device_t *dev, int block) |
Stop sampling on a microphone. | |
uint8 * | sip_get_samples (maple_device_t *dev, size_t *sz) |
Retrieve the sample buffer from the microphone. | |
int | sip_clear_samples (maple_device_t *dev) |
Clear the sample buffer of a microphone. |
Definitions for using the Sound Input Peripheral.
This file contains the definitions needed to access the Maple microphone type device (the Seaman mic). Many thanks go out to ZeZu who pointed me toward what some of the commands actually do in the original version of this driver.
As a note, the device itself is actually referred to by the system as the Sound Input Peripheral, so hence why this driver is named as it is.
#define SIP_DEFAULT_GAIN 0x0F |
Default microphone gain.
#define SIP_MAX_GAIN 0x1F |
Maximum microphone gain.
#define SIP_MIN_GAIN 0x00 |
Minimum microphone gain.
#define SIP_SAMPLE_11KHZ 0x00 |
Record samples at 11.025kHz.
#define SIP_SAMPLE_16BIT_SIGNED 0x00 |
Record 16-bit signed integer samples.
#define SIP_SAMPLE_8BIT_ULAW 0x01 |
Record 8-bit ulaw samples.
#define SIP_SAMPLE_8KHZ 0x01 |
Record samples at 8kHz.
#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.
#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.
typedef struct sip_state sip_state_t |
SIP status structure.
This structure contains information about the status of the microphone device and can be fetched with maple_dev_status(). You should not modify any of the values in here, it is all "read-only" to your programs. Modifying any of this, especially while the microphone is sampling could really screw things up.
int sip_clear_samples | ( | maple_device_t * | dev | ) |
Clear the sample buffer of a microphone.
This function clears out any old samples on the microphone buffer so that recording will start from the beginning of the buffer again. This does not resize the buffer in any way. This function will not work if called while the microphone is sampling.
dev | The device to clear the buffer on. |
MAPLE_EOK | On success. |
MAPLE_EFAIL | If the device is currently sampling. |
uint8* sip_get_samples | ( | maple_device_t * | dev, |
size_t * | sz | ||
) |
Retrieve the sample buffer from the microphone.
This function retrieves the sample buffer from the microphone and allocates a new buffer for the microphone to record into. This function cannot be called while the microphone is sampling. The caller is responsible for the buffer returned, and must free the buffer when it is done with it.
dev | The device to fetch samples for. |
sz | On return, the size of the sample buffer in bytes. This must not be NULL. |
int sip_set_frequency | ( | maple_device_t * | dev, |
unsigned int | freq | ||
) |
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.
dev | The microphone device to set sample type on. |
freq | The type of samples requested. |
MAPLE_EOK | On success. |
MAPLE_EINVALID | If freq is invalid. |
MAPLE_EFAIL | If the microphone is sampling. |
int sip_set_gain | ( | maple_device_t * | dev, |
unsigned int | g | ||
) |
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.
dev | The microphone device to set gain on. |
g | The value to set as the gain. |
MAPLE_EOK | On success. |
MAPLE_EINVALID | If g is out of range. |
int sip_set_sample_type | ( | maple_device_t * | dev, |
unsigned int | 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.
dev | The microphone device to set sample type on. |
type | The type of samples requested. |
MAPLE_EOK | On success. |
MAPLE_EINVALID | If type is invalid. |
MAPLE_EFAIL | If the microphone is sampling. |
int sip_start_sampling | ( | maple_device_t * | dev, |
int | block | ||
) |
Start sampling on a microphone.
This function informs a microphone it should start recording samples.
dev | The device to start sampling on. |
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. |
MAPLE_EOK | On success. |
MAPLE_EAGAIN | If the command couldn't be sent, try again later. |
MAPLE_EFAIL | If the microphone is already sampling. |
MAPLE_ETIMEOUT | If the command timed out while blocking. |
int sip_stop_sampling | ( | maple_device_t * | dev, |
int | block | ||
) |
Stop sampling on a microphone.
This function informs a microphone it should stop recording samples.
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. |
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. |