CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
To obtain input sound

Sample description

Overview

This is a script sample that acquires and visualizes the inputted waveform to the microphone.

cri4u_samples_criatom_script07_main.png

How to use

Click the [Start Mic] button to start waveform data acquisition. Click the [Stop Mic] button to stop waveform data acquisition.

Scene Information


Middleware CRI ADX (CRI Atom)
Sample Script Sample: To obtain input waveform
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/criatom/script/ScriptSample07_InputCapture/Scenes
Scene file ScriptSample07_InputCapture.unity
Original ADX data None


Program description

This is a script sample that acquires and displays the waveform data input to the microphone in real-time.
The PCM data value is reflected on the Y-axis position of the cube, creating the shape of the waveform graph.
If no microphone device is found, an error log will be output.
If multiple microphone devices are connected, the default settings will be used.

Waveform data acquisition script

Input voice waveform data can be obtained from the ADX microphone module.
Steps are as follows:

  1. Initialize the module with CriAtomExMic.InitializeModule().
    • You have to execute this function in order to use the module function.

  2. Create the microphone instance by setting the appropriate parameters in CriAtomExMic.Config.
    • Create an instance using CriAtomExMic.Create().

  3. After calling CriAtomExMic.Start(), acquire the waveform data.
    • Execute CriAtomExMic.ReadData(float[] bufferMono) to obtain PCM data.
    • Secure the length of the output float array passed as an argument by the same length as the number of CriAtomExMic.Config.frameSize set in (2).

Attention
When the input voice data is no longer needed, such as at the end of script execution, execute the CriAtomExMic.Stop() and CriAtomExMic.Dispose() functions in sequence to destroy the instance.
After that, use the CriAtomExMic.FinalizeModule() function to terminate the microphone module.