Core MIDI and Friends

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.

Follow

0  1  0

Published on Nov 7, 2011

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

...

Published in: TechnologyEntertainment & Humor

1 Comment
5 Likes
Statistics
Notes

Post

  • 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 O?, 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) ?les
  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 ?le • 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-o?cially 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• Con?guration is a huge hassle • Huge and tota!y undocumented hassle • Build an .aupreset with AU Lab utility, or load DLS bank or SoundFont 2 ?les, or provide your own ?les • See WWDC Session 411 (“Music in iOS and MacOSX”), then ?le documentation bugs against absence of sample code
  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 ?le 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
时间: 2024-12-18 12:03:22

Core MIDI and Friends的相关文章

iOS API 概述

原文:http://www.bubuko.com/infodetail-650437.html iOS API简介 转自:http://book.2cto.com/201307/27019.html 苹果的iOS API在不同版本间有很多变化,本书采用的是iOS 6.本节中,我们会介绍iOS 6有哪些API,如何使用这些API的帮助文档以及如何使用官方案例.2.6.1 API概述iOS的整体架构图如图2-40所示,分为4层——Cocoa Touch层.Media层.Core Services层和

iOS音频视频开发起始点

Audio & Video Starting Point Multimedia technologies in iOS let you access the sophisticated audio and video capabilities of iPhone, iPad, and iPod touch. Specialized classes let you easily add basic features such as iPod library playback and movie c

Windows 10 的音频和 MIDI API将统一

微软一统 Windows 10 的音频和 MIDI API 微软在夏季NAMM上的A3E大会上做了主题演讲,他们对Windows 10的音频和MIDI API都做了新的规划,开发者针对Windows 10开发的应用在手机.平板.桌面电脑.Raspberry Pi 2上也可以运行. 微软之前在音频方面一直是很低调,或者说没怎么关心过音频开发者们,这次Windows 10突然高调起来,在Windows 10里有很多针对音频和MIDI方面的改进: MIDI API:所有Windows 10设备都支持,

AOSON mini5 MT6592 Octa Core 1.7GHz 2G 16G Android 4.4 13MP Camera GPS 7.9 Inch 2048*1536 Tablet PC

Product Description Aoson Mini5 Android Phablet 2GB RAM 16GB ROM IPS FHD Screen 3G Smartphone Android 4.4 Octa Core Phone Call Tablet PC Highligts : CPU: MTK6592 Octa core; Metal body, Made by CNC, Unibody with Aviation aluminum; 7.9 inch Capacitive

.Net Core + Angular Cli 开发环境搭建

一.基础环境配置 1.安装VS 2017 v15.3或以上版本 2.安装VS Code最新版本 3.安装Node.js v6.9以上版本 4.重置全局npm源,修正为 淘宝的 NPM 镜像: npm install -g cnpm --registry=https://registry.npm.taobao.org 5.安装TypeScript cnpm install -g typescript typings 6.安装 AngularJS CLI cnpm install -g @angul

java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;问题

在springsecurity学习中,在加入spring有关的jar包后,出现java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment报错 出错原因:jar包版本有冲突 解决方法:换不同版本的jar包就可以解决问题了

ASP.NET Core中使用默认MVC路由

ASP.NET Core里Route这块的改动不大,只是一些用法上有了调整,提供了一些更加简洁的语法. 而对于自定义路由的支持当然也是没有问题的,这个功能应该是从MVC1.0版本就已经有这个功能. 先看看ASP.NET Core里面实现默认MVC路由的配置方式 通常情况下,在使用MVC项目的时候,默认的路由就足够了,就是常见的通过Controller和Action获取具体的方法的方式. 从一个最基本的项目开始,执行以下步骤,就可以使得项目支持MVC路由 1.创建一个空白的ASP.NET Core

NET Core项目定义Item Template

NET Core项目定义Item Template 作为这个星球上最强大的IDE,Visual Studio不仅仅提供了很多原生的特性,更重要的是它是一个可定制的IDE,比如自定义Project Template和Item Template就是一个非常有用的扩展点.这里我们主要关注Item Template,它时我们可以在"Add new Item"对话框中添加我们自定义的Item(如下图所示).如果不了解Item Template,Scott Gu的文章. 我们之前自定义了一些Ite

Asp.Net Core 项目实战之权限管理系统(7) 组织机构、角色、用户权限

0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之权限管理系统(2) 功能及实体设计 3 Asp.Net Core 项目实战之权限管理系统(3) 通过EntityFramework Core使用PostgreSQL 4 Asp.Net Core 项目实战之权限管理系统(4) 依赖注入.仓储.服务的多项目分层实现 5 Asp.Net Core 项目实