LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp_siggen.cpp
Go to the documentation of this file.
1#include "lasp_siggen.h"
2#include "arma_npy.h"
3#include "lasp_siggen_impl.h"
4#include <iostream>
5#include <pybind11/pybind11.h>
6
7using std::cerr;
8namespace py = pybind11;
9
21void init_siggen(py::module &m) {
22
24 py::class_<Siggen, std::shared_ptr<Siggen>> siggen(m, "Siggen");
25 siggen.def("setLevel", &Siggen::setLevel,
26 "Set the level of the signal generator");
27 siggen.def("setDCOffset", &Siggen::setDCOffset);
28 siggen.def("setMute", &Siggen::setMute);
29 siggen.def("setLevel", &Siggen::setLevel);
30 siggen.def("setLevel", &Siggen::setLevel, py::arg("newLevel"),
31 py::arg("dB") = true);
32 siggen.def("reset", &Siggen::reset);
33
34 siggen.def("setFilter", &Siggen::setFilter);
35
36 py::class_<Noise, std::shared_ptr<Noise>> noise(m, "Noise", siggen);
37 noise.def(py::init<>());
38
39 py::class_<Sine, std::shared_ptr<Sine>> sine(m, "Sine", siggen);
40 sine.def(py::init<const d>());
41 sine.def("setFreq", &Sine::setFreq);
42
43 py::class_<Periodic, std::shared_ptr<Periodic>> periodic(m, "Periodic",
44 siggen);
45 periodic.def("getSequence",
46 [](const Sweep &s) { return ColToNpy<d>(s.getSequence()); });
47
48 py::class_<Sweep, std::shared_ptr<Sweep>> sweep(m, "Sweep", periodic);
49 sweep.def(py::init<const d, const d, const d, const d, const us>());
50 sweep.def_readonly_static("ForwardSweep", &Sweep::ForwardSweep);
51 sweep.def_readonly_static("BackwardSweep", &Sweep::BackwardSweep);
52 sweep.def_readonly_static("LinearSweep", &Sweep::LinearSweep);
53 sweep.def_readonly_static("LogSweep", &Sweep::LogSweep);
54}
vd getSequence() const
Return copy of the generated sequence.
void setFilter(const std::string &name, std::shared_ptr< Filter > f)
Set a filter on the signal. For example to EQ the signal, or otherwise to shape the spectrum....
void setDCOffset(d offset)
Set a linear DC offset value to the signal.
void setLevel(const d level, bool dB=true)
Set the level of the signal generator.
void reset(const d newFs)
Reset the signal generator. Should be called whenever the output is based on a different sampling fre...
void setMute(bool mute=true)
Mute the signal. Passes through the DC offset. No lock is hold. If it just works one block later,...
Definition lasp_siggen.h:62
void setFreq(const d newFreq)
Sweep signal.
static constexpr int BackwardSweep
static constexpr int LogSweep
static constexpr int LinearSweep
static constexpr int ForwardSweep
void init_siggen(py::module &m)
Initialize Siggen wrappers.