CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
CriAtomExMic Class Reference

Microphone for capturing sound More...

Inherits CriDisposable.

Classes

struct  Config
 A config structure for creating an AtomEx microphone More...
 
struct  DeviceInfo
 Microphone device information structure More...
 
class  Effect
 Microphone effect More...
 

Public Member Functions

override void Dispose ()
 Discards the microphone More...
 
void Start ()
 Starts microphone sound capturing More...
 
void Stop ()
 Stops the microphone sound capturing More...
 
int GetNumChannels ()
 Gets the number of microphone channels More...
 
int GetSamplingRate ()
 Gets the microphone sampling frequency More...
 
uint GetNumBufferedSamples ()
 Gets the number of samples of buffered data More...
 
uint GetNumBufferredSamples ()
 
bool IsAvailable ()
 Gets the microphone availability More...
 
uint ReadData (float[] bufferMono)
 Reads the microphone input data (monaural) More...
 
uint ReadData (float[] bufferMono, uint numToRead)
 Reads the microphone input data (monaural) More...
 
uint ReadData (float[] bufferL, float[] bufferR)
 Reads the microphone input data (stereo) More...
 
uint ReadData (float[] bufferL, float[] bufferR, uint numToRead)
 Reads the microphone input data (stereo) More...
 
uint ReadData (float[][] buffers)
 Reads the microphone input data (multi-channel) More...
 
uint ReadData (float[][] buffers, uint numToRead)
 Reads the microphone input data (multi-channel) More...
 
void SetOutputWriteStream (CriAudioWriteStream stream)
 Sets the light stream More...
 
CriAudioReadStream GetOutputReadStream ()
 Gets the read stream More...
 
Effect AttachEffect (IntPtr afxInterface, float[] configParameters)
 Adds an effect More...
 
void DetachEffect (Effect effect)
 Removes an effect More...
 
void SetEffectParameter (Effect effect, int parameterIndex, float parameterValue)
 Sets effect parameters More...
 
float GetEffectParameter (Effect effect, int parameterIndex)
 Gets effect parameters More...
 
void SetEffectBypass (Effect effect, bool bypass)
 Effect Bypass setting More...
 
void UpdateEffectParameters (Effect effect)
 Sets effect parameters More...
 

Static Public Member Functions

static void InitializeModule ()
 Initializes the CriAtomMic module More...
 
static void FinalizeModule ()
 Terminates the CriAtomMic module More...
 
static void SetupOutputCategoryForMic_IOS (bool enable)
 [iOS] Sets the output category of the microphone input More...
 
static DeviceInfo[] GetDevices ()
 Gets the microphone device More...
 
static int GetNumDevices ()
 Gets the number of microphone devices More...
 
static DeviceInfo GetDefaultDevice ()
 Gets the default microphone device More...
 
static bool IsFormatSupported (Config config)
 Gets the format support status More...
 
static CriAtomExMic Create (Config?config=null)
 Creates an AtomEx microphone More...
 

Detailed Description

Microphone for capturing sound

Description:
A class for capturing input from a physical microphone or sound device.
Performs control such as starting input, getting status and getting data.
You can also get the information about the sound input device using CriWare.CriAtomExMic::GetDevices .

Member Function Documentation

static void InitializeModule ( )
inlinestatic

Initializes the CriAtomMic module

Description:
Initializes the CriAtomMic module.
In order to use the function of the module, you must call this function.
(You can use the features of the module after calling this function and before calling the CriWare.CriAtomExMic::FinalizeModule function.)
Note:
After calling this function, be sure to call the corresponding CriWare.CriAtomExMic::FinalizeModule function.
In addition, this function cannot be called again until the CriWare.CriAtomExMic::FinalizeModule function is called.
See also
CriAtomExMic::FinalizeModule
static void FinalizeModule ( )
inlinestatic

Terminates the CriAtomMic module

Description:
Terminates the CriAtomMic module.
See also
CriAtomExMic::InitializeModule
static void SetupOutputCategoryForMic_IOS ( bool  enable)
inlinestatic

[iOS] Sets the output category of the microphone input

Parameters
enableEnable or disable the setting (True: enable, False: disable)
Description:
Set the category (AVAudioSessionCategory) to use the microphone on iOS.

