How to get the peak volume of the sound being played

(This is a translation of a [Japanese [Content removed] by Ooshima.)

Thank you for your continued support.

I am trying to get the peak volume of the sound played using UGameplayStatics::SpawnSound2D (i.e. the peak volume of the data that is actually being played, not the volume specified as an argument when played). What methods do you think are available for this?

I searched for documents for this, but couldn’t find any good solution.

Previously, we used the CRI plugin. So I set a playback callback function using FCriWareApi::criAtomExPlayer_SetFilterCallback. Within that function, the PCM data was referenced to calculate the peak volume. However, as this project no longer uses the plugin, I have to develop an alternative method to achieve this.

Thank you.

Hello Masahiro,

I see few options you could try. The best fit depends on your use case.

  • Use an envelope follower on the source (Audio Components have a OnAudioSignleEnvelopeValue)
  • Use a MetaSound with a WavePlayer Node. From within the MetaSound you can analyze the wave’s audio samples to find the peak samples.
  • Use LoudnessNRT or Loudness in the AudioSynesthesia plugin. These perform perceptual loudness analysis. ULoudnessNRT is run in the editor for offline analysis. ULoudness is to analyze rendering audio through a UAudioBus.

(This is a translation of a Japanese post by Ooshima.)

Thank you for your continued support.

I can now get the peak volume of the sound being played by using an envelope follower (UAtomComponent::OnAudioSingleEnvelopeValueNative).

Thank you very much for your information.

Please close the thread.

Thanks.