SlideShare a Scribd company logo
1 of 31
CoreMIDI and Friends
Chris Adamson, CocoaHeads Ann Arbor
            Sept. 8, 2011
Road Map


• MIDI basics
• MIDI APIs on OSX
• MIDI APIs on iOS
MIDI Basics

• MIDI = Musical Instrument Digital Interface
  • Circa 1982!
• Sends messages between devices, not sounds
  • Notes to play (pitch, impact, vibrato), patch
    selection, timing synchronization, etc.
MIDI Terms

• Device — participant in a MIDI network
• Endpoint — one connection into or out of a
 device

• Source — endpoint that sends data
• Destination — endpoint that receives data
MIDI Messages


STATUS   DATA 1   DATA 2
MIDI Messages

• Channel Voice Messages — Note On, Note
  Off, After-touch, Pitch wheel

  • High nybble of status is command, low
    nybble is channel number

• Channel Mode, System Messages
• Various extensions to the spec over the years
http://www.midi.org/techspecs/midimessages.php
MIDI APIs on OSX
• CoreMIDI — Implementation of MIDI
 messaging

• Instrument Units — Audio Units that generate
 sound in response to MIDI events

• Music Device — Sends commands to
 Instrument Units

• Music Sequence / Music Player — Plays MIDI
 (.mid) files
Core MIDI


• C-based API in Audio Toolbox
  • Largely similar to other Core Audio APIs
  • Uses Core Foundation opaque types,
    memory management, etc.
Core MIDI Types

• MIDIClientRef — Holds state for your MIDI
 session

• MIDIDeviceRef — A device (real or virtual)
 with “entities” (MIDIEntityRef), which are
 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 you
    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;
Now What?
Instrument Units


• Audio Units that generate sound in response to
 MIDI events

  • kAudioUnitType_MusicDevice
• Do not currently 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
 header file

  • Only 4 functions
  • MusicDeviceMIDIEvent() sends status,
    data1, data2 to a MusicDeviceComponent
    (i.e., an instrument Audio Unit)
Demo
MIDI on iOS


• Core MIDI added in iOS 4.2
• Device connectivity is via dock port
  • Custom hardware
  • iPad Camera Connection Kit
MIDI via the CCK
• MIDI-to-USB adapters semi-officially blessed
 by Apple

  • Adapter must be USB MIDI Class-
    compliant (i.e., doesn’t need drivers)

  • Bus-powered devices may not 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, etc.
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
   like other instrument units
AUSampler
• Configuration is a huge hassle
  • Huge and tota!y undocumented hassle
  • Build an .aupreset with AU Lab utility, or
    load DLS bank or SoundFont 2 files, or
    provide your own files

  • See WWDC Session 411 (“Music in iOS
    and MacOSX”), then file documentation
    bugs against absence of sample code
In Summary
• Musicians love MIDI. Devices are cheap and
 plentiful

• OSX and iOS love media, MIDI included
  • By comparison, Android has crap MIDI
    support (no javax.sound.midi, just .mid file
    support in android.media.JetPlayer)

• If you’re doing Mac or iOS media apps, you
 should consider supporting MIDI device I/O
Also, you should buy my book




http://www.mypearsonstore.com/bookstore/product.asp?isbn=9780321636843
             http://my.safaribooksonline.com/9780321636973
        http://www.informit.com/promotions/promotion.aspx?promo=137039

More Related Content

What's hot

The Next-Gen Dynamic Sound System of Killzone Shadow Fall
The Next-Gen Dynamic Sound System of Killzone Shadow FallThe Next-Gen Dynamic Sound System of Killzone Shadow Fall
The Next-Gen Dynamic Sound System of Killzone Shadow FallGuerrilla
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesTack Mobile
 
Why is EFL used on Tizen?
Why is EFL used on Tizen?Why is EFL used on Tizen?
Why is EFL used on Tizen?Ryo Jin
 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSLYoss Cohen
 
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten HaitzlerEFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten HaitzlerRyo Jin
 
Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Kore VM
 
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Maarten Balliauw
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embeddedtrx2001
 
