MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / ReadImpulseResponseToFloat

Function ReadImpulseResponseToFloat

libjamesdsp/JdspImpResToolbox.c:349–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349float* ReadImpulseResponseToFloat
350(const char* mIRFileName, int targetSampleRate, int* jImpInfo, int convMode, int* javaAdvSetPtr)
351{
352 if (strlen(mIRFileName) <= 0) return 0;
353 unsigned int channels;
354 drwav_uint64 frameCount;
355 float *pFrameBuffer = loadAudioFile(mIRFileName, targetSampleRate, &channels, &frameCount, 1);
356 if (channels == 0 || channels == 3 || channels > 4)
357 {
358 free(pFrameBuffer);
359 return 0;
360 }
361
362 int i;
363 float *splittedBuffer[4];
364 int alloc = frameCount;
365 if (alloc < 8)
366 alloc = 8;
367 for (i = 0; i < channels; i++)
368 {
369 if (convMode == 2)
370 {
371 splittedBuffer[i] = (float*)malloc(alloc * 2 * sizeof(float));
372 memset(splittedBuffer[i], 0, alloc * 2 * sizeof(float));
373 }
374 else
375 splittedBuffer[i] = (float*)malloc(frameCount * sizeof(float));
376 }
377 channel_splitFloat(pFrameBuffer, frameCount, splittedBuffer, channels);
378 if (convMode > 0)
379 {
380 free(pFrameBuffer);
381 int range[2];
382 float startCutdB = javaAdvSetPtr[0];
383 float endCutdB = javaAdvSetPtr[1];
384 if (convMode == 1)
385 checkStartEnd(splittedBuffer, channels, frameCount, startCutdB, endCutdB, range);
386 else
387 {
388 range[0] = 0;
389 range[1] = alloc * 2;
390 }
391 float *outPtr[4];
392 int xLen = range[1] - range[0];
393 if (convMode == 1)
394 {
395 checkStartEnd(splittedBuffer, channels, frameCount, startCutdB, endCutdB, range);
396 for (i = 0; i < channels; i++)
397 {
398 outPtr[i] = &splittedBuffer[i][range[0]];
399 circshift(outPtr[i], xLen, javaAdvSetPtr[i + 2]);
400 for (int j = 0; j < javaAdvSetPtr[i + 2] - 1; j++)
401 outPtr[i][j] = 0.0f;
402 }
403 }
404 else
405 {
406 fftData fd;

Callers 1

updateConvolverMethod · 0.85

Calls 10

loadAudioFileFunction · 0.70
checkStartEndFunction · 0.70
circshiftFunction · 0.70
initMpsFFTDataFunction · 0.70
mpsFunction · 0.70
freeMpsFFTDataFunction · 0.70
channel_splitFloatFunction · 0.50
pthread_createFunction · 0.50
pthread_joinFunction · 0.50
channel_joinFloatFunction · 0.50

Tested by

no test coverage detected