dsplib
1.1.0
C++ DSP library for MATLAB-like coding
Loading...
Searching...
No Matches
include
dsplib
delay.h
1
#pragma once
2
3
#include <dsplib/array.h>
4
5
namespace
dsplib {
6
7
//Delay input signal by fixed samples
8
template
<
typename
T>
9
class
Delay
10
{
11
public
:
12
explicit
Delay
(
int
length)
13
: _buffer(length) {
14
}
15
16
explicit
Delay
(
const
dsplib::base_array<T>
& initial)
17
: _buffer{initial} {
18
}
19
20
dsplib::base_array<T>
process(
span_t<T>
x) {
21
//TODO: use cycle buffer
22
const
int
nd = _buffer.size();
23
const
auto
tmp = concatenate(_buffer, x);
24
_buffer.slice(0, nd) = tmp.slice(tmp.size() - nd, tmp.size());
25
return
tmp.slice(0, x.size());
26
}
27
28
dsplib::base_array<T>
operator()(
span_t<T>
x) {
29
return
this->process(x);
30
}
31
32
private
:
33
dsplib::base_array<T>
_buffer;
34
};
35
36
using
DelayReal
=
Delay<real_t>
;
37
using
DelayCmplx
=
Delay<cmplx_t>
;
38
39
}
// namespace dsplib
dsplib::Delay
Definition
delay.h:10
dsplib::base_array
base dsplib array type
Definition
array.h:25
dsplib::span_t
Definition
span.h:295
Generated by
1.9.8