PCM Data Handling
Obtaining PCM Data as the sound wave plays
You can use the OnGeneratePCMData delegate to obtain PCM data as the sound wave plays. This is useful when processing or analyzing the PCM audio data.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object (or its derived type, such as UStreamingSoundWave, UCapturableSoundWave, etc.)
ImportedSoundWave->OnGeneratePCMDataNative.AddWeakLambda(this, [this](const TArray<float>& PCMData)
{
// Handle the result
});
Obtaining newly populated PCM data
The OnPopulateAudioData delegate can be used to obtain newly populated PCM data, which is particularly useful for streaming sound waves and can simplify the audio analysis process.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object (or its derived type, such as UStreamingSoundWave, UCapturableSoundWave, etc.)
ImportedSoundWave->OnPopulateAudioDataNative.AddWeakLambda(this, [this](const TArray<float>& PopulatedAudioData)
{
// Handle the result
});
Converting PCM data to bytes
PCM data obtained from these delegates is in 32-bit float PCM format. If you need to convert PCM data to bytes, see Transcode Audio.