Git Product home page Git Product logo

Comments (10)

orchetect avatar orchetect commented on June 24, 2024 1

UI abstraction doesn't belong in the library, however if you're using SwiftUI then the following conform to Identifiable and can be used to populate lists or menus and will auto-update in realtime if endpoints are added or removed in the system (this is currently demonstrated in the MIDISystemInfo example project):

  • MIDI.IO.Manager
    • .devices.devices
    • .endpoints.inputs
    • .endpoints.outputs

from midikit.

orchetect avatar orchetect commented on June 24, 2024 1

However - an example project could be built that creates a menu showing best practices. I'll add it to the to-do list.

from midikit.

orchetect avatar orchetect commented on June 24, 2024 1

FYI - the best way to reference/identify endpoints is by their unique ID number, since it's possible for multiple endpoints to have identical names. These ID numbers should remain fairly stable between system restarts and not change. It's possible they can change but it's rare.

So when building menus, it's good to tag each menu item with the corresponding endpoint's unique ID.

Or if storing a reference to an endpoint for later use (ie: in UserDefaults because you want to re-connect to that endpoint the next time the app is launched, for example), store the unique ID and use that when connecting to it.

from midikit.

orchetect avatar orchetect commented on June 24, 2024 1

I am building foundational examples and have a few built so far. I have a bit of time now and I will cover the menu building examples in the next day or so.

from midikit.

orchetect avatar orchetect commented on June 24, 2024 1

@elmcapp @mikeHarris85

It took quite a while but I got a thorough and complete macOS AppKit example of MIDI input and output menus.

  1. The menus are updated in real-time if endpoints change in the system.
  2. The menus allow for a single endpoint to be selected, or None may be selected to disable the connection.
  3. The menu selections and connections are stored in UserDefaults and restored on app relaunch so the user's selections are remembered.
  4. If a selected endpoint no longer exists in the system, it will still remain selected in the menu but will gain a caution symbol showing that it's missing. If the endpoint reappears in the system, it will automatically reconnect and resume data flow and the menu item will once again appear as a normal selection.
  5. Received events are logged the console, and test events can be sent to the MIDI Out selection using the buttons in the window.

https://github.com/orchetect/MIDIKit/tree/main/Examples/macOS%20AppKit/EndpointMenus

I will work on additional examples as time allows. I'd like to do a variation that uses Combo box controls in a view instead of top-level menus. And I would like to do a SwiftUI version (which will be much easier - AppKit requires a lengthy amount of code to get this all to work).

This is, incidentally, one of the more complex parts of MIDI so it's a good thing to have well-written examples for.

from midikit.

elmcapp avatar elmcapp commented on June 24, 2024 1

Sounds and looks great. If I may suggest it could be useful to add the features 1-5 in a readMe file inside the Xcode project. This way when someone looks at the examples they will know what all the example will do

from midikit.

mikeHarris85 avatar mikeHarris85 commented on June 24, 2024

Great ideal. I am coming from audioKit to this solution because I only need midi.
@orchetect Yes as @elmcapp can you please provide an example to creating menu item that would show list of inputs and another menu that show list of outputs. This would give us a better understanding of how to create menus using the resource.

I picture to see a menu include in the application main menu. Check out the picture below. Of course not with Chrome but with the application we are designing.
Screen Shot 2022-06-07 at 3 00 43 PM

from midikit.

orchetect avatar orchetect commented on June 24, 2024

... add [...] a readMe file inside the Xcode project

Yes, good point. I was going to add summary README files for the projects but haven't gotten there yet. Some of the examples are simple enough that a few text labels in the example's GUI can communicate what is going on. But for more complex examples I will definitely add a README to explain the logic flow and principles. I can add this one now.

from midikit.

orchetect avatar orchetect commented on June 24, 2024

Also added SwiftUI examples demonstrating this.

from midikit.

orchetect avatar orchetect commented on June 24, 2024

macOS AppKit/SwiftUI and iOS SwiftUI menu examples are done. Just need to add one for iOS UIKit.

(The macOS SwiftUI example needs refactoring so that it is more in line with the iOS SwiftUI one which is on my to-do list to do soon - SwiftUI is very tricky because async escaping closures (ie: receiving MIDI events) aren't allowed to mutate anything in views because they are structs, so it requires some clean abstraction).

READMEs have been added for all examples in the repo as well.

from midikit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.