problem with for loop index

Official support for: loomer.co.uk
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi Colin,

Because I had this problem a couple of times now I thought I'd let you know. The patch is a basic macro that loops over an array and adds all elements (integer values).

Where it starts to wrong is when I have to check when to send the result to the outlet. I'm not sure what your intended pattern is for that but I check whether the current index (using for-loop) is equal to the array length and then send the stored value to the outlet.
If I do that I will always get a result of zero, because it seems the for-loop will send the last index first.
If I manually build a counter and use that to compare with the array length then it works.

Anyway, Thanks for the awesome plugin. I built sequencer based on a cellular automata last week, was a lot of fun. Looking forward to the library ;-)
You do not have the required permissions to view the files attached to this post.

Post

I'll look into it today. I don't suppose you could attach or otherwise send me both of these presets, if you still have them?
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post

Okay, I did not have the exact presets anymore but I think it will help you.
You do not have the required permissions to view the files attached to this post.

Post

Thanks!
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post

Right, I think I see what you mean.

If you wanted to use the [for] module like this, rather than comparing the indices to calculate when the loop has finished, let whatever called the [for] module call the downstream module. This event would be guaranteed to occur after the [for] has finished, and even in the case of an empty array.

Image
([FINISHED!] is just a [print] module in this example.)

But you could also use the [for each] module, which will take a composite object, such as an array, and output each element in order, one-by-one. Which would simplify your macro.
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post

Thanks for your detailed answer!
This is making a lot more sense now. If I try to apply it I'm still getting way to many results sent to to the result outlet though. I guess my question rather boils down to: How do I conditionally send data to an outlet after the loop ends? I'm trying to use the branch module but its active data inlet (value) i have to connect to the data I want to send. And since the data is changing on every loop iteration it will activate the branch module on each iteration.
Hope this makes sense otherwise I can also try to take another picture.
Cheers Rufus

Post

I think I see what you're asking (but it not, please do post a screenshot or preset and I'll see if I can point you in the right direction.)

Essentially, use a [latch]. This will store the most recent thing sent through the left "write" inlet, and will only output it when it receives something through the right "read' inlet.

Image
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Post Reply

Return to “Loomer”