Generate sequence of numbers at audiorate
Hi,
I'm not sure whether this qualifies as beginner or not but I'm trying to generate a sequence of numbers at the audio rate in MSP which corresponds to the following Matlab command:
[(0:N/2), -(N/2-1:-1:1)]
For N = 16 this would be the following sequence:
0 1 2 3 4 5 6 7 8 -7 -6 -5 -4 -3 -2 -1
I came up with a scheme which uses three count~ objects but it doesn't seem to work when I try to get the signals outside the patcher via outlets. I can get the last N/2 -1 samples correct but before that it's all zeros. It seems as if I have things working inside the patcher but honestly I'm not sure how to debug some of the audiorate stuff.
Any help would be appreciated!
Thanks,
Graham
For these types of problems I like to first prototype with data and an [uzi] to clearly see what is happening. Then use msp objects. You can also use capture~ to view signal output as text. I think this is a solution to the problem:
if you need three count~ objects to count once, you know that the approach is fundamentally wrong. :)
everything timo said... and this:
[(0:N/2), -(N/2-1:-1:1)]
search terms in this forum: 110.loopi, double modulo
search terms in max: fold, wrap, pong, div, %
0 1 2 3 4 5 6 7 8 -7 -6 -5 -4 -3 -2 -1
i hope you are sure you really want to start from 0.
suggestion for data rate sequencing:
- uzi or metro
- counter starting at 1
- mapping values by expression
suggestion how to transform such a data sequencer to MSP:
- phasor~
- *~ 15.
- +~ 1.5
- trunc~
(now you have a signal counter of variable speed)
- mapping values by math objects
if you dont need to change arguments/math at signal rate, you would better calculate the numbers at data rate, then peek~ them into a buffer~, and finally use the phasor->trunc signal counter patch to read the integer values from this buffer~