Mappings with output history

9 views
Skip to first unread message

mathias...@gmail.com

unread,
Sep 17, 2020, 7:49:41 AM9/17/20
to dot_mapper
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;
}

Mathias Bredholt

unread,
Sep 17, 2020, 11:09:42 AM9/17/20
to dot_m...@googlegroups.com
Hi again, 

Furthermore, I see that the MAX_HISTORY in expression.c is -100. Are there any complications in changing this to a much larger value, say 2000?

Cheers,
Mathias

--
You received this message because you are subscribed to a topic in the Google Groups "dot_mapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dot_mapper/kNbsfNAZ3lQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dot_mapper+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dot_mapper/bd991ebd-ee08-4d70-9ad7-37db43fad889n%40googlegroups.com.

Joseph Malloch

unread,
Sep 17, 2020, 11:30:57 AM9/17/20
to dot_m...@googlegroups.com
Hi Mathias,

There was a bug when defining maps with feedback when the map involved only local signals – this wasn’t caught by the test suite since the tests tend to use different devices for source and destination. I have pushed a fix to GitHub.

*please note that the v2-devel branch now builds a library called libmapper rather than libmpr. You should remove old installed versions called libmpr from your system.

Regarding the MAX_HISTORY value, the only complication is memory usage storing the signal history. In practice I’ve tried to encourage using IIR filters with less memory rather than FIR filters – e.g. using exponential means instead of windowed means.

Cheers,
Joe

You received this message because you are subscribed to the Google Groups "dot_mapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dot_mapper+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dot_mapper/DC92475C-7A32-4ADB-930E-7095EE3489C8%40gmail.com.

Mathias Bredholt

unread,
Sep 17, 2020, 12:16:10 PM9/17/20
to dot_m...@googlegroups.com
Hi Joe,

Thanks for the note, I deleted my libmpr versions, but I still have the issue on the latest commit on v2-devel. I tried with two different devices as suggested by the tests and that works.

For MAX_HISTORY my idea is to try and implement my project MapLooper directly within libmapper maps i.e. implementing a looper system using maps with feedback. If I could change between two mappings
y = x
and
y = y{-D}
where D i the loop length, this should be possible. Do think it’s feasible or would it take unpractical amounts of memory?

Cheers,
Mathias


Joseph Malloch

unread,
Sep 17, 2020, 12:49:29 PM9/17/20
to dot_m...@googlegroups.com
Hi Mathias,

The local-map feedback expression works for me running against the latest v2-devel commit (e732a23). I modified your code (pasted below) to #include libmapper instead of libmpr, and removed the old timetag argument from mpr_sig_set_value().

I’m intrigued by your looping idea – maybe we can connect off-list for a video chat to discuss this further?

Cheers,
Joe

#include "mapper/mapper.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);


    value += 0.01;
    if (value > 1) {
      value = 0;
    }

    mpr_dev_poll(dev, 100);
  }

  return 0;
}

Mathias Bredholt

unread,
Sep 17, 2020, 12:55:37 PM9/17/20
to dot_m...@googlegroups.com
Hi Joe,

Thanks! It works for me now as well. It would be great to video chat! I’ll send you an email and we can find a time!

Cheers,
Mathias

Reply all
Reply to author
Forward
0 new messages