SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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]
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Kürzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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