Forums > MaxMSP

### 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.

— Pasted Max Patch, click to expand. —
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< ((spaces/arguments[i]) - 1); k++)
{
outlet(0, 0);
outlet(1, index);
index++;
}
}
}
}
}

and here is the section of the patch that uses it:

———-begin_max5_patcher———-
1534.3ocyZs0jaZCE9Yu+JzP5Sc15JIz09TSZ6+fN8kzcxfsY8RBWbAbR1lI
82dERhK1K1fw.q2GXsORv4nOct7oC9a2svYUxW8yb.+B38fEK91cKVnEUHXg
29gT+04FcwfEOM.lq+mKdI8d.RrDVoYkJL1mVGXqzfM5mtZo8SHAwoP32u6t
hK2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Kmtpn.RmweIlBklRF
p+CIGZAs5lnLqr7mMIFKks8ojr7UdolHRXC89bgdaVn8LobjzSsBJ8icuVVR
0rYVs8.uZlKEK0kHERE3ngDYKPREVRtPrr5Fc66MN5G6I2eW1MwYdbg0rrm7
NKV9J1nicmEozQLW+OBPu1ugfxVnM7WQ.dbafiZQ9J24lxLSFjgfu7N2fmj1
JNy8TzcpOUrEmIi9ohwzw1iLHNyKZW1qriYYrpz79.jCvwbLecd678+jlm5A
0XNAS0Kmgp6LyP099ULtixtJYzF3hmliAzG3c9dG6VmvRl7C3WmwAcMTeaNg
AwG+S7Qq5B4GhcYI6SWWt1K+ovnrfJ0uwOKOH1qtqJU+hPZzkBmmB1rwOtYs
+nfM6RToMslwIXhcYVE7Fyp3zaPixnut1.wuFFErOFEZ1LphywzisOxrhTJ5
ecaTR1rZSh9.TGglStM0GbRvu816TbFlUa5Fbu6HHncahb6YRL5kYSDJo37e
XyKtkRp+10lNEht81UMFEtK2+aQiRBuEQJ4sGYl4cyi2GhLxYkyPexldStwM
u6br9TI73rXSdN99.Tr4cyS.6CMl4kxfnO0BExYOUPm9SDw7lF+H8MAUgUe4
628+.vYRzN.
———–end_max5_patcher———–

Viewing 2 posts - 1 through 2 (of 2 total)

Forums > MaxMSP