Variable Roll Value for Audio Rate Sequencer


    May 17 2009 | 3:42 am
    Here is an audio rate sequencer i am in the process of completing. I've been struggling with getting the sequencer to give rolls of a variable length. Here is how I am trying to do it:
    Each step has a number of "spaces" - these are the total number of samples in a given step. Roll values can be any even divisor of the total number of spaces, excluding one. So, for example, if a step has 12 samples in it, the roll can be of values 1, 2, 3, 4 or 6.
    The reason is you have to have a 0 following each 1 in order for it to be a click, and thus trigger the sample to play (using zigzag~ connected to wave~). The number of zeros following a 1 depends on the roll value. For example, with 12 spaces, a roll value of 6 means 1 zero for each one, 4 means 2 zeros for each one, 3 means 3 zeros for each one, etc.
    Though this seems straightforward, my patch is not working and I have absolutely no idea why. The part in the big pink box is where my problem lies. I would deeply appreciate any help. This has been a bewildering and frustrating experience. Thanks for your time.

    • May 18 2009 | 1:37 am
      if anyone is interested, i came to a brief and simple solution through javascripting (was my first time using the js object. i was surprised at how amazingly easy it was to incorporate some line code for processes that can get rather convoluted with strictly max objects).
      here is the js file "rollwrite.js":
      outlets = 2;
      var index = 0; var spaces = 12;
      function msg_int(i) { spaces = i; }
      function bang() { index = 0; }
      function list() { var i; var j; var k;
      for(i=0; i { if(arguments[i] == 0) { for(j=0; j { outlet(0, 0); outlet(1, index); index++; } } else { while(spaces%arguments[i] != 0) { arguments[i] = arguments[i] - 1; } for(j=0; j { outlet(0, 1); outlet(1, index); index++; for(k=0; k { outlet(0, 0); outlet(1, index); index++; } } } } }
      and here is the section of the patch that uses it: