http://www.slideshare.net/invalidname/core-midi-and-friends
 
 
 
 
 
 
 

31 of 31

 
 

Core MIDI and Friends

8,215 views
  • Share
  • Like

Chris Adamson

, Developer, Author at Subsequently and Furthermore, Inc.

 0  1  0

Published on Nov 7, 2011

CocoaHeads Ann Arbor presentation on handling MIDI events in Mac OS X and iOS

...
1 Comment
5 Likes
Statistics
Notes
  • Ben Smiley

    I've written a series of compreshensive CoreMidi tutorials at: http://www.deluge.co/?q=all-things-midi

    4 years ago

Core MIDI and Friends

  1. 1. CoreMIDI and FriendsChris Adamson, CocoaHeads Ann Arbor Sept. 8, 2011
  2. 2.Road Map• MIDI basics• MIDI APIs on OSX• MIDI APIs on iOS
  3. 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. 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. 5.MIDI MessagesSTATUS DATA 1 DATA 2
  6. 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 yearshttp://www.midi.org/techspecs/midimessages.php
  7. 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. 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. 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. 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. 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. 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. 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. 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;
  15. 15.Now What?
  16. 16.Instrument Units• Audio Units that generate sound in response to MIDI events • kAudioUnitType_MusicDevice• Do not currently exist on iOS
  17. 17.Instrument to audio H/W I/O Unit Unit AU Graph
  18. 18.Instrument to audio H/W Effect Unit I/O Unit Unit AU Graph
  19. 19.Instrument to audio H/W I/O Unit Unit AU Graph
  20. 20.Mu si cD ev ic eM ID IE ve nt () Instrument to audio H/W I/O Unit Unit AU Graph
  21. 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. 22.Demo
  23. 23.MIDI on iOS• Core MIDI added in iOS 4.2• Device connectivity is via dock port • Custom hardware • iPad Camera Connection Kit
  24. 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. 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. 26.Demo
  27. 27.Demo
  28. 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. 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. 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. 31.Also, you should buy my bookhttp://www.mypearsonstore.com/bookstore/product.asp?isbn=9780321636843 http://my.safaribooksonline.com/9780321636973 http://www.informit.com/promotions/promotion.aspx?promo=137039

Core MIDI and Friends的更多相关文章

  1. 使用Core Audio实现VoIP通用音频模块

    最近一直在做iOS音频技术相关的项目,由于单项直播SDK,互动直播SDK(iOS/Mac),短视频SDK,都会用到音频技术,因此在这里收集三个SDK的音频技术需求,开发一个通用的音频模块用于三个SDK ...

  2. iOS开发:iOS的整体架构以及API介绍

    iOS的整体架构分为4层——Cocoa Touch层.Media层.Core Services层和Core OS层,下面概要介绍一下这4层. Cocoa Touch:构建iOS应用的一些基本系统服务, ...

  3. 音频 API 一览

    iOS 和 OS X 平台都有一系列操作音频的 API,其中涵盖了从低到高的全部层级.随着时间的推移.平台的增长以及改变,不同 API 的数量可以说有着非常巨大的变化.本文对当前可以使用的 API 以 ...

  4. Windows 10 的音频和 MIDI API将统一

    微软一统 Windows 10 的音频和 MIDI API 微软在夏季NAMM上的A3E大会上做了主题演讲,他们对Windows 10的音频和MIDI API都做了新的规划,开发者针对Windows ...

  5. 【Win 10 应用开发】MIDI 音乐合成——更改乐器音色

    在开始今天的吹 BB 博文之前,说点题外话. 首先,上次老周给大伙伴们介绍完发送 MIDI 音符,本来说好的接着说一下如何更改乐器音色,为啥这么久都没更新呢.特特来解释一下,最近老周接了一个 ASP. ...

  6. 用 Lua 控制 MIDI 合成器来播放自定义格式乐谱

    用 Lua 控制 MIDI 合成器来播放自定义格式乐谱 作者: FreeBlues 最新: https://www.cnblogs.com/freeblues/p/9936844.html 说明: 本 ...

  7. ASP.NET Core 之 Identity 入门(一)

    前言 在 ASP.NET Core 中,仍然沿用了 ASP.NET里面的 Identity 组件库,负责对用户的身份进行认证,总体来说的话,没有MVC 5 里面那么复杂,因为在MVC 5里面引入了OW ...

  8. .NET Core中的认证管理解析

    .NET Core中的认证管理解析 0x00 问题来源 在新建.NET Core的Web项目时选择“使用个人用户账户”就可以创建一个带有用户和权限管理的项目,已经准备好了用户注册.登录等很多页面,也可 ...

  9. ASP.NET Core 中的那些认证中间件及一些重要知识点

    前言 在读这篇文章之间,建议先看一下我的 ASP.NET Core 之 Identity 入门系列(一,二,三)奠定一下基础. 有关于 Authentication 的知识太广,所以本篇介绍几个在 A ...

随机推荐

  1. uva 12549

    12549 - Sentry Robots Time limit: 1.000 seconds We need to guard a set of points of interest using s ...

  2. 关于不断刷新界面jsp+ajax

    jsp主要就是用之前的jsonArray读取 ajax可以设置个定时器,然后设置的方法,至于方法是今天学习到的 function ajax(method,data,url,success){ var ...

  3. V-MODEL指令实现方法

    V-MODEL 是VUE 的一个指令,在input 控件上使用时,可以实现双向绑定. 通过看文档,发现他不过是一个语法糖. 实际是通过下面的代码来实现的:   <%@ page language ...

  4. 【思路】-jscode

    jscode             //1.0 思路             //VH.PutSet(TagFields.PageName, PageName.Index);             ...

  5. 在Heroku上,安装Wordpress

    其實在 Heroku 上安裝 Wordpress 不會很難,不過閱讀之前,你可能先要知道 Heroku 與 git 的基本操作,建議可以先參考以下網站用 Heroku 架設 Wordpress 網站 ...

  6. 数据中心第三方服务、金融IT外包服务、社保医疗信息化解决方案,这三类业务是什么关系,区别在哪?

    这个话题很大,牵扯很多,试着回答一下,算是胡扯了. 三类业务的关系,都是IT外包,至于外包的内容很杂.DC的外包,多半是基建和建维,一般不牵扯到软件开发,网站建设类的.金融IT外包就复杂多了,信息系统 ...

  7. (DFS、全排列)POJ-3187 Backward Digit Sums

    题目地址 简要题意: 输入两个数n和m,分别表示给你1--n这些整数,将他们按一定顺序摆成一行,按照杨辉三角的计算方式进行求和,求使他们求到最后时结果等于m的排列中字典序最小的一种. 思路分析: 不难 ...

  8. SQL疑难问题

    最近,遇到并解决一个SQL上的疑难问题.考勤系统,记录着员工进出公司的刷卡记录.而员工刷卡并不规范,存在刷多次的情况.例如:出去时连续刷多次,进来时也连续刷多次.筛选有效刷卡记录数据的规则:对于出去时 ...

  9. win7 64 位 tomcat 定时重启脚本

    添加进任务计划即可 net stop "scm"                                           [停止服务] rd /s /q D:\tomc ...

  10. 场景7 Data Guard

    场景7  Data Guard 官方文档 :Oracle Data Guard Concepts and Administration 用于数据容灾,通过主备库同步(主库将redo日志传送到备库,一个 ...