2017-03-19 1 views
1

저는 Superpowered SDK를 이해하려고하지만 Android 및 C++ 및 오디오 신호를 처음 사용하는 것은 이해하려고합니다. 여기에 주파수 도메인 예가 나와 있습니다. https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/tree/master/Examples_Android/FrequencyDomainAndroid SuperPowered SDK 오디오 - 주파수 도메인 예제 - memset 주파수 조작

내 Nexus 5X에서 실행 중입니다. FrequencyDomain.cpp 파일에서 :

static SuperpoweredFrequencyDomain *frequencyDomain; 
static float *magnitudeLeft, *magnitudeRight, *phaseLeft, *phaseRight, *fifoOutput, *inputBufferFloat; 
static int fifoOutputFirstSample, fifoOutputLastSample, stepSize, fifoCapacity; 

#define FFT_LOG_SIZE 11 // 2^11 = 2048 

static bool audioProcessing(void * __unused clientdata, short int *audioInputOutput, int numberOfSamples, int __unused samplerate) { 
SuperpoweredShortIntToFloat(audioInputOutput, inputBufferFloat, (unsigned int)numberOfSamples); // Converting the 16-bit integer samples to 32-bit floating point. 
frequencyDomain->addInput(inputBufferFloat, numberOfSamples); // Input goes to the frequency domain. 

// In the frequency domain we are working with 1024 magnitudes and phases for every channel (left, right), if the fft size is 2048. 
while (frequencyDomain->timeDomainToFrequencyDomain(magnitudeLeft, magnitudeRight, phaseLeft, phaseRight)) { 
    // You can work with frequency domain data from this point. 


// This is just a quick example: we remove the magnitude of the first 20 bins, meaning total bass cut between 0-430 Hz. 
    memset(magnitudeLeft, 0, 80); 
    memset(magnitudeRight, 0, 80); 

나는 처음 20 개 쓰레기통 0-430 Hz에서 여기에서 얼마나 이해 : How do I obtain the frequencies of each value in an FFT?

하지만 난 memset 함수 80의 가치를 이해하지 ... 4 * 20 일 때, float * 20 bins의 경우 4 바이트입니까? magnitudeLeft는 모든 주파수에 대한 데이터를 보유합니까? 그런 다음 어떻게하면 중간에서 최고 10 개 주파수를 제거 할 수 있습니까? 고맙습니다!

답변

3

magnitudeLeft 및 magnitudeRight의 모든 값은 32 비트, 4 바이트 인 float입니다.

memset은 바이트 수 매개 변수를 취하므로 20 개 * 4 바이트 = 80 바이트가됩니다. memset이 처음 20 개의 bin을 지 웁니다.

magnitudeLeft와 magnitudeRight는 모두 1024 개의 부동 소수점을 포함한 전체 주파수 범위를 나타냅니다. 크기는 항상 FFT 크기를 2로 나눈 값이므로 예제에서는 2048/2입니다. 중간 및 상부로부터 제거

같은 것을 보인다 :

memset 함수를 (& magnitudeLeft [index_of_first_bin_to_remove, 0, * number_of_bins를 sizeof (플로트));

컴파일러에서 magnitudeLeft가 float임을 알고 있기 때문에 첫 번째 매개 변수에 sizeof (float)가 곱 해지지 않으므로 올바른 주소가 자동 입력됩니다.