This commit is contained in:
commit
628ba898c9
@ -14,7 +14,6 @@ steps:
|
|||||||
path: /root/.ccache
|
path: /root/.ccache
|
||||||
commands:
|
commands:
|
||||||
- scripts/build_archlinux.sh
|
- scripts/build_archlinux.sh
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: archlinux_ccache
|
- name: archlinux_ccache
|
||||||
host:
|
host:
|
||||||
|
@ -22,15 +22,46 @@ vd Siggen::genSignal(const us nframes) {
|
|||||||
|
|
||||||
if (!_muted) {
|
if (!_muted) {
|
||||||
vd signal_dynamic = _level_linear * genSignalUnscaled(nframes);
|
vd signal_dynamic = _level_linear * genSignalUnscaled(nframes);
|
||||||
|
|
||||||
|
// Filter signal
|
||||||
for (auto f : _filters) {
|
for (auto f : _filters) {
|
||||||
assert(f.second);
|
assert(f.second);
|
||||||
f.second->filter(signal_dynamic);
|
f.second->filter(signal_dynamic);
|
||||||
}
|
}
|
||||||
signal += signal_dynamic;
|
|
||||||
}
|
// Check whether we are running / not for signal interruption.
|
||||||
|
bool activated = false;
|
||||||
|
if (_interrupt_period_s < 0) {
|
||||||
|
activated = true;
|
||||||
|
} else {
|
||||||
|
if (_interruption_frame_count < _interrupt_period_s*_fs) {
|
||||||
|
activated = true;
|
||||||
|
}
|
||||||
|
_interruption_frame_count += nframes;
|
||||||
|
|
||||||
|
if (_interruption_frame_count >= 2 * _interrupt_period_s*_fs) {
|
||||||
|
_interruption_frame_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activated) {
|
||||||
|
signal += signal_dynamic;
|
||||||
|
}
|
||||||
|
} // end if(!_muted)
|
||||||
|
|
||||||
return signal;
|
return signal;
|
||||||
}
|
}
|
||||||
|
void Siggen::setInterruptPeriod(const d newPeriod) {
|
||||||
|
mutexlock lck(_mtx);
|
||||||
|
if (newPeriod == 0) {
|
||||||
|
throw rte("Interruption period cannot be 0");
|
||||||
|
}
|
||||||
|
if (newPeriod < 0) {
|
||||||
|
_interrupt_period_s = -1;
|
||||||
|
} else {
|
||||||
|
_interrupt_period_s = newPeriod;
|
||||||
|
}
|
||||||
|
}
|
||||||
void Siggen::setFilter(const std::string &name,
|
void Siggen::setFilter(const std::string &name,
|
||||||
std::shared_ptr<Filter> filter) {
|
std::shared_ptr<Filter> filter) {
|
||||||
DEBUGTRACE_ENTER;
|
DEBUGTRACE_ENTER;
|
||||||
@ -59,5 +90,6 @@ void Siggen::reset(const d newFs) {
|
|||||||
assert(f.second);
|
assert(f.second);
|
||||||
f.second->reset();
|
f.second->reset();
|
||||||
}
|
}
|
||||||
|
_interruption_frame_count = 0;
|
||||||
resetImpl();
|
resetImpl();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,13 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
std::mutex _mtx;
|
std::mutex _mtx;
|
||||||
d _fs = 0;
|
d _fs = 0;
|
||||||
|
/**
|
||||||
|
* @brief Interuption of period the signal. If set, the signal will be
|
||||||
|
* periodically turned on / off. This is useful for measuring reverberation
|
||||||
|
* times using the "interrupted noise method".
|
||||||
|
*/
|
||||||
|
int _interrupt_period_s = -1;
|
||||||
|
int _interruption_frame_count = 0;
|
||||||
|
|
||||||
virtual void resetImpl() = 0;
|
virtual void resetImpl() = 0;
|
||||||
virtual vd genSignalUnscaled(const us nframes) = 0;
|
virtual vd genSignalUnscaled(const us nframes) = 0;
|
||||||
@ -36,6 +43,15 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual ~Siggen() = default;
|
virtual ~Siggen() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the interruption period for interrupted signals.
|
||||||
|
*
|
||||||
|
* @param newPeriod If < 0, the interruption is disabled. If > 0, an
|
||||||
|
* approximate interruption number of *buffers* is computed, rounded upwards
|
||||||
|
* for which the signal generator is turned off.
|
||||||
|
*/
|
||||||
|
void setInterruptPeriod(const d newPeriod);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set a filter on the signal. For example to EQ the signal, or
|
* @brief Set a filter on the signal. For example to EQ the signal, or
|
||||||
* otherwise to shape the spectrum. Filters are stored in a map, and
|
* otherwise to shape the spectrum. Filters are stored in a map, and
|
||||||
@ -59,7 +75,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param mute if tre
|
* @param mute if tre
|
||||||
*/
|
*/
|
||||||
void setMute(bool mute = true) { _muted = mute; }
|
void setMute(bool mute = true) { _muted = mute; _interruption_frame_count=0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the level of the signal generator
|
* @brief Set the level of the signal generator
|
||||||
|
@ -30,6 +30,7 @@ void init_siggen(py::module &m) {
|
|||||||
siggen.def("setLevel", &Siggen::setLevel, py::arg("newLevel"),
|
siggen.def("setLevel", &Siggen::setLevel, py::arg("newLevel"),
|
||||||
py::arg("dB") = true);
|
py::arg("dB") = true);
|
||||||
siggen.def("reset", &Siggen::reset);
|
siggen.def("reset", &Siggen::reset);
|
||||||
|
siggen.def("setInterruptPeriod", &Siggen::setInterruptPeriod);
|
||||||
|
|
||||||
siggen.def("setFilter", &Siggen::setFilter);
|
siggen.def("setFilter", &Siggen::setFilter);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ set -e
|
|||||||
# Update cache
|
# Update cache
|
||||||
apt update
|
apt update
|
||||||
# Install requirements
|
# Install requirements
|
||||||
apt install -y git python3-virtualenv libopenblas-dev python3-pip libfftw3-dev libusb-1.0-0-dev libpulse-dev python3-build
|
apt install -y git python3.10-venv libopenblas-dev python3-pip libfftw3-dev libusb-1.0-0-dev libpulse-dev python3-build
|
||||||
# Build
|
# Build
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
python3 -m build
|
python3 -m build
|
||||||
|
Loading…
Reference in New Issue
Block a user