1*05767d91SRobert Wu# Notes on Implementation 2*05767d91SRobert Wu 3*05767d91SRobert Wu## Latency from Resampling 4*05767d91SRobert Wu 5*05767d91SRobert WuThere are two components of the latency. The resampler itself, and a buffer that 6*05767d91SRobert Wuis used to adapt the block sizes. 7*05767d91SRobert Wu 8*05767d91SRobert Wu1) The resampler is an FIR running at the target sample rate. So its latency is the number of taps. 9*05767d91SRobert WuFrom MultiChannelResampler.cpp, numTaps is 10*05767d91SRobert Wu 11*05767d91SRobert Wu Fastest: 2 12*05767d91SRobert Wu Low: 4 13*05767d91SRobert Wu Medium: 8 14*05767d91SRobert Wu High: 16 15*05767d91SRobert Wu Best: 32 16*05767d91SRobert Wu 17*05767d91SRobert WuFor output, the device sampling rate is used, which is typically 48000.For input, the app sampling rate is used. 18*05767d91SRobert Wu 19*05767d91SRobert Wu2) There is a block size adapter that collects odd sized blocks into larger blocks of the correct size. 20*05767d91SRobert Wu 21*05767d91SRobert WuThe adapter contains one burst of frames, from getFramesPerBurst(). But if the app specifies a 22*05767d91SRobert Wuparticular size using setFramesPerCallback() then that size will be used. 23*05767d91SRobert WuHere is some pseudo-code to calculate the latency. 24*05767d91SRobert Wu 25*05767d91SRobert Wu latencyMillis = 0 26*05767d91SRobert Wu targetRate = isOutput ? deviceRate : applicationRate 27*05767d91SRobert Wu // Add latency from FIR 28*05767d91SRobert Wu latencyMillis += numTaps * 1000.0 / targetRate 29*05767d91SRobert Wu // Add latency from block size adaptation 30*05767d91SRobert Wu adapterSize = (callbackSize > 0) ? callbackSize : burstSize 31*05767d91SRobert Wu if (isOutput && isCallbackUsed) latencyMillis += adapterSize * 1000.0 / deviceRate 32*05767d91SRobert Wu else if (isInput && isCallbackUsed) latencyMillis += adapterSize * 1000.0 / applicationRate 33*05767d91SRobert Wu else if (isInput && !isCallbackUsed) latencyMillis += adapterSize * 1000.0 / deviceRate 34