The processing performed by calling this function will also be performed within CriWare.CriAtomExMic::InitializeModule and CriWare.CriAtomExMic::FinalizeModule .
Therefore, it is usually not neccessary to call this function directly.
This function should only be used when the AVAudioSessionCategory setting needs to be changed, in order to use an external microphone input module other than the regular CriAtomExMic module.
See also
CriAtomExMic::InitializeModule, CriAtomExMic::FinalizeModule
static DeviceInfo [] GetDevices ( )
inlinestatic

Gets the microphone device

Returns
Microphone device array
Description:
Gets information on the microphone device.
See also
CriAtomExMic::GetDefaultDevice
static int GetNumDevices ( )
inlinestatic

Gets the number of microphone devices

Returns
The number of microphone devices
Description:
Gets the number of microphone devices connected to the terminal.
See also
CriAtomExMic::GetDevices
static DeviceInfo GetDefaultDevice ( )
inlinestatic

Gets the default microphone device

Returns
Microphone device structure
Description:
Gets the information about the default microphone device.
See also
CriAtomExMic::GetDevices
static bool IsFormatSupported ( Config  config)
inlinestatic

Gets the format support status

Parameters
configConfig information
Returns
True: supported, False: not supported
Description:
Gets whether the specified format in the config information is supported.
See also
CriAtomExMic::GetDevices
static CriAtomExMic Create ( Config config = null)
inlinestatic

Creates an AtomEx microphone

Parameters
configConfig information
Returns
AtomEx microphone
Description:
Creates a microphone instance for capturing sound.

Calling the CriWare.CriAtomExMic::Create function creates an AtomEx microphone and an instance ( CriAtomExMic ) for controlling the microphone is returned.

This function returns null if it failed to open the sound input device.
To actually start sound input, call the CriWare.CriAtomExMic::Start function.
Use the CriWare.CriAtomExMic::ReadData function for getting the captured sound data.
See also
CriAtomExMic::Destroy
override void Dispose ( )
inline

Discards the microphone

Description:
Discard the microphone for capturing sound.
Note:
This function is a return-on-complete function. The time it takes depends on the platform.
If this function is called at a timing when the screen needs to be updated such as in a game loop, the process is blocked in the unit of milliseconds, resulting in dropped frames.
Create/discard microphone at a timing when load fluctuations is accepted such as when switching scenes.
See also
CriAtomExMic::Create
void Start ( )
inline

Starts microphone sound capturing

Description:
Starts capturing sounds by the microphone.
See also
CriAtomExMic::Create, CriAtomExMic::Stop
void Stop ( )
inline

Stops the microphone sound capturing

Description:
Stops capturing sound by the microphone.
See also
CriAtomExMic::Create, CriAtomExMic::Start
int GetNumChannels ( )
inline

Gets the number of microphone channels

Returns
The number of channels
Description:
Gets the number of microphone channels.
int GetSamplingRate ( )
inline

Gets the microphone sampling frequency

Returns
Sampling frequency
Description:
Gets the sampling frequency of the microphone.
uint GetNumBufferedSamples ( )
inline

Gets the number of samples of buffered data

Returns
The number of samples buffered
Description:
Gets the number of microphone input data samples existing in the internal buffer.
uint GetNumBufferredSamples ( )
inline
Deprecated:
This is a deprecated API that will be removed. Please consider using CriWare.CriAtomExMic.GetNumBufferedSamples instead.
bool IsAvailable ( )
inline

Gets the microphone availability

Returns
Whether it is available (True: available, False: not available)
Description:
Checks the status of the audio input device to see if it is available.
uint ReadData ( float[]  bufferMono)
inline

Reads the microphone input data (monaural)

Parameters
bufferMonoData buffer
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
This function is valid only when you call CriWare.CriAtomExMic::Start by setting the number of channels to 1.
Otherwise, the assertion fails.
uint ReadData ( float[]  bufferMono,
uint  numToRead 
)
inline

Reads the microphone input data (monaural)

Parameters
bufferMonoData buffer
numToReadThe number of samples to read
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
This function is valid only when you call CriWare.CriAtomExMic::Start by setting the number of channels to 1.
Otherwise, the assertion fails.
uint ReadData ( float[]  bufferL,
float[]  bufferR 
)
inline

Reads the microphone input data (stereo)

Parameters
bufferLData buffer (L channel)
bufferRData buffer (R channel)
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
This function is valid only when you call CriWare.CriAtomExMic::Start by setting the number of channels to 2.
Otherwise, the assertion fails.
In addition, make sure that each data buffer has the same array length.
uint ReadData ( float[]  bufferL,
float[]  bufferR,
uint  numToRead 
)
inline

