Sound wave properties
You can retrieve the entire PCM buffer from a sound wave directly.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
TArray<float> PCMBuffer = ImportedSoundWave->GetPCMBufferCopy();
To create a seamless audio loop, you can set looping to automatically rewind the sound wave playback time to zero and play after playback ends.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetLooping(false);
You can adjust the volume of the sound being played to suit your needs.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetVolume(1.0f);
You can also modify the pitch of the sound being played to your preference.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetPitch(1.0f);
You can set subtitles, namely, define the text and the time at which they should be displayed.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
TArray<FEditableSubtitleCue> Subtitles;
FEditableSubtitleCue Subtitle;
Subtitle.Text = FText::FromString("Example");
Subtitle.Time = 2.0f;
Subtitles.Add(Subtitle);
ImportedSoundWave->SetSubtitles(Subtitles);
You can set the virtualization mode, such as Play When Silent, which allows the sound wave to continue playback even during silence. This is particularly helpful if you're using sound attenuation.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetVirtualizationMode(EVirtualizationMode::PlayWhenSilent);
If you need to change the sample rate or number of channels in the imported sound wave, you can use the appropriate functions to resample and mix the audio data. This will modify the entire sound wave data and affect the output from the OnGeneratePCMData
and OnPopulateAudioData
delegates accordingly.
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->ResampleSoundWave(44100);
ImportedSoundWave->MixSoundWaveChannels(2);
Or, if you want to automatically resample and mix all the upcoming audio data to be populated to the specified desired sample rate and number of channels, you can use the following functions (this will also affect the output from the OnGeneratePCMData
and OnPopulateAudioData
delegates accordingly).
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetInitialDesiredSampleRate(44100);
ImportedSoundWave->SetInitialDesiredNumOfChannels(2);