XNA L06–Input, Audio and Video Playback
XNA L06–Input, Audio and Video PlaybackXNA L06–Input, Audio and Video Playback
XNA L06–Input, Audio and Video PlaybackMohammad Shaker
 
Hardware synth
Hardware synthHardware synth
Hardware synthHoward Mao
 
Connecting hardware up to ColdFusion
Connecting hardware up to ColdFusionConnecting hardware up to ColdFusion
Connecting hardware up to ColdFusionJustin Mclean
 

What's hot (13)

The Next-Gen Dynamic Sound System of Killzone Shadow Fall
The Next-Gen Dynamic Sound System of Killzone Shadow FallThe Next-Gen Dynamic Sound System of Killzone Shadow Fall
The Next-Gen Dynamic Sound System of Killzone Shadow Fall
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and Games
 
Why is EFL used on Tizen?
Why is EFL used on Tizen?Why is EFL used on Tizen?
Why is EFL used on Tizen?
 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
 
PiST/// Workshop
PiST/// WorkshopPiST/// Workshop
PiST/// Workshop
 
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten HaitzlerEFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
 
Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)
 
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embedded
 
XNA L06–Input, Audio and Video Playback
XNA L06–Input, Audio and Video PlaybackXNA L06–Input, Audio and Video Playback
XNA L06–Input, Audio and Video Playback
 
Philip polstra
Philip polstraPhilip polstra
Philip polstra
 
Hardware synth
Hardware synthHardware synth
Hardware synth
 
Connecting hardware up to ColdFusion
Connecting hardware up to ColdFusionConnecting hardware up to ColdFusion
Connecting hardware up to ColdFusion
 

Viewers also liked

Continuous Delivery in Ruby
Continuous Delivery in RubyContinuous Delivery in Ruby
Continuous Delivery in RubyBrian Guthrie
 
From One to Many: Evolving VPC Design (ARC401) | AWS re:Invent 2013
From One to Many:  Evolving VPC Design (ARC401) | AWS re:Invent 2013From One to Many:  Evolving VPC Design (ARC401) | AWS re:Invent 2013
From One to Many: Evolving VPC Design (ARC401) | AWS re:Invent 2013Amazon Web Services
 
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...CloudIDSummit
 
OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?Oliver Pfaff
 
Hadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job PerformanceHadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job PerformanceCloudera, Inc.
 
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014Amazon Web Services
 
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014Amazon Web Services
 
Digital digest //24.06.2016
Digital digest //24.06.2016Digital digest //24.06.2016
Digital digest //24.06.2016Digital Mind
 
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...Qualtrics
 
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망mosaicnet
 
Social Media Strategy DRAFT
Social Media Strategy DRAFTSocial Media Strategy DRAFT
Social Media Strategy DRAFTBeth Kanter
 
Apc's customised digital signage solutions
Apc's customised digital signage solutionsApc's customised digital signage solutions
Apc's customised digital signage solutionsAPC plc
 
[SJSU] Social Media Strategy
[SJSU] Social Media Strategy[SJSU] Social Media Strategy
[SJSU] Social Media Strategycgalvante
 
Ipsos MORI Political Monitor - August 2014
Ipsos MORI Political Monitor - August 2014Ipsos MORI Political Monitor - August 2014
Ipsos MORI Political Monitor - August 2014Ipsos UK
 
Вестник // Digital Blow Mind // Май 2016
Вестник // Digital Blow Mind // Май 2016Вестник // Digital Blow Mind // Май 2016
Вестник // Digital Blow Mind // Май 2016Digital Mind
 
8 3 giraldo anderson y jhon trejos
8 3 giraldo anderson y jhon trejos8 3 giraldo anderson y jhon trejos
8 3 giraldo anderson y jhon trejosjhonatanrulo
 
Box Office Best Practices [Webinar]
Box Office Best Practices [Webinar]Box Office Best Practices [Webinar]
Box Office Best Practices [Webinar]AudienceView
 

Viewers also liked (20)

Continuous Delivery in Ruby
Continuous Delivery in RubyContinuous Delivery in Ruby
Continuous Delivery in Ruby
 