Reads the microphone input data (stereo)

Parameters
bufferLData buffer (L channel)
bufferRData buffer (R channel)
numToReadThe number of samples to read
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
This function is valid only when you call CriWare.CriAtomExMic::Start by setting the number of channels to 2.
Otherwise, the assertion fails.
In addition, make sure that array size of all data buffers is equal to or larger than numToRead.
uint ReadData ( float  buffers[][])
inline

Reads the microphone input data (multi-channel)

Parameters
buffersData buffer array
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
The length of the data buffer array passed to this function must be equal to or larger than the number of CriAtomExMic::Config channels passed to CriAtomExMic::Start .
Otherwise, the assertion fails.
In addition, make sure that array size of all data buffers is equal to or larger than numToRead.
uint ReadData ( float  buffers[][],
uint  numToRead 
)
inline

Reads the microphone input data (multi-channel)

Parameters
buffersData buffer array
numToReadThe number of samples to read
Returns
The number of samples that could be acquired
Description:
Gets the data input to the microphone.
If this function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Note:
The length of the data buffer array passed to this function must be equal to the number of CriAtomExMic::Config channels passed to CriWare.CriAtomExMic::Start .
Otherwise, the assertion fails.
In addition, make sure that array size of each data buffer is equal to or larger than numToRead.
void SetOutputWriteStream ( CriAudioWriteStream  stream)
inline

Sets the light stream

Parameters
streamLight stream
Description:
Sets the output light stream to the microphone.
The light stream callback function is called when microphone captures input.
The callback function is called from a separate thread on most platforms, so the callee must be implemented as thread-safe.
CriAudioReadStream GetOutputReadStream ( )
inline

Gets the read stream

Returns
Read stream callback function
Description:
Gets the read stream of the microphone in the output direction.
When calling the read stream callback function, it is necessary to specify the AtomEx microphone handle as the first argument.
If the read stream callback function is not called regularly and the internal buffer becomes full, the data that cannot be fed to the buffer is discarded.
Effect AttachEffect ( IntPtr  afxInterface,
float[]  configParameters 
)
inline

Adds an effect

Parameters
afxInterfaceCriAfx interface
configParametersConfig parameter array for creating CriAfx
Returns
Microphone effect
Description:
Adds an effect to the microphone.
The effect you add must be created using the CriAfx interface.

If this function is called while the microphone is operating, the effect is suddenly activated, which may cause noise in the sound.
void DetachEffect ( Effect  effect)
inline

Removes an effect

Parameters
effectMicrophone effect
Description:
Removes a microphone effect.

If this function is called while the microphone is operating, the effect is suddenly deactivated, which may cause noise in the sound.
See also
CriAtomExMic::AttachEffect
void SetEffectParameter ( Effect  effect,
int  parameterIndex,
float  parameterValue 
)
inline

Sets effect parameters

Parameters
effectMicrophone effect
parameterIndexParameter index
parameterValueParameter value
Description:
Sets parameters to the microphone effect.
This sets the corresponding parameter value by specifying its index.

Parameters are not reflected to the effect just by calling this function, so it is necessary to finally call criAtomMic_UpdateEffectParameters to reflect the parameters.
See also
CriAtomExMic::UpdateEffectParameters
float GetEffectParameter ( Effect  effect,
int  parameterIndex 
)
inline

Gets effect parameters

Parameters
effectMicrophone effect
parameterIndexParameter index
Returns
Parameter value
Description:
Gets microphone effect parameters.
By specifying a parameter index, the value of the corresponding parameter is returned.
void SetEffectBypass ( Effect  effect,
bool  bypass 
)
inline

Effect Bypass setting

Parameters
effectMicrophone effect
bypassBypass setting
Description:
Specifies that the microphone effects be bypassed.
If you specify True for Bypass, the effects are deactivated.
void UpdateEffectParameters ( Effect  effect)
inline

Sets effect parameters

Parameters
effectMicrophone effect
Description:
Sets parameters to the microphone effect.
This sets the corresponding parameter value by specifying its index.

Parameters are not reflected to the effect just by calling this function, so it is necessary to finally call criAtomMic_UpdateEffectParameters to reflect the parameters.
See also
CriAtomExMic::UpdateEffectParameters

The documentation for this class was generated from the following file: