Hi there Shoo,
After a bit of fiddling, I managed to get things fixed reliably.
It turns out that the main problem was with the 'mem to Float Array' convertor - because it has no 'Green' inputs at all, it is not aware of when the contents of the array are changed, apart from when you force an update by disconnecting/re-connecting it.
I solved this using the 'mem to Min/Max' instead - this has a Green input pin for its 'Samples to Average over' input, which now gets triggered when the code outputs a 'Done' signal (After sampling is complete). Because the 'Min/Max' is set to average over one sample, it does not affect the output values at all, it is used purely to force an update of the array.
Sorry for that little oversight in my original post - I had never used the 'mem to Array' in a situation like this where the data gets updated on an 'arbitrary' basis.
Here's the schematic - as I am a SynthMaker user, the file is really an SM one, with the extension edited to '.fsm', but it should work OK, there are no 'SM only' parts in there.
A couple of other points regarding your other questions...
- The size of a 'mem' is always fixed, it has no way to know the max index reached by the counter - hence your spurious data in the second half of the display; it is just a 'ghost image' of whatever memory contents happened to be in that space when the 'mem' got updated.
I've made a small change so that the 'mem' size matches the number of sample points - note that the 'mem' size is always in bytes, and each float sample requires 4 bytes (32bit data) - hence the multiplication of the size.
For a stereo 'mem', you would need to multiply by 8.
- Most of the other errors were caused simply by the array not updating properly, as noted above - so it was often not showing the real contents of the 'mem'.
- Be careful with the 'streambool' data type. There is a difference between 'Green' and stream (blue) boolean data that makes them incompatible.
For Green Boolean; False = 0, True = 1.
For stream boolean, the content is actually a bitmask; False = 0, True = 0xFFFFFFFF (i.e. All bits set, which is not a valid float number, it is only useful for using with the '&' operator for bitmasking.)
So, the streamboolin/out is really only intended for situations where you want to pass the raw bitmask between stream components to save having to use a lot of repeated (MyBoolVariable > 0) type comparisons.
NB) The code is slightly modified so that 'i1' is always the index, and 'datamarked' uses 'sample & hold' to retain triggered values. Your original code looked to be OK - I made the changes so that I could use readouts to check the values when I looked for the bug.