| 347 | } |
| 348 | |
| 349 | float* 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; |
no test coverage detected