Peek/poke inside loop structures

    Nov 16 2012 | 1:25 pm
    I've been playing with the new control structures in GenExpr, trying to push their limits a bit. For some reason, I can't read/write to a data or buffer object from within the loop. Is this a bug or a known limitation? I'm hoping that future versions support this, as it'd enable some really useful additions to Gen's current functionality (oversampling, for example). Any insight anyone?

    • Nov 16 2012 | 8:21 pm
      this is a current limitation. a shame as i agree could be very powerful. i asked the devs about it and it is on the general feature request radar as far as i know.
    • Nov 18 2012 | 3:04 am
      Yes, unfortunately this is a known issue at the moment, but it will be resolved in the next update. This issue also affects the use of Data etc. within functions currently.
    • Apr 27 2016 | 12:50 pm
      HI Graham, I see you answered this post before, I am trying this:
      Data somedata(32); Data moredata(32,32); y =0; for (x =0;x somedata.poke(1); y += somedata.peek(1);//works... somedata.poke(1,x); y += somedata.peek(1,x);//doesn't work. } out1 = y;
      Now gen supports any number of channels, the latter would be extremely useful for array operations :)
    • Apr 28 2016 | 5:40 am
      ^i don't think you wrote that quite right(in your code there, you've only used 'somedata' and never use the 'moredata' multichannel array). but even if you did write 'moredata' into the last 2 lines which don't work for you, it doesn't seem like it would be using a proper set of arguments.
      here's a simple example that shows how the multi-channel 'data'-array would work, though it probably isn't very useful by itself, it performs a simple way of recording powers-of-2 with additions into the multichannel data, and then providing inputs to read/index everything, just to show every single sample within the 32 channels of a 32-index 'data' does work properly:
      Data somedata(32);
      Data moredata(32,32);
      x = 0; y = 0;
      for (i = 0; i < 32; i+=1)
      x = somedata.peek(i);
      out1 = x;
      for (j = 0; j < 32; j+=1) 
      	for (k = 0; k < 32; k+=1) 
      out2 = moredata.peek(in1,in2);
      And here's a patch to demo based on the above:
      Hope it helps.
    • Apr 28 2016 | 5:50 am
      (^and halfway through writing it, i decided not to even bother using the variable 'y', so you could also take out the 'x' there and assign 'somedata.peek(i);' directly to out1... but whatevs, you get the idea :) also, see here where Graham at the end states to use 'codeview', whenever i'm confused, that's what i do too, for example, create a 'poke bs' object, and the inlets in order from left-to-right form the arguments for the codebox version, example: 'bs.poke(arg1,arg2,arg3,arg4) )
    • Apr 28 2016 | 6:01 am
      whoops forgot to include the link to Graham's words of wisdom:
    • May 11 2016 | 10:42 am
      Thank you, I will try it in my patch, but there is something causing it not to work. It could be because it is in a subpatch, and it could be because it is in a method, or maybe it is because it is a poly~ object and multiple instances should not write to the same place at the same time, or maybe it is something else. The problem is, when it crashes it deletes everything inside the patch, and after a number of such calamities in projects that also complain if I keep multiple copies of the same file on my searchpath, and with poly~ objects disconnecting themselves when I try to change the file to a version that doesn't work, I kind of decided to stick with what I know works for a while. Maybe I'll have another stab at it when I finish the Godel rewrite, but as Godel is already 1,000 lines of gen~ code that I'm trying to get working, it could be some time before I get to it. Maybe next year? :)