libctru  v2.4.1
Enumerations | Functions
mic.h File Reference

MIC (Microphone) service. More...

Go to the source code of this file.

Enumerations

enum  MICU_Encoding {
  MICU_ENCODING_PCM8 = 0 ,
  MICU_ENCODING_PCM16 = 1 ,
  MICU_ENCODING_PCM8_SIGNED = 2 ,
  MICU_ENCODING_PCM16_SIGNED = 3
}
 Microphone audio encodings. More...
 
enum  MICU_SampleRate {
  MICU_SAMPLE_RATE_32730 = 0 ,
  MICU_SAMPLE_RATE_16360 = 1 ,
  MICU_SAMPLE_RATE_10910 = 2 ,
  MICU_SAMPLE_RATE_8180 = 3
}
 Microphone audio sampling rates. More...
 

Functions

Result micInit (u8 *buffer, u32 bufferSize)
 Initializes MIC. More...
 
void micExit (void)
 Exits MIC.
 
u32 micGetSampleDataSize (void)
 Gets the size of the sample data area within the shared memory buffer. More...
 
u32 micGetLastSampleOffset (void)
 Gets the offset within the shared memory buffer of the last sample written. More...
 
Result MICU_MapSharedMem (u32 size, Handle handle)
 Maps MIC shared memory. More...
 
Result MICU_UnmapSharedMem (void)
 Unmaps MIC shared memory.
 
Result MICU_StartSampling (MICU_Encoding encoding, MICU_SampleRate sampleRate, u32 offset, u32 size, bool loop)
 Begins sampling microphone input. More...
 
Result MICU_AdjustSampling (MICU_SampleRate sampleRate)
 Adjusts the configuration of the current sampling session. More...
 
Result MICU_StopSampling (void)
 Stops sampling microphone input.
 
Result MICU_IsSampling (bool *sampling)
 Gets whether microphone input is currently being sampled. More...
 
Result MICU_GetEventHandle (Handle *handle)
 Gets an event handle triggered when the shared memory buffer is full. More...
 
Result MICU_SetGain (u8 gain)
 Sets the microphone's gain. More...
 
Result MICU_GetGain (u8 *gain)
 Gets the microphone's gain. More...
 
Result MICU_SetPower (bool power)
 Sets whether the microphone is powered on. More...
 
Result MICU_GetPower (bool *power)
 Gets whether the microphone is powered on. More...
 
Result MICU_SetClamp (bool clamp)
 Sets whether to clamp microphone input. More...
 
Result MICU_GetClamp (bool *clamp)
 Gets whether to clamp microphone input. More...
 
Result MICU_SetAllowShellClosed (bool allowShellClosed)
 Sets whether to allow sampling when the shell is closed. More...
 

Detailed Description

MIC (Microphone) service.

Enumeration Type Documentation

◆ MICU_Encoding

Microphone audio encodings.

Enumerator
MICU_ENCODING_PCM8 

Unsigned 8-bit PCM.

MICU_ENCODING_PCM16 

Unsigned 16-bit PCM.

MICU_ENCODING_PCM8_SIGNED 

Signed 8-bit PCM.

MICU_ENCODING_PCM16_SIGNED 

Signed 16-bit PCM.

◆ MICU_SampleRate

Microphone audio sampling rates.

Enumerator
MICU_SAMPLE_RATE_32730 

32728.498 Hz

MICU_SAMPLE_RATE_16360 

16364.479 Hz

MICU_SAMPLE_RATE_10910 

10909.499 Hz

MICU_SAMPLE_RATE_8180 

8182.1245 Hz

Function Documentation

◆ micGetLastSampleOffset()

u32 micGetLastSampleOffset ( void  )

Gets the offset within the shared memory buffer of the last sample written.

Returns
The last sample's offset.
Examples
audio/mic/source/main.c.

◆ micGetSampleDataSize()

u32 micGetSampleDataSize ( void  )

Gets the size of the sample data area within the shared memory buffer.

Returns
The sample data's size.
Examples
audio/mic/source/main.c.

◆ micInit()

Result micInit ( u8 buffer,
u32  bufferSize 
)

Initializes MIC.

Parameters
sizeShared memory buffer to write audio data to. Must be aligned to 0x1000 bytes.
handleSize of the shared memory buffer.
Examples
audio/mic/source/main.c.

◆ MICU_AdjustSampling()

Result MICU_AdjustSampling ( MICU_SampleRate  sampleRate)

Adjusts the configuration of the current sampling session.

Parameters
sampleRateSample rate of outputted audio.

◆ MICU_GetClamp()

Result MICU_GetClamp ( bool *  clamp)

Gets whether to clamp microphone input.

Parameters
clampPointer to output the clamp state to.

◆ MICU_GetEventHandle()

Result MICU_GetEventHandle ( Handle handle)

Gets an event handle triggered when the shared memory buffer is full.

Parameters
handlePointer to output the event handle to.

◆ MICU_GetGain()

Result MICU_GetGain ( u8 gain)

Gets the microphone's gain.

Parameters
gainPointer to output the current gain to.

◆ MICU_GetPower()

Result MICU_GetPower ( bool *  power)

Gets whether the microphone is powered on.

Parameters
powerPointer to output the power state to.

◆ MICU_IsSampling()

Result MICU_IsSampling ( bool *  sampling)

Gets whether microphone input is currently being sampled.

Parameters
samplingPointer to output the sampling state to.

◆ MICU_MapSharedMem()

Result MICU_MapSharedMem ( u32  size,
Handle  handle 
)

Maps MIC shared memory.

Parameters
sizeSize of the shared memory.
handleHandle of the shared memory.

◆ MICU_SetAllowShellClosed()

Result MICU_SetAllowShellClosed ( bool  allowShellClosed)

Sets whether to allow sampling when the shell is closed.

Parameters
allowShellClosedWhether to allow sampling when the shell is closed.

◆ MICU_SetClamp()

Result MICU_SetClamp ( bool  clamp)

Sets whether to clamp microphone input.

Parameters
clampWhether to clamp microphone input.

◆ MICU_SetGain()

Result MICU_SetGain ( u8  gain)

Sets the microphone's gain.

Parameters
gainGain to set.

◆ MICU_SetPower()

Result MICU_SetPower ( bool  power)

Sets whether the microphone is powered on.

Parameters
powerWhether the microphone is powered on.

◆ MICU_StartSampling()

Result MICU_StartSampling ( MICU_Encoding  encoding,
MICU_SampleRate  sampleRate,
u32  offset,
u32  size,
bool  loop 
)

Begins sampling microphone input.

Parameters
encodingEncoding of outputted audio.
sampleRateSample rate of outputted audio.
sharedMemAudioOffsetOffset to write audio data to in the shared memory buffer.
sharedMemAudioSizeSize of audio data to write to the shared memory buffer. This should be at most "bufferSize - 4".
loopWhether to loop back to the beginning of the buffer when the end is reached.
Examples
audio/mic/source/main.c.