Skip to content

4. Capturable Sound Wave

Georgy Treshchev edited this page Jan 1, 2024 · 7 revisions

There is a capturable sound wave derived from the streaming sound wave. It supports capturing audio data from input devices like a microphone and playing it back, with the same capabilities as an imported sound wave (including rewinding, usage in SoundCues, etc). You can even capture and play audio simultaneously without any limitations.

It also automatically requests microphone permissions on iOS and Android once the capture is started.

Create Capturable Sound Wave node


To use this feature, you need to first get all available audio input devices that can be used for capturing by calling the corresponding function.

Get Available Audio Input Devices node


After that, you can start capturing audio data from the input device and stop it when needed.

Start and Stop capture nodes


Additionally, you can choose to mute or unmute sound capture to prevent the accumulation of audio data without interrupting the capturing process. This is useful when switching capturing frequently since starting recording through StartCapture may cause minor hitches on the engine's side. You should first start the capture itself, and only then mute/unmute it.

If your aim is to eliminate a slight freeze, you could consider starting the capture during a time when this freeze might be negligible. For example, you could start the capture during the loading screen of your game, mute the capturable sound wave right after that, and then unmute the capturable sound wave when needed for capturing audio data without any hitches.

Toggle Mute nodes


Finally, your implementation might look like this:

An example of using a capturable sound wave

Troubleshooting
Note: Currently, this isn't needed to be done manually since the plugin now automatically requests the needed permissions on both iOS and Android.
For audio capturing to work on Android, you must request the android.permission.RECORD_AUDIO permission. Starting with Android 5.0 (Lollipop), this permission can only be requested in real time. You can request it, for example, with the following function.

Requesting android.permission.RECORD_AUDIO android permission