Hi,
I'm trying to create mappings expressions using output history, but I can't get it to work.
I'm using the expression: y=x+2*y{-1}
With a gain of 2, the output of the mapping should blow up pretty quickly but it doesn't seem to affect the mapping with the inclusion of y{-n} terms.
Cheers,
Mathias
This is my code:
#include "mpr/mpr.h"
#include "stdio.h"
void sigHandler(mpr_sig sig, mpr_sig_evt evt, mpr_id inst, int length,
mpr_type type, const void *value, mpr_time time) {
printf("%f\n", *((float *)value));
}
int main(int argc, char const *argv[]) {
mpr_dev dev = mpr_dev_new("feedback-test", 0);
mpr_sig sigSend =
mpr_sig_new(dev, MPR_DIR_OUT, "output", 1, MPR_FLT, 0, 0, 0, 0, 0, 0);
mpr_sig sigRecv = mpr_sig_new(dev, MPR_DIR_IN, "input", 1, MPR_FLT, 0, 0, 0,
0, sigHandler, MPR_SIG_UPDATE);
float value = 0.0;
while (!mpr_dev_get_is_ready(dev)) {
mpr_dev_poll(dev, 100);
}
mpr_map map = mpr_map_new(1, &sigSend, 1, &sigRecv);
const char *expr = "y=x+2*y{-1}";
mpr_obj_set_prop(map, MPR_PROP_EXPR, 0, 1, MPR_STR, expr, 1);
mpr_obj_push(map);
for (;;) {
mpr_sig_set_value(sigSend, 0, 1, MPR_FLT, &value, MPR_NOW);
value += 0.01;
if (value > 1) {
value = 0;
}
mpr_dev_poll(dev, 100);
}
return 0;
}