From One to Many: Evolving VPC Design (ARC401) | AWS re:Invent 2013
From One to Many:  Evolving VPC Design (ARC401) | AWS re:Invent 2013From One to Many:  Evolving VPC Design (ARC401) | AWS re:Invent 2013
From One to Many: Evolving VPC Design (ARC401) | AWS re:Invent 2013
 
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...
CIS13: Bootcamp: Ping Identity OAuth and OpenID Connect In Action with PingFe...
 
OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?
 
Hadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job PerformanceHadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job Performance
 
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014
(APP304) AWS CloudFormation Best Practices | AWS re:Invent 2014
 
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
 
Digital digest //24.06.2016
Digital digest //24.06.2016Digital digest //24.06.2016
Digital digest //24.06.2016
 
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...
Internaliser et industrialiser ses études de satisfaction digitales - Qualtri...
 
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망
일본에 불어닥친 클라우드 컴퓨팅 열풍의 현황과 전망
 
2nd annual io t summit 2016 - Bangalore India
2nd annual io t summit 2016 - Bangalore India2nd annual io t summit 2016 - Bangalore India
2nd annual io t summit 2016 - Bangalore India
 
Social Media Strategy DRAFT
Social Media Strategy DRAFTSocial Media Strategy DRAFT
Social Media Strategy DRAFT
 
Apc's customised digital signage solutions
Apc's customised digital signage solutionsApc's customised digital signage solutions
Apc's customised digital signage solutions
 
Sesiones cs fuensanta 25 años
Sesiones cs fuensanta 25 añosSesiones cs fuensanta 25 años
Sesiones cs fuensanta 25 años
 
ประชุมชี้แจ้งกรอบวิจัย งบประมาณปี 2558
ประชุมชี้แจ้งกรอบวิจัย งบประมาณปี 2558ประชุมชี้แจ้งกรอบวิจัย งบประมาณปี 2558
ประชุมชี้แจ้งกรอบวิจัย งบประมาณปี 2558
 
[SJSU] Social Media Strategy
[SJSU] Social Media Strategy[SJSU] Social Media Strategy
[SJSU] Social Media Strategy
 
Ipsos MORI Political Monitor - August 2014
Ipsos MORI Political Monitor - August 2014Ipsos MORI Political Monitor - August 2014
Ipsos MORI Political Monitor - August 2014
 
Вестник // Digital Blow Mind // Май 2016
Вестник // Digital Blow Mind // Май 2016Вестник // Digital Blow Mind // Май 2016
Вестник // Digital Blow Mind // Май 2016
 
8 3 giraldo anderson y jhon trejos
8 3 giraldo anderson y jhon trejos8 3 giraldo anderson y jhon trejos
8 3 giraldo anderson y jhon trejos
 
Box Office Best Practices [Webinar]
Box Office Best Practices [Webinar]Box Office Best Practices [Webinar]
Box Office Best Practices [Webinar]
 

Similar to Core MIDI and Friends

Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Chris Adamson
 
Vst Virtual Studio Technology
Vst Virtual Studio TechnologyVst Virtual Studio Technology
Vst Virtual Studio TechnologyJonny Williams
 
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)Chris Adamson
 
Rloynd ig2 t1 ws
Rloynd ig2 t1 wsRloynd ig2 t1 ws
Rloynd ig2 t1 wsrosstapher
 
Michaelwilliamsig2task1worksheet
Michaelwilliamsig2task1worksheetMichaelwilliamsig2task1worksheet
Michaelwilliamsig2task1worksheetHooaax
 
Michael williamsig2task1worksheet
Michael williamsig2task1worksheetMichael williamsig2task1worksheet
Michael williamsig2task1worksheetHooaax
 
Methods and Principles of Sound Design and Production
Methods and Principles of Sound Design and ProductionMethods and Principles of Sound Design and Production
Methods and Principles of Sound Design and ProductionHooaax
 
Ig2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinIg2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinKalen612
 
Ig2 task 1 work sheet - JS
Ig2 task 1 work sheet - JSIg2 task 1 work sheet - JS
Ig2 task 1 work sheet - JSJamieShepherd
 
