mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
made count of input and output samples independent
This commit is contained in:
parent
e4b687d1f6
commit
65e24d421f
1 changed files with 13 additions and 12 deletions
25
fdzp.hh
25
fdzp.hh
|
|
@ -10,28 +10,29 @@ Copyright 2019 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
namespace DSP {
|
||||
|
||||
template <int BINS, int FACT, typename CMPLX>
|
||||
template <int OUTPUT, int INPUT, typename CMPLX>
|
||||
class FDZP
|
||||
{
|
||||
typedef typename CMPLX::value_type VALUE;
|
||||
FastFourierTransform<BINS, CMPLX, -1> fwd;
|
||||
FastFourierTransform<BINS * FACT, CMPLX, 1> bwd;
|
||||
CMPLX tmp[BINS * FACT];
|
||||
static constexpr VALUE SCALE = VALUE(1) / VALUE(BINS);
|
||||
FastFourierTransform<INPUT, CMPLX, -1> fwd;
|
||||
FastFourierTransform<OUTPUT, CMPLX, 1> bwd;
|
||||
CMPLX tmp[OUTPUT];
|
||||
static constexpr VALUE SCALE = VALUE(1) / VALUE(INPUT);
|
||||
static_assert(INPUT < OUTPUT, "OUTPUT must be larger than INPUT");
|
||||
public:
|
||||
void operator ()(CMPLX *output, const CMPLX *input)
|
||||
{
|
||||
fwd(tmp, input);
|
||||
if (!(BINS&1)) {
|
||||
tmp[BINS/2] *= VALUE(0.5);
|
||||
tmp[BINS*FACT-BINS/2] = tmp[BINS/2];
|
||||
if (!(INPUT&1)) {
|
||||
tmp[INPUT/2] *= VALUE(0.5);
|
||||
tmp[OUTPUT-INPUT/2] = tmp[INPUT/2];
|
||||
}
|
||||
for (int i = (BINS+1)/2+1; i < BINS; ++i)
|
||||
tmp[BINS*(FACT-1)+i] = tmp[i];
|
||||
for (int i = (BINS+1)/2+1; i < BINS; ++i)
|
||||
for (int i = (INPUT+1)/2+1; i < INPUT; ++i)
|
||||
tmp[OUTPUT-INPUT+i] = tmp[i];
|
||||
for (int i = (INPUT+1)/2+1; i < INPUT; ++i)
|
||||
tmp[i] = 0;
|
||||
bwd(output, tmp);
|
||||
for (int i = 0; i < BINS * FACT; ++i)
|
||||
for (int i = 0; i < OUTPUT; ++i)
|
||||
output[i] *= SCALE;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue