Passing Data / Buffer at Gen~ function


    Mar 28 2016 | 12:49 pm
    Hi guys,
    Is there a way to pass a "Data" name as a parameter on a declared function in gen~'s codebox? I want to have a function alter some values in various Data arrays, is it possible without hardcoding the Data names in my algorithm?
    Nick

    • Mar 28 2016 | 3:28 pm
      Should be possible. Quick test, and it does work, though it did turn up a minor bug (now logged internally):
      fun(dat, val) {
      	poke(dat, val);
      	// minor bug: a return value is necessary, or else the function might be wrongly optimized away
      	return val;
      }
      
      Data a(1);
      Data b(1);
      
      out1 = peek(a, 0);
      out2 = peek(b, 0);
      
      fun(a, 7);
      fun(b, 4);
      
      Just don't try returning Data/Buffer etc. from a function -- that isn't supported (yet).
    • Mar 28 2016 | 4:23 pm
      Thank you Graham, didn't think it would be that simple!
      Cheers!
      Nick