problem with timing and triggering of recalculation in expr object
I am experiencing strange problems with recalculation of expr objects
To reproduce the problems I experience do the following:
Put the 3 attached files in the same directory,
and open shepbasic2_demo.maxpat.
Configure notein and noteout for the midi config of your machine.
The red number fields display pitch and velocity of the key you pressed,
the green numberfields will show the pitches that should be played,
and the blue number fields display the corresponding velocities.
On your Midi keyboards, enter key 60 (c4)
The first time you do that, no sound output will happen,
the green pitch fields will display the values needed,
but all the velocity output fields will be 0.
When you press key 60 (c4) a second time, things will work ok.
Now, when you then press c3 repeatedly, the sound results of the first
press is different from the sound of the second, third ... press.
So it seems that the shepbasic2 abstraction does not update its second output
in time.
How can I force shepbasic to completely recalculate all its output
whenever any input changes?
I probably need to put some bang or trigger object in some place,
but being a Max newbie I do not know where I should put it.
you have to collect all relevant parts of a calculation and output
only once - whan all calculations are done.
check trigger, pack, pak join and change or zl.change objects
I found out that the solution is much simpler.
In shepbasic2.maxpat,
expr round($i1*$f2) needs to be changed to
expr round($f1*$i2) and the connectors to the 2 inlets need to be exchanged.
Then, complete calculation is triggered whenever a key is pressed.