Page 1 of 2

Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 3:14 am
by DSP-Robotron
I'm trying to switch oscillators based on ruby random function and it's working but the sounds are ignoring the envelopes or something. I end up with sounds being switched but the notes are sustaining for way too long and creating an overlapping mess and also overloading the CPU. Can anybody solve this bug or at least explain why the gate is not working for the ADSR ? Thanks.

out = rand(0..2)
output out, @in

That's the code so far. Randomize numbers between 0 and 2 and then send the midi input to the output that has that number. Simple. Right ? I guess not. Because it's not doing it 100% properly or something.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 3:38 am
by DSP-Robotron
This one works a bit better but it's only masking the problem.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 7:57 am
by martinvicanek
Try an ASIO driver instead of DS Out.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 8:43 am
by DSP-Robotron
Here is a more advanced version of it if you guys want it but it still needs way more tone generators.
At least 8 samples or tones per Arpeggiator.
Now it has 2 of those.
It's still very buggy somehow because the CPU load is 10 times higher than what is supposed to be.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 1:58 pm
by tulamide
I'm surprised that nobody answered you already!

When a note is played, two midi massages will be sent. One at the start (a Note On message) and one, when the note has to end (a Note Off message).

You currently re-route any incoming message to a random output, which means that the Note Off that belongs to the Note On you re-routed to output 2 may be sent to output 3. Sometimes, that's the nature of randomness, the Note Off message arrives at the correct output. The result being that it sometimes works and sometimes not.

What you have to do is keeping track of every Note On message and the output, you sent it to. Then, when a matching Note Off arrives, look up where it needs to be send, and send it there, bypassing the randomization.

Note On and Note Off are not the only midi messages that are grouped. You also have to be careful with pitchbend messages, polyphonic aftertouch, channel pressure and system exclusives.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 2:15 pm
by DSP-Robotron
That's a very good point but how can I make sure the signals go to the correct target ?
Isn't it possible to just send notes off messages to everything/everywhere at the end of every arpeggio cycle ?
That would guarantee a good reset of each cycle.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 2:29 pm
by martinvicanek
As Tulamide says (and Spogg in another thread), the Note Off messages may go to the wrong output. A quick dirty hack would be to route Note Off messages generaly to all outputs - it would do no harm except for the extra processing load. But then still the other problems in Tulamide's response would remain. To do it right you would need some bookkeeping...

If all you want is a random timbre for each new note, you could do the assignment in the poly section thus avoiding extra instances of MIDI/Voices prims, ADSR modules, etc. You would also not waste GUI real estate. ;)

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 2:50 pm
by DSP-Robotron
I have no idea how the poly section works yet. The polyphony was set at 32 when I only need 1 or 3. Maybe some simplified example file would work better. I only need sample switching at each step in the most efficient way because the CPU load is pretty high already and the sustaining notes keep accumulating until it crashes.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Wed Aug 19, 2020 5:23 pm
by DSP-Robotron
This version seems to work better but is not using the samplers.

Re: Ruby Script Midi Out Problem (For Random Output)

PostPosted: Thu Aug 20, 2020 12:59 am
by DSP-Robotron
Solved. I think.
I had to modify the Arp code but this version seems to work better.
Does anybody know how to make the Open button visible on the Wave Player ?
It's not allowing to load samples from the front panel.