Roadmap for a MIDI Cocoa app

As a developer and Mac user new to swift, I cannot find a straightforward guide that will help me build an app on the Mac (**NOT iOS**) which reads MIDI input from a piano and provides feedback.


The CoreMIDI API doesn't seem to have any guides or examples, just the various classes and methods and transversely there doesn't seem to be much about CoreMIDI in the Apple guides and examples library (https://developer.apple.com/library/content/navigation/index.html#section=Platforms&topic=macOS).


I am a web developer so I already have a grasp of programming fundamentals and object orientation principals. I have been working my way around various Swift guides and documentation so I don't need to go over the basics of Xcode.


I don't yet fully understand a lot of the MIDI technology terminology or indeed the terminilogy used in the CoreMIDI API, but all I am trying to do for now is set something simple up like a callback that gives feedback when you play a note on a piano.


Can anyone provide me with a very rough idea/basic roadmap in plain English as to how to get started with this e.g.:


- Create a storyboard for your app

- Import the CoreMIDI framework by going to XYZ in XCode

- Create a new MIDI connection by doing XYZ

- Create a callback that displays the note played on the screen by doing XYZ


Thank you in advance!

Accepted Reply

This one deals specificqally with the callback:

h ttp://mattg411.com/swift-coremidi-callbacks/


and general app architecture using MIDI

h ttp://mattg411.com/coremidi-swift-programming/


Finally, this one, if others not enough

h ttp://www.rockhoppertech.com/blog/swift-2-and-coremidi/

Replies

You say :

I have been trying to find my way around various Swift guides and documentation and I don't need to go over basic programming principals like variables loops and functions, or the basics of Xcode.

You're wrong : you'll go nowhere (except copy existing code without understanding what's going on) without those basics. Don't hope you'll create any serious app without mastering those basics and more.


However, some answers to your questions

- Create a storyboard for your app

That's the very basic of XCode ; you should read some introdcutory tutorials on XCode, otherwise you'll rapidly get lost.

You can read Apple documentation on starting with XCode

to create a storyboard : launch XCode

Ask for New in file menu, select project

then select either OSX or IOS.

Storyboard will be created automatically when you ask to create project


- Import the CoreMIDI framework by going to XYZ in XCode

that's a declmaration at the beginning of the viewController file:

     import CoreMIDI


- Create a new MIDI connection by doing XYZ

- Create a callback that displays the note played on the screen by doing XYZ

have a look here:

h ttp://www.rockhoppertech.com/blog/swift-fail-midiclientcreate/

h ttps://stackoverflow.com/questions/26494434/using-midipacketlist-in-swift

h ttps://stackoverflow.com/questions/27416435/send-and-receive-midi-with-swift-and-coremidi

Hi Claude, I'm saying I don't need to go over the basics of Swift such as variables, functions, loops etc because being a web developer (PHP & JS) I already have a grasp on programming fundamentals and object oriented principals and I have already looked into - and am comfortable with - the Swift syntax.


I know the basics of Xcode and where most things are, like how to add UI elements, create outlets and actions etc etc I just don't know how to approach my problem because I'm unfamiliar with the CoreMIDI framework and it's terminology, therefore I don't know what 'steps' or methods are involved. I just wrote that bulleted list as an example so that whoever answered would be thorough and wouldn't skip over anything, which would help me and by the looks of things on the interweb, a whole lot of other people.


The main thing I am concerned with is getting to the point at which I can play a note on a MIDI device such as a piano and performing some sort of feedback - i.e. importing the necessary framework and then doing whatever is required to get a basic setup like 'create a new connection' and 'create a callback which prints out the note played' or whatever.


As you can see I know all these bits and bobs but I just don't have a clear roadmap.


Thanks

ok, sorry I totally misinterpreted your statement !


did you find something interesting in the 3 references I sent in previous post ?

Thanks but no, I think the first example is for iOS and the following two StackOverflow are either irrelevent, written in Objective-C or only describe output (I'm looking for input/callback).


I'm more really looking for a guide that describes in plain English the core steps involved in creating a project with a MIDI callback so that you can do something with the input.

This one deals specificqally with the callback:

h ttp://mattg411.com/swift-coremidi-callbacks/


and general app architecture using MIDI

h ttp://mattg411.com/coremidi-swift-programming/


Finally, this one, if others not enough

h ttp://www.rockhoppertech.com/blog/swift-2-and-coremidi/

Thanks again, I did actually try the matt4g example in a playground a few days ago, it just prints a thousand things a second without you even pressing anything on your MIDI device. I was going to use this as a fallback in case I couldn't find a guide that exaplains the various parts of CoreMIDI and how to do things properly from scratch, which is ideally what I'm looking for.


The Rockhoppertech and mattg411 examples are the closest that I have come to finding working examples of the CoreMIDI framework, but even they are unfortunately not very clear.


It seems mad how there is no guidance/example in the API. I've even thought about resorting to other third party frameworks like MIKMidi (from Made In Key) but even they say in their docs that it's useful to have a basic understanding of CoreMIDI.

Last try, from web resources.


h ttps://stackoverflow.com/questions/28924831/coremidi-callbacks-in-swift

Nice, thanks Claude. I have also done some digging and spoken to the creator of MIKMidi who was a huge help and sent me a MIDI example, which does the same thing that the mattg411 callback example above does whereby it just prints out a thousand things a second so I am assuming that this is normal and I just need to debug and inspect the incoming message in order to get my note played from there!


Thanks again Claude and for anyone else looking to make a start with this, try using MIKMidi framework here https://github.com/mixedinkey-opensource/MIKMIDI or the mattg411 examples page here http://mattg411.com/coremidi-swift-programming/