lutNCO

Lookup-Table方式の高速な局部発振器を提供します。 テンプレートパラメータのfuncには周期2PIの周期関数を与えることが出来ます。 たとえば、std.math.expiを与えれば複素発振器となり、std.math.sinであれば正弦波を出力します。

この局部発振器は周波数の動的な制御が可能なので、信号の周波数をフィードバック制御する際に用いることができます。 Lookup-Tableは、テンプレートパラメータ毎にプログラムの初期化時に生成されるので、 最初の初期化が終われば、実行コストはテーブルの参照のみになり、高速にアクセス可能です。 また、テーブル長を伸ばしても初期化コストが増加するだけで、実行コストはあまり大きくならないことも特徴です。

  1. auto lutNCO(real freq, real deltaT, real theta)
    template lutNCO(alias func, size_t divN)
    pure nothrow @safe @nogc
    lutNCO
    (
    real freq
    ,
    real deltaT
    ,
    real theta = 0
    )
    if (
    isPowOf2(divN)
    )
  2. auto lutNCO(R range, real freq, real deltaT, real theta)

Members

Aliases

E
alias E = typeof(func(0.0))
Undocumented in source.

Functions

lutNCO
auto lutNCO(real freq, real deltaT, real theta)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

LutNCO
struct LutNCO()
Undocumented in source.

Variables

table
immutable(E[]) table;
Undocumented in source.

Examples

auto sig1 = lutNCO!(std.math.expi, 4)(1, 0.25, 0);
static assert(isInputStream!(typeof(sig1)));
static assert(isInplaceComputableStream!(typeof(sig1)));
static assert(is(ElementType!(typeof(sig1)) : creal));

assert(equal!((a, b) => approxEqual(a.re, b.re) && approxEqual(a.im, b.im))
    (sig1[0 .. 1024], preciseComplexNCO(1, 0.25, 0)[0 .. 1024]));

sig1 = lutNCO!(std.math.expi, 4)(1000, 10.0L^^-6, std.math.E);
auto buf = sig1[0 .. 1024].array;
assert(sig1.readOp!"-"(buf).length == buf.length);
assert(equal!"a == 0"(buf, buf));

Meta