boo/lib/audiodev/LtRtProcessing.hpp

82 lines
1.8 KiB
C++
Raw Normal View History

2018-10-07 03:36:44 +00:00
#pragma once
#include "boo/System.hpp"
#include "boo/audiodev/IAudioVoice.hpp"
#include "Common.hpp"
#include <memory>
#if INTEL_IPP
#include "ipp.h"
#endif
2018-12-08 05:17:51 +00:00
namespace boo {
#if INTEL_IPP
#define USE_LPF 0
#if USE_LPF
2018-12-08 05:17:51 +00:00
class FIRFilter12k {
IppsFIRSpec_32f* m_firSpec;
Ipp8u* m_firBuffer;
Ipp32f* m_dlySrc;
Ipp32f* m_inBuf;
public:
2018-12-08 05:17:51 +00:00
explicit FIRFilter12k(int windowFrames, double sampleRate);
~FIRFilter12k();
void Process(Ipp32f* buf, int windowFrames);
};
#endif
2018-12-08 05:17:51 +00:00
class WindowedHilbert {
#if USE_LPF
2018-12-08 05:17:51 +00:00
FIRFilter12k m_fir;
#endif
2018-12-08 05:17:51 +00:00
IppsHilbertSpec* m_spec;
Ipp8u* m_buffer;
int m_windowFrames, m_halfFrames;
int m_bufIdx = 0;
Ipp32f* m_inputBuf;
Ipp32fc* m_outputBuf;
Ipp32fc* m_output[4];
Ipp32f* m_hammingTable;
void _AddWindow();
public:
2018-12-08 05:17:51 +00:00
explicit WindowedHilbert(int windowFrames, double sampleRate);
~WindowedHilbert();
void AddWindow(const float* input, int stride);
void AddWindow(const int32_t* input, int stride);
void AddWindow(const int16_t* input, int stride);
template <typename T>
void Output(T* output, float lCoef, float rCoef) const;
};
#endif
2018-12-08 05:17:51 +00:00
class LtRtProcessing {
AudioVoiceEngineMixInfo m_inMixInfo;
int m_windowFrames;
int m_halfFrames;
int m_outputOffset;
int m_bufferTail = 0;
int m_bufferHead = 0;
std::unique_ptr<int16_t[]> m_16Buffer;
std::unique_ptr<int32_t[]> m_32Buffer;
std::unique_ptr<float[]> m_fltBuffer;
#if INTEL_IPP
2018-12-08 05:17:51 +00:00
WindowedHilbert m_hilbertSL, m_hilbertSR;
#endif
2018-12-08 05:17:51 +00:00
template <typename T>
T* _getInBuf();
template <typename T>
T* _getOutBuf();
public:
2018-12-08 05:17:51 +00:00
LtRtProcessing(int _5msFrames, const AudioVoiceEngineMixInfo& mixInfo);
template <typename T>
void Process(const T* input, T* output, int frameCount);
const AudioVoiceEngineMixInfo& inMixInfo() const { return m_inMixInfo; }
};
2018-12-08 05:17:51 +00:00
} // namespace boo