From ed9b7914eeff6d0db2c90b34fcc3673778250ed7 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 2 Oct 2017 19:19:55 -1000 Subject: [PATCH] Sample blend timing fix for LtRt processing --- lib/audiodev/LtRtProcessing.cpp | 31 +++++++++++++++++++++++-------- lib/audiodev/LtRtProcessing.hpp | 5 +++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/audiodev/LtRtProcessing.cpp b/lib/audiodev/LtRtProcessing.cpp index 9267778..74ed99d 100644 --- a/lib/audiodev/LtRtProcessing.cpp +++ b/lib/audiodev/LtRtProcessing.cpp @@ -35,6 +35,7 @@ inline T ClampFull(float in) #define M_PI 3.14159265358979323846 /* pi */ #endif +#if USE_LPF static constexpr int FirTaps = 27; FIRFilter12k::FIRFilter12k(int windowFrames, double sampleRate) @@ -75,9 +76,13 @@ void FIRFilter12k::Process(Ipp32f* buf, int windowFrames) ippsMove_32f(buf, m_inBuf, windowFrames); ippsFIRSR_32f(m_inBuf, buf, windowFrames, m_firSpec, m_dlySrc, nullptr, m_firBuffer); } +#endif -WindowedHilbert::WindowedHilbert(int windowFrames, double sampleRate) -: m_fir(windowFrames, sampleRate), m_windowFrames(windowFrames), +WindowedHilbert::WindowedHilbert(int windowFrames, double sampleRate) : +#if USE_LPF + m_fir(windowFrames, sampleRate), +#endif + m_windowFrames(windowFrames), m_halfFrames(windowFrames / 2), m_inputBuf(ippsMalloc_32f(m_windowFrames * 2 + m_halfFrames)), m_outputBuf(ippsMalloc_32fc(m_windowFrames * 4)), @@ -110,15 +115,16 @@ WindowedHilbert::~WindowedHilbert() void WindowedHilbert::_AddWindow() { +#if USE_LPF Ipp32f* inBufBase = &m_inputBuf[m_windowFrames * m_bufIdx + m_halfFrames]; m_fir.Process(inBufBase, m_windowFrames); +#endif if (m_bufIdx) { /* Mirror last half of samples to start of input buffer */ Ipp32f* bufBase = &m_inputBuf[m_windowFrames * 2]; - for (int i=0 ; i(output[i*2] + tmp * lCoef); @@ -188,7 +194,7 @@ void WindowedHilbert::Output(T* output, float lCoef, float rCoef) const int i, t; for (i=0, t=0 ; i(output[i*2] + tmp * lCoef); output[i*2+1] = ClampFull(output[i*2+1] + tmp * rCoef); @@ -202,7 +208,7 @@ void WindowedHilbert::Output(T* output, float lCoef, float rCoef) const for (t=0 ; i(output[i*2] + tmp * lCoef); output[i*2+1] = ClampFull(output[i*2+1] + tmp * rCoef); } @@ -223,7 +229,7 @@ template <> int32_t* LtRtProcessing::_getOutBuf() { return m_32Buffer.g template <> float* LtRtProcessing::_getOutBuf() { return m_fltBuffer.get() + m_outputOffset; } LtRtProcessing::LtRtProcessing(int _5msFrames, const AudioVoiceEngineMixInfo& mixInfo) -: m_inMixInfo(mixInfo), m_windowFrames(_5msFrames), m_halfFrames(m_windowFrames / 2), +: m_inMixInfo(mixInfo), m_windowFrames(_5msFrames * 4), m_halfFrames(m_windowFrames / 2), m_outputOffset(m_windowFrames * 5 * 2) #if INTEL_IPP , m_hilbertSL(m_windowFrames, mixInfo.m_sampleRate), @@ -261,6 +267,15 @@ LtRtProcessing::LtRtProcessing(int _5msFrames, const AudioVoiceEngineMixInfo& mi template void LtRtProcessing::Process(const T* input, T* output, int frameCount) { +#if 0 + for (int i=0 ; i(); T* outBuf = _getOutBuf(); diff --git a/lib/audiodev/LtRtProcessing.hpp b/lib/audiodev/LtRtProcessing.hpp index 17a2caa..553ed81 100644 --- a/lib/audiodev/LtRtProcessing.hpp +++ b/lib/audiodev/LtRtProcessing.hpp @@ -14,7 +14,9 @@ namespace boo { #if INTEL_IPP +#define USE_LPF 0 +#if USE_LPF class FIRFilter12k { IppsFIRSpec_32f* m_firSpec; @@ -26,10 +28,13 @@ public: ~FIRFilter12k(); void Process(Ipp32f* buf, int windowFrames); }; +#endif class WindowedHilbert { +#if USE_LPF FIRFilter12k m_fir; +#endif IppsHilbertSpec* m_spec; Ipp8u* m_buffer; int m_windowFrames, m_halfFrames;