Is there a method to force parallelization of code processing?
-
I am running into a problem with writing to an array from multiple incoming MIDI messages that arrive on the same sample.
Each note is being processed in serial through the entire note on callback code before moving on to the next.I have 5 note ons coming in at the same sample.
I am recording the note on numbers with
array.push()When I print out the contents of that array,
it looks like all of the notes are trying to write to the same index, sequentially, overwriting the 0 index, so that last note is the only one that appears in the index at that point:
It seems like the entire portion of code is being processed for each note before moving on to the next note, whereas I want all notes to be processed by each statement that ends in ";" before moving on to the next statement, therefore being able to write all 5 notes to indexes 0-4.
Is there a method to force parallelization of the MIDI message processing at each statement?
Here is a snippet of the problem:
HiseSnippet 1544.3oc6Z8taaaCDWJ1ZnRsancnXnejnXevYIHw1MooYYCMoINsFqtIHNsa.EEELRT1DQlTih1MYC8q6oXuK6UXOJ8MX6HkrsjsbhqQV+yfMPfCu+v63cG+cmTxgBtKIJhKLLcN97Phg4MrZdNS1d21XJyn9dFl2w5EbpKAU6rv.tGQfjjHIk0x3QmGhihHdFllEdrRZS6hF5Ou6gOBGfYtjgjLLz6xSocnxgTOb6ehFDrO1ibLsSJoWa65tb1t7.dWvyJXU1HD6dJtE4YXkXKXY7DbTaCyuyx0csMIOvu5FkqtIYcu0NoZkx3pk2byMH30K6dxlDbU+SbKaX9E07nRtnoDCG.CyhOh6cdy172vhMvKnQzSBHpEULZBVNl797.O0QTQ0X21z.uC6GxhLLLsNbX.rPb.71VMndzAzGFHuolAZnFoCflKj08Jjw8pj18Jmx8xwkLS4REicoaY0zUPCkC4n7mqaUmIIBeLjmR6JwxZX9WV6xAAXxU5fOkru.VLPgR2ub4kgeVbK+tLWIkyPb1y3RxArRK576N1Nu0AMJKe+b4orhfGDPD4xVUYHtHEKw514DhXYTObPWx.AgSe1Pp0jCooy3twG5TBxY0YT4AgD1jpCLRhTvu8756gkXUdHgFHWHQHoJWvbORO3VPbVw1ZORzoRdHbOXrTFTrv85FfkYqfT2yRX.wfLoMUtgEQkmm9d3nkUEmtxpKtpeZc2aYcHU51Ne+cgb7WHp8es+lbI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lcNcQ62t8SghMr.hSjYLVT48tWYt4q6XE6tH0EPzmufzE9+MH8Q7tp+Z+MvPQ3YvPAvSq1DvFcIf0YLRfZPAyET3awqKqVGCNx7zK9G3SByJp0lILqzm4ba7IlM5fcE7W6FOtn5N80zTfZDl9++BaqFp0nJF5QHSW22A5H7ZW2ra0XJVcVU7dyphqMqJt9rp38mUE2XVU7AWthpF16zUx6DCiYXz3vZ54uMMqwv.hfF8v3eIZNt3K
-
@VirtualVirgin said in Is there a method to force parallelization of code processing?:
MIDI messages that arrive on the same sample
How are you doing this?
-
@d-healey said in Is there a method to force parallelization of code processing?:
@VirtualVirgin said in Is there a method to force parallelization of code processing?:
MIDI messages that arrive on the same sample
How are you doing this?
In this case, there is a simple test harmonizer in the snippet here that generates 5 notes from 1 note. If you are going to suggest delaying each generated note by a successive sample, that is a no-go.
I am working on a voice exploder, which takes each note generated from any harmony input of 16 notes or less and sends each note to a different MIDI channel based on the sort method chosen.
Harmonizer plugins, and quantized notation software or DAWs will produce multiple notes for a chord at the same sample.
This particular utility I would like to build is to handle those use cases.
-
@VirtualVirgin You're printing the notes in a loop which could be part of the issue. Instead use the script watch table to monitor the values in the array in realtime, or use
Console.print(trace(myArr));
-
@d-healey said in Is there a method to force parallelization of code processing?:
@VirtualVirgin You're printing the notes in a loop which could be part of the issue. Instead use the script watch table to monitor the values in the array in realtime, or use
Console.print(trace(myArr));
I don't think so.
The print of the array length is outside of the loop, so the console should not be showing the print of the array length in between each print of the array contents.
It should show all 5 prints of the length at the very end of console, and each should read as "5".
(That is, if it were operating in parallel at each statement) -
@VirtualVirgin Can you make a minimal snippet that demonstrates this?
-
@VirtualVirgin this is not how MIDI works - as the MIDI Spec 1.0 makes very plain - MIDI is a serial protocol, so the notes must follow each other and cannot arrive at the same time....
-
@Lindon said in Is there a method to force parallelization of code processing?:
@VirtualVirgin this is not how MIDI works - as the MIDI Spec 1.0 makes very plain - MIDI is a serial protocol, so the notes must follow each other and cannot arrive at the same time....
I understand in theory the idea that that the MIDI messages are in serial.
If you generate notes for harmony, say using the Synth.addNoteOn() in HISE,
the order you generate them in the code will be the order they arise later on in a MIDI monitor, even if they are generated at the same sample. Note numbers generated out of sort order, say 74, 60, 77, will show up in the MIDI monitor later in that same order.But in practice, the way I see it, MIDI messages that occur within the same sample are in some ways handled as if happening at the same time because a timestamp will read the same for all notes at that sample, and cannot be distinguished from using that information. So for time ID purposes they are the same.
MIDI from quantized DAWs, notation software and plugins generating harmonies will therefore return a time delta of "0" between messages in those vertical stacks (chords).
So not technically "at the same time", but from an ID perspective certainly categorized as the "at the same time" (timestamp).
Anyway, my question arises from trying to figure out how to handle MIDI messages occurring on the same sample when they need processing with a quick turnaround.
I'm sure you know a bit about it. I'll have some more questions later. -
@VirtualVirgin said in Is there a method to force parallelization of code processing?:
but from an ID perspective
The event ID will always be unique.
-
@d-healey said in Is there a method to force parallelization of code processing?:
@VirtualVirgin said in Is there a method to force parallelization of code processing?:
but from an ID perspective
The event ID will always be unique.
"ID" here referring to the ID of the timestamp (0 samples difference), not the Event ID.
-
@VirtualVirgin I'm suggesting you use the event ID to avoid clashes in your array. A minimal snippet would really help to understand exactly what the issue is and find a solution.
-
@d-healey said in Is there a method to force parallelization of code processing?:
@VirtualVirgin I'm suggesting you use the event ID to avoid clashes in your array. A minimal snippet would really help to understand exactly what the issue is and find a solution.
Yes, I was thinking about using a combo of timestamp and Event ID for each note.
At the moment though my problem solving test has switched over to a different, but related conundrum. I'll put that in a different post in a few.
-
@VirtualVirgin said in Is there a method to force parallelization of code processing?:
@Lindon said in Is there a method to force parallelization of code processing?:
@VirtualVirgin this is not how MIDI works - as the MIDI Spec 1.0 makes very plain - MIDI is a serial protocol, so the notes must follow each other and cannot arrive at the same time....
I understand in theory the idea that that the MIDI messages are in serial.
If you generate notes for harmony, say using the Synth.addNoteOn() in HISE,
the order you generate them in the code will be the order they arise later on in a MIDI monitor, even if they are generated at the same sample. Note numbers generated out of sort order, say 74, 60, 77, will show up in the MIDI monitor later in that same order.But in practice, the way I see it, MIDI messages that occur within the same sample are in some ways handled as if happening at the same time because a timestamp will read the same for all notes at that sample, and cannot be distinguished from using that information. So for time ID purposes they are the same.
MIDI from quantized DAWs, notation software and plugins generating harmonies will therefore return a time delta of "0" between messages in those vertical stacks (chords).
So not technically "at the same time", but from an ID perspective certainly categorized as the "at the same time" (timestamp).
Anyway, my question arises from trying to figure out how to handle MIDI messages occurring on the same sample when they need processing with a quick turnaround.
I'm sure you know a bit about it. I'll have some more questions later.Yes, but no..... the MIDI spec says (if I remember correctly) that any receiving object needs only to act serially, so it can freely ignore the timestamp... so what you are doing is legal and accounted for - but no midi processor is required to process it in the same sample.... in fact given the laws of physics - they cant. - So it should come as no surprise when a midi processor of some sort (in this case HISE) doesnt behave the way you want.