Merged in develop.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Anne de Jong 2023-08-30 21:44:20 +02:00
commit 628ba898c9
5 changed files with 53 additions and 5 deletions

View File

@ -14,7 +14,6 @@ steps:
path: /root/.ccache
commands:
- scripts/build_archlinux.sh
volumes:
- name: archlinux_ccache
host:

View File

@ -22,15 +22,46 @@ vd Siggen::genSignal(const us nframes) {
if (!_muted) {
vd signal_dynamic = _level_linear * genSignalUnscaled(nframes);
// Filter signal
for (auto f : _filters) {
assert(f.second);
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;
}
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,
std::shared_ptr<Filter> filter) {
DEBUGTRACE_ENTER;
@ -59,5 +90,6 @@ void Siggen::reset(const d newFs) {
assert(f.second);
f.second->reset();
}
_interruption_frame_count = 0;
resetImpl();
}

View File

@ -29,6 +29,13 @@ private:
protected:
std::mutex _mtx;
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 vd genSignalUnscaled(const us nframes) = 0;
@ -36,6 +43,15 @@ protected:
public:
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
* otherwise to shape the spectrum. Filters are stored in a map, and
@ -59,7 +75,7 @@ public:
*
* @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

View File

@ -30,6 +30,7 @@ void init_siggen(py::module &m) {
siggen.def("setLevel", &Siggen::setLevel, py::arg("newLevel"),
py::arg("dB") = true);
siggen.def("reset", &Siggen::reset);
siggen.def("setInterruptPeriod", &Siggen::setInterruptPeriod);
siggen.def("setFilter", &Siggen::setFilter);

View File

@ -10,7 +10,7 @@ set -e
# Update cache
apt update
# 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
git submodule update --init --recursive
python3 -m build