Synth.isNote(eventID)
-
@d-healey said in Synth.isNote(eventID):
How does the user switch between mono mode and glide?
There are two independant buttons on the UI that turn these on and off.
-
@Lindon so they are never active at the same time?
-
@d-healey they can be active in any combination
0 0
0 1
1 0
1 1but in the end lets not get hung up on this example - what if I have 4 different MIDI Processors? what then?
-
@Lindon if only one is active at a time we don't have to worry about them interfering with each other.
If both are active at once how does the instrument decide whether it should play in mono mode or trigger a glide?
-
@d-healey said in Synth.isNote(eventID):
@Lindon if only one is active at a time we don't have to worry about them interfering with each other.
If both are active at once how does the instrument decide whether it should play in mono mode or trigger a glide?
As I say - let not get hung up on this example -- If both are active (and the glide is first) it plays the glide(s) - it even glides chords.... if its followed by the mono then it chokes down to a single (last played) note.
But as I say - this is just an example - what if I have a MIDI processor that acts based on Velocity - doing a bunch of stuff(including changing the velocity) to MIDI notes with a velocity over 100, and this processor is followed by another - which does something else - this second processor does something to every note (making it Artificial in every instance). Now the first processor doesn't know if its note has been "hijacked" by downstream processors....so it has no idea if it should be handling note off activities...
-
@Lindon I'm focusing on this example because each situation has a different solution and I'm trying to help you get your project working :) While a catch all solution to check active notes would be good, we don't have one, so I want to help you using the techniques that are available at the moment.
The velocity trigger issue you describe I have solved in my own project using a global variable. I put a script at the top of the chain to record the true velocity before it is changed by other scripts, this can then be picked up by the velocity filter script.
Another solution to the makeArtificial problem is to not use makeArtificial at all. Instead you generate brand new notes using
Synth.playNote()
, which solution to use depends on how your scripts interact with each other and which ones are active at a particular moment. -
A simple example might help:
HiseSnippet 2144.3oc6Z80aabbD+NIc1lLVFIAoA4wKDEAj05OGobbrirhojnjKg0eHDksKPPfwIdKIWni2xd2R0v5Jff7b+Bj7TeneI5SMuVf9P+fzGx2f1Y18NdKIORdlV1IswGhc39mYle6LyNyN65Z9rFjf.luldlS62knoeSi5883s2ssM0SqZEM8aYPCNhwI0a3S6x01oeW6f.hilt9hOBmidlkzDe+3C2w101qAItKMsmxnMHGP6P4w8Vq7iott6a6PNk1QY12ob0FLucYtrd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J0o8tZ+qq92U63FbP7Ct0CUFWmzgdJ30Gn14SBH66S98mfVY092kY6m3P+3C2GVjIRScadOeg6h7xVFx8XwTaSdIduukd6aseE97jYhvXcZmttjnKeVfw2GxZKBlN3FsGBkGx7Xcay7nMTM5mPfRsa0h3qh8DWPxBvi64CJeBwkXq5.+qKe.33Y6C5IxqGcgdJsWejQ3idfaFM+YUP8oYBeWigeRhWmFP3Lou0.9FMq7h+xLq7Irdbnp8CsAGU7zpPM50gjgMH.R77HtA3AWW.SnIaaEcz45P49hF+G3KbvhXa8vAKFM3+2HiN1M7YOugrPOb+xMD8.5VOw+j3xXbH11rXT8cFFVqYoAmul97FMPS5pE0zRllRyAMaLGzbm4flOcNn4tyAMe1bPy8lJM3IV1tGm0QtcG5n1dh5r002yyF1sH1Yo8eEXcueK
This is your mono script placed before my portamento script....
as you will see when on alone the porta script will glide happily single notes or chords...but add in the mono script, which does some NoteOff work, and the porta is left thinking that it needs to deal with notes that no longer exist...
-
I'll play around with this and see what I can come up with. Any reason you're using an array to store note IDs instead of a MIDIList?
-
@d-healey yep laziness
-
I found a redundant if statement.
if (Synth.isLegatoInterval()) { local dif = LastNote - Message.getNoteNumber(); if (AllKeys.getValue() == 1 && Synth.isLegatoInterval() == false)
The second
isLegatoInterval()
will never be false. This isn't part of the issue though.A quick fix to the error you're getting is to alter your port script's note off callback like so:
if (Message.isArtificial()) Synth.noteOffByEventId(tid);
You'll get some nice new hanging note issues to fix when the mono script is disabled :)
-
@d-healey said in Synth.isNote(eventID):
if (Message.isArtificial())
Synth.noteOffByEventId(tid);Thanks yeah the redundant if statement I know about - being lazy again...
So this sorta works - in that it fixes the problem if I check in the porta script if mono is running and handle each case slightly differently.
But this breaks all sorts of encapsulation guidelines I'd really like to keep to....
-
@Lindon so back to my first point/question(s)
any one know if this is do-able and would be willing to give it a shot?
-
@Lindon I think it's doable, but I think I'd need to rewrite the port script somewhat. Could you give me a breakdown of what the port script should do so I don't have to reverse engineer yours?
-
@d-healey yeah I mean give it a shot at adding in the C++ code to get us to
Synth.isNote(EventId);
-
@Lindon Oh I meant independent mono and poly scripts working in harmony was doable, I'm sure the
isNote
thing is doable too but not sure how to tackle it. -
@d-healey - thanks.
@Christoph-Hart - is there anything else we'd need other than what i outlined in the OP?
-
Yes, you will need another method in
EventIdHandler
:/** Checks whether the event ID points to an active artificial event. */ bool isArtificialEventId(uint16 eventId) const { return !artificialEvents[eventId % HISE_EVENT_ID_ARRAY_SIZE].isEmpty(); }
and call this instead of
popNoteOnFromEventId()
, because this method removes the event (hence the namepop...
).However this is a pretty shallow advice. I can't guarantee that there are no unwanted side effects, as the system of assigning artificial event IDs is pretty delicate (AFAIK you can't have multiple artificial notes with the same note number and channel for performance reasons)...
-
BTW, you can query if a note is already artificial and use that info in the second script:
HiseSnippet 794.3oc6VssaSCDDc2zXDIhhnB9.r5SIBnJtTtH3AZaRJJBRaDoTwaUasG2rp16ZYuNPTU+s36h+.XV63ZmV2aVphWXUjb14lOy3yryNJTZCQQxPBsw9yB.B8QFimITS5NgwEjA8HzGaLjEofPyTQaOKfEEANDJcoOoEPaTmjr98G2l4wD1PtHB4.I2F9B2mqxkNZyOy871g4.6y8KX8FaNvVJ5J8jwHdVxnCIfYeB6XXWl1rZFD5C56vUxvwJlBhPa1V5La7D4ODo1e.OhejGn2XQFiAJULo6DtmynrbMhPn0Gkm4Kkl4OyXH2get77JvSRTXl6QwZ.s1hPp9BPx5pfzNROGc.tB3Uq.7pmBuULFaGxCT4ZzX6oykliNqhvqVpVRseQMLciE1JtTXJE6JUvdhVsadZyFckhHoGrVPHWnZs5dByi.WYH7dyUMet4PLn3mf0NFT8mBB0.mVsa+gkaZhqLc9rSfsBUbWtMm40RqtjnxbQVzMGzlm07RH00sbn55dufULr2HXu.LwPnBkddPXJRufZMQubMycrkH1+HH7ElSYdwv4Fhe8Wjd071Quv9HEB0BFJECDb0dAv7VkLNPlDKx405hFkmWEkljNkXVtnKyoIcSwD9uuMnGSwPZNctLzt..+nnyPZOXJdlQJougQOH5DkL.O0nxcDquPCaVGg5V2QLFvxoy0SwZf+3tsxTyiJxwZmRAOM8gdcg2fTMAOfUJ.SdjICgzTX0Lh6YoO.uH3NEFt3xA5ZZs9Oe9eNeFmyHch8XpEG9nmxNWAVhWfKOP+1h3pYEmBeGlH0ozIRVkks2R3thwHtxdR43sVI3UOr6dFuymuurQeWWvVkC15F678pNL+N.kuJiUbwwCYpP9OITici8GiWwwFPjHDXiMJiVSynR22QuWWYFCBmjM+AWyUZo2SmqzJSIwmYGJOzNk1puAwCSjfXRjb4oF3s3v8lVjjFRzOiNq0g3iWr4Paaco3kH1K2m0qfOupB9rQE740Uvm2TAedaE74cWqO56TtUrR5m1lfBF0O4XDJsufgrrDFI4uPCl7HI
So your
Synth.isNote()
function can be written in HiseScript like this:// You don't need the event id, just make sure you never call this method // outside the `onNoteOn` / `onNoteOff` callbacks.. inline function isNote() { return Message.isArtificial(); }
-
@Christoph-Hart I'd like to add my vote to @Lindon's request. It appears that my plugins would benefit from it too :)
-
@d-healey many ways yes!