Hi All -
I would like to use the PCM data that is saved in a .wav file directly as the starting point for a procedurally generated sound. I already have a “procedural sound node” working which can fill the PCM buffer with data created in code at runtime. I would now like to use data from an existing .wav asset (and modify it with some code).
I tried using the USoundWave 's RawData.GetCopy() and can see the bytes in this buffer, but the data here seems to be compressed or not what I’m expecting. I created a simple sound file with only three samples at -1.0 0.0 and 1.0, but do not see these in the buffer.
How can I access the PCM Data from a USoundWave?
Slightly difficult to answer this one as there isn’t a single place the PCM data will be, or really an approved method of doing this. The RawData of a SoundWave should always be PCM data but it will only be loaded in editor builds generally and you’ll need to lock it before you can read from it. If you look at the Sound Visualisations plugin code you might see some examples similar to this.
If you are in a cooked game however, CompressedFormatData will be loaded instead. Then depending on whether the sound decompresses natively or at runtime, the PCM data may either be in the SoundWave’s RawPCMData pointer or decoded in chunks at regular intervals, which are part of a sound buffer that works differently on each platform/file type.