# UE4 - Microphone Spectrum always return 0 Length

**URL:** <https://qa.fmod.com/t/ue4-microphone-spectrum-always-return-0-length/14320>\
**Category:** Unreal Engine\
**Created:** [January 21, 2019, 4:16am UTC](https://qa.fmod.com/t/ue4-microphone-spectrum-always-return-0-length/14320 "2019-01-21T04:16:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VectorX](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/vectorx/32/45_2.png) [@VectorX](https://qa.fmod.com/u/VectorX)\
**Post date:** [January 21, 2019, 4:16am UTC](https://qa.fmod.com/t/ue4-microphone-spectrum-always-return-0-length/14320/1 "2019-01-21T04:16:48Z")

</div>

I’m working on the same thing but for unreal engine, I did everything possible as I’ve researched, but the results always zero

> void UMyActorComponent::getSpectrum\_Linear()  
> {  
> studioSystem-\>update();  
> if (fft != NULL)  
> {  
> GEngine-\>AddOnScreenDebugMessage(-1, 0.05f, FColor::Red, “FFT”);   
> GEngine-\>AddOnScreenDebugMessage(-1, 0.05f, FColor::Red, FString::FromInt(fft-\>length));  
> GEngine-\>AddOnScreenDebugMessage(-1, 0.05f, FColor::Red, FString::FromInt(fft-\>numchannels));   
> for (int channels = 0; channels \< fft-\>numchannels; ++channels)  
> {  
> for (int bin = 0; bin \< fft-\>length; ++bin)  
> {  
> float freVal = fft-\>spectrum[channels][bin];  
> GEngine-\>AddOnScreenDebugMessage(-1, 0.1f, FColor::Green, FString::SanitizeFloat(freVal));  
> }  
> }   
> }  
> }

> void UMyActorComponent::StartRecording()  
> {  
> result = lowlevel-\>createSound(0, FMOD\_LOOP\_NORMAL | FMOD\_OPENUSER, &exinfo, &sound);  
> result = lowlevel-\>recordStart(DEVICE\_INDEX, sound, true);  
> result = lowlevel-\>playSound(sound, 0, false, &channel);   
> lowlevel-\>createDSPByType(FMOD\_DSP\_TYPE::FMOD\_DSP\_TYPE\_FFT, &dsp);  
> dsp-\>getParameterData(FMOD\_DSP\_FFT\_SPECTRUMDATA, (void \*\*)&fft, 0, 0, 0);  
> channel-\>addDSP(FMOD\_DSP\_PARAMETER\_DATA\_TYPE\_FFT, dsp);  
> dsp-\>setBypass(false);  
> dsp-\>setActive(true);   
> GEngine-\>AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT(“Start Recording!”));  
> }

I’ve been told to use lock and unlock sound, but i couldn’t understand or find any example how to use those functions to get what I want.

I really need help in this. any advice?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [January 28, 2019, 10:18pm UTC](https://qa.fmod.com/t/ue4-microphone-spectrum-always-return-0-length/14320/2 "2019-01-28T22:18:19Z")

</div>

You will need to call dsp-\>getParameterData every time you want new data, as it will only get a snapshot of the data at that exact frame.
