Closed Levitanus closed 3 years ago
P.S. If I do something with rtmidi
(at least in its Python binding) — I would not use callback at all, but take messages from the queue one by one, but here I stunned...
I don't know how iced
works, but it looks wrong that you try to open the MIDI connection in every update
. You probably have to call connect
already in new
and not just store a MidiInput
in BigNote
, but rather a MidiInputConnection
.
You might also need to create a channel (https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html) to move the messages from the closure that you pass into connect
into the update
function (you can move the Sender
into the closure).
Thanks a lot! I'll try to investigate. Afraid, I cannot use connect in the new(), as later when gui is opened — the port will be chosen. But right now I try at least build it somehow).
Afraid, I cannot use connect in the new(), as later when gui is opened — the port will be chosen.
Then you have to store an Option<MidiInputConnection>
in your state, and call connect
only once when the port is chosen. Then store the resulting connection.
I've managed finally, thanks! https://github.com/hecrj/iced/issues/405
Great to hear!
I'm sorry for bothering here: I'm newbie in
rust
, but for the day I cannot figure out how to handlemidi_input
in my code:I try to use it inside
iced
application cycle, but, any attempts to get data from an opened connection ends with no possibility to get reference to the data, or pass self to the callback (which I can understand).