chris-zen / coremidi

CoreMIDI library for Rust
https://chris-zen.github.io/coremidi/coremidi/
MIT License
75 stars 20 forks source link

Use the block crate and functions that take blocks instead of boxing callbacks. #31

Closed adamnemecek closed 2 years ago

adamnemecek commented 3 years ago

Hey Christian, you would be interested in a PR that adds the block crate and replaces calls to MIDIInputPortCreate with a call to MIDIInputPortCreateWithBlock and call to MIDIClientCreate with call to MIDIClientCreateWithBlock . It would make the codebase easier to understand. I just tried a basic proof of concept and it seems to work.

chris-zen commented 3 years ago

Hi @adamnemecek, sorry for the late response, I completely missed this issue. I'm wondering if you are still interested in this topic. If so, I see that you mention that code would be cleaner with it, are there any other advantages? What implications would it have for the clients of the API? Thanks

chris-zen commented 2 years ago

Hi @adamnemecek , I'm updating the crate to support MIDI 2, where using blocks as you suggested is the only way. I'm wondering if you could share your prototype with me, no matter in which state it is. I hope it reaches you on time 🙏

adamnemecek commented 2 years ago

It's been a while since I touched this but there's a crate called block which lets you use objective-c blocks from rust.

I think that this should work mostly

https://github.com/adamnemecek/wmidi_coremidi/blob/4c927e9cafd5ca59061a0a5c450827a61e29664f/src/midi_input.rs#L259

chris-zen commented 2 years ago

@adamnemecek I appreciate your time, thanks 😉

I have a working solution in #36 so I will close this issue.