@k-chaffin, @Andre_M, and anyone who has opinions, I have an early-beta version I’d like you to try.
I’ve been working on some functionality I’ve been calling “multithreading”, for lack of a better term. It allows the user to create multiple “blocks” of code that can run in parallel.
It’s working, so far as I can tell, though I suspect some cases haven’t been tested. but I’d love some pre-release confirmation that the design is reasonable and not terribly confusing. Or more likely, I’d like to hear where the design needlessly prevents useful functionality and how I could improve it; or, you know, that it outright doesn’t work.
The builds are here. The docs have been updated a bit, but I’d take suggestions on what needs to be sharper.
Briefly, this introduces two new functions, start() and trigger(), two new commands, CLEAR ALL and RESET, and some new structures that are the meat of the this change.
To make you want to look at the docs, here’s a few examples:
' Two beats, one making 40 pulses per second, one making 2.
' Note that they do drift out of phase because there are 40 NEXT/second
' vs two NEXT/second, and those cost the first loop 40/sample_rate()ths of a second
' every second.
' Not sure how to address this.
for i = 0 to 39
out1 = 2
wait 10
out1 = 0
wait 15 - 1000 / sample_rate()
next
also
for i = 0 to 1
out2 = -2
wait 10
out2 = 0
wait 490 - 1000 / sample_rate()
next
end also
WHEN START()
a[0] = { -1, 3, -3, 1, 2, -2, 5, -4 }
for b = 0 to 7
c[b] = sin(a[b])
next
END WHEN
ALSO
for loop = 0 to 7
out1 = a[loop]
out2 = c[loop]
wait 1
next
END ALSO
' A trigger to IN9 resets the speed the notes are played.
FOR n = 0 TO 3
out1 = note[n]
WAIT pause_length
NEXT
WHEN start() or trigger(in9)
note[0] = { c3, g3, c4, c4 } ' The notes in my score.
pause_length = random(100, 1000) ' How fast we play the notes.
RESET ' Force main block to restart now
END WHEN
@k-chaffin, what you’ve been asking for is now:
WHEN trigger(in9)
RESET
END WHEN
Love to hear what you all think.
Mahlen