Audio devices, formats and codecs
Audio devices, formats and codecsAudio devices, formats and codecs
Audio devices, formats and codecscubitos98
 
Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378CallumDrakeCPFC
 
Simple User-Friendly MIDI Controller using Arduino.
Simple User-Friendly MIDI Controller using Arduino.Simple User-Friendly MIDI Controller using Arduino.
Simple User-Friendly MIDI Controller using Arduino.IRJET Journal
 
Ig2 task 1 no2
Ig2 task 1 no2Ig2 task 1 no2
Ig2 task 1 no2Kenyon101
 

Similar to Core MIDI and Friends (20)

Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
 
Vst Virtual Studio Technology
Vst Virtual Studio TechnologyVst Virtual Studio Technology
Vst Virtual Studio Technology
 
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
 
Rloynd ig2 t1 ws
Rloynd ig2 t1 wsRloynd ig2 t1 ws
Rloynd ig2 t1 ws
 
Michaelwilliamsig2task1worksheet
Michaelwilliamsig2task1worksheetMichaelwilliamsig2task1worksheet
Michaelwilliamsig2task1worksheet
 
Michael williamsig2task1worksheet
Michael williamsig2task1worksheetMichael williamsig2task1worksheet
Michael williamsig2task1worksheet
 
IG2 Task 1 Work Sheet
IG2 Task 1 Work SheetIG2 Task 1 Work Sheet
IG2 Task 1 Work Sheet
 
Methods and Principles of Sound Design and Production
Methods and Principles of Sound Design and ProductionMethods and Principles of Sound Design and Production
Methods and Principles of Sound Design and Production
 
Ig2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinIg2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martin
 
Ig2 task 1 iian
Ig2 task  1 iianIg2 task  1 iian
Ig2 task 1 iian
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Lecture 2.5 hardware
Lecture 2.5 hardwareLecture 2.5 hardware
Lecture 2.5 hardware
 
Ig2 task 1 work sheet - JS
Ig2 task 1 work sheet - JSIg2 task 1 work sheet - JS
Ig2 task 1 work sheet - JS
 
Audio devices, formats and codecs
Audio devices, formats and codecsAudio devices, formats and codecs
Audio devices, formats and codecs
 
Ig2
Ig2Ig2
Ig2
 
input devices
input devicesinput devices
input devices
 
Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378
 
Ig2 task 1
Ig2 task 1Ig2 task 1
Ig2 task 1
 
Simple User-Friendly MIDI Controller using Arduino.
Simple User-Friendly MIDI Controller using Arduino.Simple User-Friendly MIDI Controller using Arduino.
Simple User-Friendly MIDI Controller using Arduino.
 
Ig2 task 1 no2
Ig2 task 1 no2Ig2 task 1 no2
Ig2 task 1 no2
 

More from Chris Adamson

Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)Chris Adamson
 
Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)Chris Adamson
 
Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)Chris Adamson
 
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...Chris Adamson
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineChris Adamson
 
Forward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is FineForward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is FineChris Adamson
 
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...Chris Adamson
 
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Chris Adamson
 
Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Chris Adamson
 
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Chris Adamson
 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Chris Adamson
 
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Chris Adamson
 
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Chris Adamson
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Chris Adamson
 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Chris Adamson
 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasChris Adamson
 
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Chris Adamson
 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Chris Adamson
 
Introduction to the Roku SDK
Introduction to the Roku SDKIntroduction to the Roku SDK
Introduction to the Roku SDKChris Adamson
 

More from Chris Adamson (20)

Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
Whatever Happened to Visual Novel Anime? (AWA/Youmacon 2018)
 
Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)Whatever Happened to Visual Novel Anime? (JAFAX 2018)
Whatever Happened to Visual Novel Anime? (JAFAX 2018)
 
Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)Media Frameworks Versus Swift (Swift by Northwest, October 2017)
Media Frameworks Versus Swift (Swift by Northwest, October 2017)
 
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
Fall Premieres: Media Frameworks in iOS 11, macOS 10.13, and tvOS 11 (CocoaCo...
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
 
Forward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is FineForward Swift 2017: Media Frameworks and Swift: This Is Fine
Forward Swift 2017: Media Frameworks and Swift: This Is Fine
 
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
 
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
 
Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)
 
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
 
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
 
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014
 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las Vegas
 
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)
 
