Re: concurrency of asynchronous events - input from multiple keyboards

2021-01-02 Thread Nathan Gray
On Fri, Jan 01, 2021 at 03:20:09PM -0500, Vadim Belman wrote: > As it seems that Audio::PortMIDI lacks non-blocking interface, I think a > solution would be to read events in a dedicated thread and re-submit them > into a Supplier. Something like: > > my Supplier $midi-events; > > start { >

Re: concurrency of asynchronous events - input from multiple keyboards

2021-01-01 Thread Brad Gilbert
I think the simplest way to turn that into a Supply is to use the `supply` keyword my $pm = Audio::PortMIDI.new; my $input = supply { my $stream = $pm.open-input($input-device-number, 32); DONE { $stream.close; } loop { emit

Re: concurrency of asynchronous events - input from multiple keyboards

2021-01-01 Thread Vadim Belman
As it seems that Audio::PortMIDI lacks non-blocking interface, I think a solution would be to read events in a dedicated thread and re-submit them into a Supplier. Something like: my Supplier $midi-events; start { loop { my $ev = $midi.read; $midi-events.emit: $ev; } }

concurrency of asynchronous events - input from multiple keyboards

2021-01-01 Thread Nathan Gray
I am working on a small virtual organ program, where I have multiple MIDI controller keyboards which can be connected to one or more synthesizer channels to emit various sounds simultaneously. At this point, I am able to read events from a single MIDI controller and send the events to the correct