1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

scale: fixes for scale hook

This commit is contained in:
Steffen Vogel 2021-06-18 14:31:29 -04:00
parent d53547934c
commit 2680a067f0
2 changed files with 28 additions and 9 deletions

View file

@ -0,0 +1,19 @@
@include "hook-nodes.conf"
paths = (
{
in = "signal_node"
out = "file_node"
hooks = (
{
type = "scale"
signal = "sine"
offset = 100.0
scale = 55.0
}
)
}
)

View file

@ -104,27 +104,27 @@ public:
state = State::PARSED;
}
virtual Hook::Reason process(sample *smp)
virtual Hook::Reason process(struct sample *smp)
{
int k = signal_index;
unsigned k = signal_index;
assert(k < smp->length);
assert(state == State::STARTED);
switch (sample_format(smp, k)) {
case SignalType::INTEGER:
smp->data[k].i = smp->data[k].i * scale + offset;
smp->data[k].i *= scale;
smp->data[k].i += offset;
break;
case SignalType::FLOAT:
smp->data[k].f = smp->data[k].f * scale + offset;
smp->data[k].f *= scale;
smp->data[k].f += offset;
break;
case SignalType::COMPLEX:
smp->data[k].z = smp->data[k].z * (float) scale + (float) offset;
break;
case SignalType::BOOLEAN:
smp->data[k].b = smp->data[k].b * (float) scale + (float) offset;
smp->data[k].z *= scale;
smp->data[k].z += offset;
break;
default: { }