Stupid Video Tricks
Stupid Video TricksStupid Video Tricks
Stupid Video Tricks
 
Introduction to the Roku SDK
Introduction to the Roku SDKIntroduction to the Roku SDK
Introduction to the Roku SDK
 

Recently uploaded

Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Recently uploaded (20)

Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Core MIDI and Friends

  • 1. CoreMIDI and Friends Chris 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 • Notes to play (pitch, impact, vibrato), patch selection, timing synchronization, etc.
  • 4. MIDI Terms • Device — participant in a MIDI network • Endpoint — one connection into or out of a device • Source — endpoint that sends data • Destination — endpoint that receives data
  • 5. MIDI Messages STATUS DATA 1 DATA 2
  • 6. MIDI Messages • Channel Voice Messages — Note On, Note Off, After-touch, Pitch wheel • High nybble of status is command, low nybble is channel number • Channel Mode, System Messages • Various extensions to the spec over the years http://www.midi.org/techspecs/midimessages.php
  • 7. MIDI APIs on OSX • CoreMIDI — Implementation of MIDI messaging • Instrument Units — Audio Units that generate sound in response to MIDI events • Music Device — Sends commands to Instrument Units • Music Sequence / Music Player — Plays MIDI (.mid) files
  • 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 “entities” (MIDIEntityRef), which are logical sub-systems • MIDIEndPointRef — Source or destination • MIDIPortRef — An input or output port
  • 10. 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);
  • 11. 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); !}
  • 12. Read Proc • Callback function indicated by MIDIInputPortCreate() • Receives MIDIPacketList • numPackets and MIDIPacket[] • Receives user-info/context pointers that you set up in MIDIInputPortCreate() and MIDIPortConnectSource()
  • 13. 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
  • 14. 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;
  • 16. Instrument Units • Audio Units that generate sound in response to MIDI events • kAudioUnitType_MusicDevice • Do not currently exist on iOS
  • 17. Instrument to audio H/W I/O Unit Unit AU Graph
  • 18. Instrument to audio H/W Effect Unit I/O Unit Unit AU Graph
  • 19. Instrument to audio H/W I/O Unit Unit AU Graph
  • 20. Mu si cD ev ic eM ID IE ve nt () Instrument to audio H/W I/O Unit Unit AU Graph
  • 21. MusicDevice.h • Small API to deliver MIDI events to instrument units • Not in Xcode documentation. Check out the header file • Only 4 functions • MusicDeviceMIDIEvent() sends status, data1, data2 to a MusicDeviceComponent (i.e., an instrument Audio Unit)
  • 22. Demo
  • 23. MIDI on iOS • Core MIDI added in iOS 4.2 • Device connectivity is via dock port • Custom hardware • iPad Camera Connection Kit
  • 24. MIDI via the CCK • MIDI-to-USB adapters semi-officially blessed by Apple • Adapter must be USB MIDI Class- compliant (i.e., doesn’t need drivers) • Bus-powered devices may not work, due to low power supplied by iPad. Powered USB devices generally work. • http://iosmidi.com/devices/
  • 25. 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, etc.
  • 26. Demo
  • 27. Demo
  • 28. 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 like other instrument units
  • 29. AUSampler • Configuration is a huge hassle • Huge and tota!y undocumented hassle • Build an .aupreset with AU Lab utility, or load DLS bank or SoundFont 2 files, or provide your own files • See WWDC Session 411 (“Music in iOS and MacOSX”), then file documentation bugs against absence of sample code
  • 30. In Summary • Musicians love MIDI. Devices are cheap and plentiful • OSX and iOS love media, MIDI included • By comparison, Android has crap MIDI support (no javax.sound.midi, just .mid file support in android.media.JetPlayer) • If you’re doing Mac or iOS media apps, you should consider supporting MIDI device I/O
  • 31. Also, you should buy my book http://www.mypearsonstore.com/bookstore/product.asp?isbn=9780321636843 http://my.safaribooksonline.com/9780321636973 http://www.informit.com/promotions/promotion.aspx?promo=137039