Http://www.slideshare.net/invalidname/core-midi-and-friends from Core MIDI and Friends8,215 views
Chris Adamson
, Developer, Author
at subsequently and Furthermore, Inc. Follow 0 1 0
Published on Nov 7, 2011
CocoaHeads Ann Arbor presentation on handling MIDI events in Mac OS X and iOS
...Published in:technology, entertainment & Humor
- 1 Comment
- 5 likes
- Statistics
- Notes
- Ben Smiley I ' ve written a series of compreshensive Coremidi tutorials At:http://www.deluge.co/?q=all-things-midi4 years ago
Core MIDI and Friends
- 1. Coremidi and Friendschris Adamson, cocoaheads Ann Arbor Sept. 8, 2011
- 2. Road Map MIDI Basics MIDI APIs on OSX MIDI APIs on IOS
- 3. MIDI Basics MIDI = Musical Instrument Digital interface circa 1982! sends messages between devices, not sounds no TES to play (pitch, impact, vibrato), patch selection, timing synchronization, etc.
- 4. MIDI terms device-participant in a MIDI network endpoint-one connection to or out of a device source-endpoin T that sends data destination-endpoint that receives data
- 5. MIDI messagesstatus Data 1 Data 2
- 6. MIDI Messages Channel Voice messages-note on, Note O, After-touch, Pitch Wheel High nybble of the status is command, Low nybble are channel number channel Mode, System messages various extensions to the spec over the Yearshttp://www.midi. org/techspecs/midimessages.php
- 7. MIDI APIs on OSX coremidi-implementation of MIDI messaging instrument units-audio Units, generate sound in Re Sponse to MIDI Events Music device-sends commands to instrument units music sequence/music player-plays MIDI (. mid )? Les
- 8. Core MIDI c-based API in Audio Toolbox largely similar to other core Audio APIs uses core Foundation opaque types, memory management, etc.
- 9. Core MIDI Types Midiclientref-holds state for your MIDI session MIDIDEVICEREF-A device (real or virtual) with "en Tities "(Midientityref), which is logical sub-systems Midiendpointref-source or destination Midiportref-an input or Output port
- Creating Client & Input port! Midiclientref client = null;! Midiclientcreate (Cfstr ("Core MIDI to System Sounds Demo"), Mymidinotifyproc, Self, &client);!! Midiportref InPort = null;! Midiinputportcreate (Client, Cfstr ("Input port"), Mymidireadproc, Self, &inport);
- Discovering and connecting sources!unsigned long Sourcecount = Midigetnumberofsources ();! for (int i = 0; i < Sourcecount; ++i) {!! Midiendpointref src = midigetsource (i);!! Cfstringref Endpointname = null;!! Osstatus nameerr = Midiobjectgetstringproperty (src, kmidipropertyname, &endpointname);!! if (NOERR = = nameerr) {!!! NSLog (@ "source%d:%@n", I, endpointname);!! }!! Midiportconnectsource (InPort, SRC, NULL);!}
- Read Proc callback function indicated by Midiinputportcreate () receives midipacketlist numpackets and MIDIPacket[ ] receives User-info/context pointers that's set up in Midiinputportcreate () and Midiportconnectsource ()
- Midipacket contains TimeStamp, length, and byte[] byte[] data is the MIDI message data[0]: status Data[1]: MIDI Data 1 Data[2] (if present): MIDI data 2
- Parsing a NOTE on message! Midipacket *packet = (Midipacket *) pktlist->packet;!! Byte Midicommand = packet->data[0] >> 4;! Is it a note-on?! if (Midicommand = = 0x09) {!! Byte Note = packet->data[1] & 0x7f;!! Byte velocity = packet->data[2] & 0x7F;
- What is now?
- Instrument units Audio Units, generate sound in response to MIDI events Kaudiounittype_musicdevice do not Curr ently exist on IOS
- Instrument to audio h/w I/O Unit unit AU Graph
- Instrument to Audio h/w Effect unit I/O Unit unit AU Graph
- Instrument to audio h/w I/O Unit unit AU Graph
- Mu si cD ev ic eM ID IE ve NT () Instrument to audio h/w I/O Unit unit AU Graph
- Musicdevice.h small API to deliver MIDI events to instrument units not in Xcode documentation. Check out the headers? Le only 4 functions musicdevicemidievent () sends status, DATA1, data2 to a musicdevicecomponent (i.e., an instrument Audio Unit)
- Demo
- All. MIDI on iOS core MIDI added in IOS 4.2 device connectivity are via dock port custom hardware ipad Camera connecti On Kit
- Midi via the CCK MIDI-TO-USB adapters semi-o?cially blessed by Apple adapter must be USB MIDI class-compliant (i.e ., doesn ' t need drivers) bus-powered devices may isn't work, due to low power supplied by IPad. Powered USB devices generally Work. http://iosmidi.com/devices/
- Playing sounds on iOS no instrument units on IOS. Options: synthesize your own with a render callback play sampled sounds with Audio Queue, AV Player, System sounds, et C.
- Demo
- Demo
- Ausampler New Instrument Audio Unit in Lion ... and ... takes a sampled waveform and pitch-shifts it to make it into an Instrument call with musicdevicemidievent (), just as other instrument units
- Ausampler Con?guration is a huge hassle huge and tota!y undocumented hassle build an. Aupreset with AU Lab utilit Y, or Load DLS bank or SoundFont 2 les, or provide your own? Les see WWDC Session 411 ("Music in IOS and MacOSX"), then ? Le documentation bugs against absence of sample code
- Summary musicians love MIDI. Devices is cheap and plentiful osx and IOS love Media, midi included by comparison, Android have crap midi support (no Javax.sound.midi, just. Mid le Support in android.media.JetPlayer) if you ' re doing Mac or IOS media apps, you should con Sider supporting MIDI device I/O
- Also, you should buy my bookhttp://www.mypearsonstore.com/bookstore/product.asp?isbn=9780321636843 http:// my.safaribooksonline.com/9780321636973 http://www.informit.com/promotions/promotion.aspx?promo=137039
Core MIDI and Friends