I am trying to create some visualization using cooked fft, and I’m not entirely sure how to set it up. I got it to return an array of spectral data, and the inOutLastIndex variable progresses as expected, but all the elements contain a magnitude of 0. The sound is from a .flac file and everything else looks as it should, any help is appreciated.
variables in header file:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USoundWave* sound;
TArray<FSoundWaveSpectralData> fourierData;
uint32 lastIndex = INDEX_NONE;
Code in .cpp:
fourierData.Empty();
sound->GetInterpolatedCookedFFTDataForTime(GetGameTimeSinceCreation() + timeOffset, lastIndex, fourierData, true); //Get data
if(sound->HasCookedFFTData()) UE_LOG(LogTemp, Warning, TEXT("DataAmount: %d"), lastIndex) //debug progression
if (activeBuffer) {//write data
for (int i = 0; i < width; i++) {
dataBuffer1[4 * i] = fourierData[i].Magnitude * 255;
dataBuffer1[4 * i + 1] = fourierData[i].Magnitude * 255;
dataBuffer1[4 * i + 2] = fourierData[i].Magnitude * 255;
dataBuffer1[4 * i + 3] = 255;
}
memcpy(dataBuffer1 + (width * 4), dataBuffer2, width * (height - 1) * 4);
overWriteTexture(dataBuffer1);
This should write the data to a grayscale texture, (given that the magnitude is between 0 and 1, couldn’t find any info on that) but the texture is entirely black, (tested the writing to texture method with other data, it works well) and when I print the magnitude of any frequenzy in the debug log, it just says 0,0000. Thanks in advance for any reply.