Skip to content

Commit

Permalink
API: Add ROC_RESAMPLER_BACKEND_SPEEXDEC
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv authored and baranovmv committed Oct 9, 2023
1 parent 241bf30 commit 5f7d579
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/public_api/include/roc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,30 +500,57 @@ typedef enum roc_resampler_backend {

/** CPU-intensive good-quality high-precision built-in resampler.
*
* This backend controls clock speed with high precision, and hence is useful when
* latency or synchronization error should be very low.
* This backend controls clock speed with very high precision, and hence is useful
* when latency or synchronization error should be very low.
*
* This backend has higher CPU usage, especially on high resampling quality and on
* CPUs with small L3 caches.
*
* This backend has high CPU usage, especially on high resampling quality and on
* CPUs with small caches.
* The implementation is based on bandlimited interpolation algorithm.
*
* This backend is always available.
*
* Recommended for \ref ROC_CLOCK_SYNC_PROFILE_RESPONSIVE and on good CPUs.
*/
ROC_RESAMPLER_BACKEND_BUILTIN = 1,

/** Very fast good-quality low-precision resampler based on SpeexDSP.
/** Fast good-quality low-precision resampler based on SpeexDSP.
*
* This backend has low CPU usage even on high resampler quality and cheap CPUs.
*
* This backend controls clock speed with lower precision, and is not so good when
* latency or synchronization error should be very low.
*
* This backend is available if SpeexDSP was enabled at build time.
* This backend is available only when SpeexDSP was enabled at build time.
*
* Recommended for \ref ROC_CLOCK_SYNC_PROFILE_GRADUAL and on cheap CPUs.
*/
ROC_RESAMPLER_BACKEND_SPEEX = 2
ROC_RESAMPLER_BACKEND_SPEEX = 2,

/** Fast medium-quality and medium-precision resampler combining SpeexDSP with
* decimation.
*
* This backend uses SpeexDSP for converting between base rates (e.g. 44100 vs 48000)
* and decimation/expansion (dropping or duplicating samples) for clock drift
* compensation.
*
* Typical decimation rate needed to compensate clock drift is below 0.5ms/second
* (20 samples/second on 48Khz), which gives tolerable quality despite usage of
* decimation, especially for speech.
*
* When frame and packet sample rates are equal (e.g. both are 44100), only decimation
* stage is needed, and this becomes fastest possible backend working almost as fast
* as memcpy().
*
* When frame and packet rates are different, usage of this backend compared to
* \c ROC_RESAMPLER_BACKEND_SPEEX allows to sacrify some quality, but somewhat
* improve scaling precision in return.
*
* This backend is available only when SpeexDSP was enabled at build time.
*
* Recommended when CPU resources are extremely limited.
*/
ROC_RESAMPLER_BACKEND_SPEEXDEC = 3
} roc_resampler_backend;

/** Resampler profile.
Expand Down
4 changes: 4 additions & 0 deletions src/public_api/src/adapters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ bool resampler_backend_from_user(audio::ResamplerBackend& out, roc_resampler_bac
case ROC_RESAMPLER_BACKEND_SPEEX:
out = audio::ResamplerBackend_Speex;
return true;

case ROC_RESAMPLER_BACKEND_SPEEXDEC:
out = audio::ResamplerBackend_SpeexDec;
return true;
}

return false;
Expand Down

0 comments on commit 5f7d579

Please sign in to comment.