The GetSamplesAsync
method of the SoundFile
class asynchronously retrieves decompressed audio samples from the sound file. This method is useful when you need to process or analyze audio data without blocking the main thread.
The GetSamplesAsync
method of the SoundFile
class asynchronously retrieves decompressed audio samples from the sound file. This method is useful when you need to process or analyze audio data without blocking the main thread.
To use the GetSamplesAsync
method, you must have an instance of the SoundFile
class. Call this method to obtain the audio samples as an array of Int16
values, which represent the decompressed audio data.
Ensure that the sound file is loaded before calling this method. You can check the IsLoaded
property to verify if the sound file is ready for sample extraction.
// Example of using GetSamplesAsync async Task ProcessAudioSamplesAsync(SoundFile soundFile) { if (soundFile.IsLoaded) { Int16[] samples = await soundFile.GetSamplesAsync(); // Process the samples as needed } else { // Handle the case where the sound file is not loaded } }