Data flow (bang order?) Problem
Hi all, first time poster and complete Max newbie here, so if this post is in the wrong format - or if the problem i'm having is due to a basic misunderstanding or poor design - please don't hesitate to let me know!
I am currently working on an algorithmic composer for a University project, this project is perhaps a little different in that I am aiming at making it able to transpose through different musical modes, whilst synthesising sound in just intonation. This means that I am generating additional voices on top of, and relative to a fundamental bass frequency. I am having trouble generating the first voice above the bass, however, as I have created an expression to: 1. Evaluate what note from the current available set of notes (this set of notes changes as the musical mode/scale is changed) is currently playing in the bass - then 2. to add a random interval (set by an itable) to this number, 3. look up the new number from the current available set of notes (this gives the midi note number) 4. evaluate the difference between the midi note number of the current bass note, and the new number (gives the interval number) 5. Use this number to trigger the correct equation for the interval selected (ie. difference of -9 or +3 = Minor 3rd > triggers the equation to multiply the frequency of the current bass note by 6:5, giving a just intonated minor 3rd.
My problem is is at stage 4. I currently have the program working so that it seems every time a new bass note is played, the value of that note, and the note value of the first voice to be generated on top of it, are sent to the equation to evaluate the difference between them simultaneously. For example, if the itable for generating random intervals in voice 1 is set so that it will only generate unisons (set 1 at 100%, all other values at 0%) you will see the number boxes that are being fed into the evaluating equation simultaneously display the same number every time a new note is generated. However in reality this is not the case, by feeding these numbers into a pack object and unpacking to a new message box, I was able to see that there is actually a lag, and that the message being unpacked contains two different numbers!! I cant work out why this is happening or how to fix it, and was hoping that this might be a common problem with data flow, that some of you have come across before? I hope my explanation of the problem is adequate, I apologise for having quite a complicated program!
Instructions: In order to see the problem, scroll down to the bottom of the patch and press toggles 1 and 2, then the problematic section is labelled, above the section with the itables in the right hand side of the patch.
Have you looked at the trigger object? It's a very simple way to guarantee order of operations.....
Thanks Max, yes I have tried a number of different potential solutions using trigger, but haven't been able to find the right one so far..
You should try to organise timing of received messages needed to calculate
whatever the result should be.
Adding that random values using so many if objects etc will definitely cost some time,
which would then result in fast hidden multiple results
using pack is problematic, because only 1st item triggers the output.
if 2nd item arrives later, list would not reflect current 2 values.
using pak, delay and zl change could help, in situation when one does not have
tight and organised data flow.

Thank you very much! This solution did work, but unfortunately - I have had to redesign the project using matrixctrl to play the bass notes rather than generate them probabilistically. I am having a new problem trying to get voices above the bass no trigger correctly (or not to retrigger) and have tried using this solution but have not had any luck. If anyone could help me out with this i would be eternally grateful.
The problem lies in the section to the right of the main matrix control (in the unlocked patch) Ive included a preset in presentation mode that highlights the issue. To the right of the unlocked patch there are a few other matrixcontrols - these each select, and stack an available interval, on top of the last one, and move it to the closest available value based on receive objects from the previous matrixcontrols output. However, although this works in principal, the timing of how various messages are fired from the vexpr object inside the patches (p voice1) and (p voice2) doesnt seem to work. (p voice 3) also has this problem, but I havent finished coding the conditions for what messages are fired into the vexpr object for that one yet - so its best ignored for now.
I hope Ive explained the problem adequately, and I really hope one of you is able to help!
Thanks in advance!!
That patch is too complicated for what it should do.
That's why you get timing problems, or better say
difficulties to trace order of executed events, or even to
ignore simple mistakes, like to connect frequency to adsr~

Instead of numerous if objects, one could use simple objects
like sel, route etc.
And make patch look much tidier, thus allowing better overwiew.
Take one example - modeselector patch.
All it does is to rotate note list to 7 outlets.

all it needs could be reduced to :

Another example

alternative

-----

Or :

( you know what original looks like...)
-------
What I am trying to say is, that I would be glad to help you solve the problem,
but have absolutely no motivation to scroll arround in that large patch ,
full of unused leftovers, half finished constructs etc, trying to understand what and why should happen, and why does it not do what it is supposed to do.
Even that it might seem to be irrelevant, what objects one uses to get
a result, it can affect performance and order of execution quite a bit.
------
I suggest you post only patch part with a function which needs to be helped with
like if you can't get matrix to execute notes.