Page 2 of 3

Re: Mono display from a poly moduation source

PostPosted: Thu Mar 22, 2018 5:18 pm
by KG_is_back
tulamide wrote:
KG_is_back wrote:This could also be adapted to get the lowest voice ID, but I can't quite figure out how at the moment.

When doing 2^x, every voice id has its own bit, which would scream for bitwise logicals, no?


Yes, that is another way of interpreting it. However, it should theoretically work with any base, not just 2.

martinvicanek wrote:Since the Combiner prim works with floats, you have only 23 mantisa bits to work with. So you would need two floats to fully encode which of the 32 voices are active.

Yes that is true. However, in this example we do not care which voices are active. We only care for the highest voice aka the highest bit. When more than 23 voices are playing, the lower ones get rounded out in the floating point logic. We only care about the order (aka the exponent). The mantissa is irrelevant. I fact, the algorithm can be heavily optimized by simply not calculating the mantissa when doing the power and log functions. It would effectively boil down to two bitshifts, some bitmasking and float<->int conversion.

Re: Mono display from a poly moduation source

PostPosted: Thu Mar 22, 2018 5:41 pm
by adamszabo
Its such a coincidence that I am having a similar issue, even though I have a beta version with the "Min/Max Poly to Mono", which you can easily solve this problem, I am having an issue with it so I have to look for alternative methods. I had my own crazy hack method from a while back, I dont even remember how it works but it works ok. The point here is that we need to somehow get the ID of the very last key we pressed so we can grab 1 single channel even from a poly signal so we can use it for mono modulations or graphs or whatever. Now in a synth we also have to keep in mind that we could have unison enabled or long release times and when the voices run out the new notes that are being stolen have to act as the last key pressed.

I like the simplicity of Martins and KGs method but in my project I demonstrate that they dont work with stolen notes.

I have 2 unison enabled and a maximum of 6 voices so you can have a maximum of 3 different notes. The top code is mine, the middle is Martins and the bottom is KGs. To very easily see whats happening we will grab the latest pitch value from the poly voices, which will show in red in the channel readers. Now start pressing each key one by one, Q, W, E, R, T, Y, U, I etc... Mine repeats the correct channels and chooses the last key while the other seem to be missing a few. I actually dont really like my method its a bit complicated but maybe it gives some ideas as to how I think it should be!

Re: Mono display from a poly moduation source

PostPosted: Thu Mar 22, 2018 11:36 pm
by tulamide
KG_is_back wrote:
martinvicanek wrote:Since the Combiner prim works with floats, you have only 23 mantisa bits to work with. So you would need two floats to fully encode which of the 32 voices are active.

Yes that is true. However, in this example we do not care which voices are active. We only care for the highest voice aka the highest bit. When more than 23 voices are playing, the lower ones get rounded out in the floating point logic. We only care about the order (aka the exponent). The mantissa is irrelevant. I fact, the algorithm can be heavily optimized by simply not calculating the mantissa when doing the power and log functions. It would effectively boil down to two bitshifts, some bitmasking and float<->int conversion.

I think, Martin's answer was more headed towards me, to explain why 2^x simply as a bitmask for all IDs would fail with more than 23 voices. For your approach it indeed doesn't matter much.

Adam, your solution is very precise. When I read your descriptions, I instantly thought of somehow involving MIDI. And indeed you do so, which is very clever. I don't understand much from the modules, but the result is convincing!

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 7:39 am
by martinvicanek
Adam, it seems to me that the "missing notes" are blocked by the 6 voices limitation in the midi2poly settings. Your method captures those notes via the midi2mono bypass.
If you want to capture the last pressed key regadless whether the note has actually been played, why don't you go Ruby?

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 8:48 am
by Spogg
Another great solution Adam, and I couldn’t catch it out!

Thanks for sharing this and I’ll add it to the first post.

Cheers

Spogg

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 9:03 am
by adamszabo
martinvicanek wrote:If you want to capture the last pressed key regadless whether the note has actually been played, why don't you go Ruby?


Because I have no clue how I would do it in Ruby, I will leave that to the experts :lol:

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 1:45 pm
by martinvicanek
From the top of my head:
Code: Select all
def event i,v
   msg = v.to_array
   if msg.size == 4         # it is a channel message (as opposed to sysex)
      if msg[0] == 144      # note-on event
         output 0, msg[2]   # MIDI note number
      end
   end
end
Supply MIDI input
At the (integer) output 0 is the last struck MIDI note.

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 2:13 pm
by tulamide
martinvicanek wrote:From the top of my head:
Code: Select all
def event i,v
   msg = v.to_array
   if msg.size == 4         # it is a channel message (as opposed to sysex)
      if msg[0] == 144      # note-on event
         output 0, msg[2]   # MIDI note number
      end
   end
end
Supply MIDI input
At the (integer) output 0 is the last struck MIDI note.

Stop it, Martin! Now you're also a Ruby expert. That is so unfair! :mrgreen:
I love that you follow the conventions of writing Ruby code. However, this code is not sufficient. I made a few examples somewhere here on the forum (I'm not sure, but I think it was for Kortezzzz), that would do the trick. Here you don't take Note Off into account. Also, in Adam's original fsm you see that it captures the end of the playing note as given by the envelope (which you wouldn't capture with midi, even with note off)

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 3:14 pm
by martinvicanek
tulamide wrote:Now you're also a Ruby expert.

Far from that! Oh, I realize that Adam was asking for expert help, so it was inapropriate for me to repond. But I did leave a grace period of almost 5 hours! :lol:
Your remarks about Note Off and release are correct of course, I am aware. I thought the task was simply to extract the last keystroke. Obviosly it was not. I should probably shut up now. :roll:

Re: Mono display from a poly moduation source

PostPosted: Fri Mar 23, 2018 5:12 pm
by tulamide
martinvicanek wrote:
tulamide wrote:Now you're also a Ruby expert.

Far from that! Oh, I realize that Adam was asking for expert help, so it was inapropriate for me to repond. But I did leave a grace period of almost 5 hours! :lol:
Your remarks about Note Off and release are correct of course, I am aware. I thought the task was simply to extract the last keystroke. Obviosly it was not. I should probably shut up now. :roll:

I hope you didn't misunderstand me :oops:
I meant it, when I expressed my surprise. It was Ruby code, it was well written, and it was unexpected. So, my reaction was a positive one (and a bit of jealousy, because you seem to be a Hans Dampf in allen Gassen :ugeek: )

My text was not meant to demean you, in no effing way!!! Also, maybe it is what Adam looks for, he might not be interested in getting notified of note play being ended.

If you allow me, I would like to point out, that you don't need to exclude sysex data specifically. The format is different, and therefore the first entry of msg will be a string containing the sysex data. The comparison of a string with a number will never be true, so it won't affect the interpretation of the rest of the code.