problem with for loop index

Official support for: loomer.co.uk
KVRer
12 posts since 29 Jan, 2019

Post Tue Apr 09, 2019 2:19 am

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.

KVRAF
2253 posts since 25 Aug, 2003 from Bournemouth, UK

Post Tue Apr 09, 2019 2:28 am

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.

KVRer

Topic Starter

12 posts since 29 Jan, 2019

Post Wed Apr 10, 2019 1:01 am

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.

KVRAF
2253 posts since 25 Aug, 2003 from Bournemouth, UK

Post Wed Apr 10, 2019 1:18 am

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

KVRAF
2253 posts since 25 Aug, 2003 from Bournemouth, UK

Post Wed Apr 10, 2019 1:38 am

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.

KVRer

Topic Starter

12 posts since 29 Jan, 2019

Post Fri Apr 12, 2019 12:35 am

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

KVRAF
2253 posts since 25 Aug, 2003 from Bournemouth, UK

Post Fri Apr 12, 2019 6:58 am

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.

Return to “Loomer”