diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2022-11-12 19:25:08 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2022-11-12 19:25:08 -0800 |
commit | 50ba074fe1b0d0ddc4604a0a6bb723382d9e60ad (patch) | |
tree | a2e66361639bf69b6ec32c23195ef8e1ba60a7c1 /core/converter.h | |
parent | 68e04624b1f94d9bf8f9ebce5d90e64ab143efea (diff) |
Add a method for the input sample delay for the SampleConverter
Diffstat (limited to 'core/converter.h')
-rw-r--r-- | core/converter.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/converter.h b/core/converter.h index 2d22ae38..46d9b83e 100644 --- a/core/converter.h +++ b/core/converter.h @@ -1,6 +1,7 @@ #ifndef CORE_CONVERTER_H #define CORE_CONVERTER_H +#include <chrono> #include <cstddef> #include <memory> @@ -37,6 +38,13 @@ struct SampleConverter { uint convert(const void **src, uint *srcframes, void *dst, uint dstframes); uint availableOut(uint srcframes) const; + using SampleOffset = std::chrono::duration<int64_t, std::ratio<1,MixerFracOne>>; + SampleOffset currentInputDelay() const noexcept + { + const int64_t prep{mSrcPrepCount - MaxResamplerEdge}; + return SampleOffset{(prep<<MixerFracBits) + mFracOffset}; + } + DEF_FAM_NEWDEL(SampleConverter, mChan) }; using SampleConverterPtr = std::unique_ptr<SampleConverter>; |