zl.stream help

M K's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is probably a stupid question, but why isn't multiple notes showing up in the message, when more than one note are held down?

mattyo's icon

Three things to remember:
1. Only one thing ever happens at a time
2. note numbers are not continuously output
3. zl objects do not keep a list in memory once they have dumped it out

Think of it step by step

-- hold down note 1
-- pitchval goes to pipe (1 value)
-- number of notes held down (1) goes to zl stream
-- pitchval goes to zl.stream
-- number of notes held down == number of note numbers in zl.stream, so first note value outputs

-- Hold down note 2
-- pitchval goes to pipe (1 value)
-- -- number of notes held down (2) goes to pipe
-- pitchvalr goes to zl.stream
-- number of notes held down (2) < number of note numbers in zl.stream, so nothing happens

/M

M K's icon

"— — number of notes held down (2) goes to pipe"

I don't understand this. Number of notes isn't connected to the pipe?

mattyo's icon

Typo, sorry.

the point is that Borax only outputs the last note played. Once the first note is output, when the list length is 1, the number of events accumulated in the zl.stream will always be one less than the listlength you're setting. If what you want is a list of all held notes every time you play one, you will need to store the notes somewhere, and maintain their played/off state. There's probably a more elegant way to do this, as I'm still having my coffee, but look at the example below.

Max Patch
Copy patch and select New From Clipboard in Max.

\M

M K's icon

very helpful! thanks!

mattyo's icon

No problem.