SlideShare a Scribd company logo
1 of 53
Get on the Audiobus
Chris Adamson • @invalidname
CocoaConf Boston • October, 2013

Slides & code will be posted to the CocoaConf Glassboard,
and announced on my Twitter & app.net (@invalidname)
Roadmap
• How audio works on iOS
• What Audiobus is and how it connects apps
• Adopting Audiobus in your audio app
Audio on iOS
• Each app is responsible for its own audio
• No access to audio to/from other apps
• Apps use the Audio Session API to interact
with the system

• See also AVAudioSession in AV
Foundation
Audio Session
• Allows inspection of hardware properties

(sampling rate, hardware latencies) and
negotiation of access to system audio resources

• Audio “category” declares what your app does
with audio

• This affects things like whether you mix with
other apps’ audio, honor ring/silent, can play
in background, etc.
Audio Categories
• Ambient
• Solo Ambient
• Playback
• Record
• Play and Record
• Audio Processing
• Multi-Route
Audio Engines
• How your app interacts with audio

hardware, i.e., captures or produces sound

• OpenAL (play-out only)
• Audio Queue
• Audio Units
AURemoteIO
Bus 1: audio in
AURemoteIO

Bus 0: audio out
Mixing between apps

AURemoteIO

AURemoteIO
Mixing between apps

AURemoteIO

!

AURemoteIO
Every App is an Island
• Only awareness of other apps’ audio is
value of

kAudioSessionProperty_OtherAudioIsPlaying

property

• No access to what other apps are playing
audio, how loud it is, etc.
Which means…
• You can’t record audio from one app in
another app

• Production apps can’t specialize; have to
provide everything (instruments, filters/
effects, recording) that you’d ever need
Enter Audiobus
Audiobus
• Standalone app that coordinates inter-app
audio

• Currently on 50% off sale ($4.99)

• Only works with apps that adopt the
Audiobus API

• 300 and counting!
Demo
What Audiobus Is
• Audiobus is an app for users to coordinate
audio across supported apps

• User decides which apps are the inputs,
effects, and outputs
What Audiobus Isn’t
• Audiobus is not a general-purpose systemlevel audio capture (like Audio Hijack on
Mac)

• Audiobus cannot get audio from or send
audio to an arbitrary app

• Apps must adopt the Audiobus SDK and
register with the Audiobus website
How the heck does it
even work?
Considering that inter-app communication
is nearly impossible on iOS…
Secret Sauce!
• Audiobus began with MIDI “System Exclusive” (SysEx)
messages, defined as being arbitrary blobs of data
unique to a given MIDI device

• Originally meant for synths to exchange waveforms,
patches or other software/firmware upgrades, etc.

• MIDI messages available to all interested apps via Core
MIDI

• Later switched to Mach Ports, which Core MIDI is
implemented atop
Audiobus Concepts
• Apps take on roles based on their
relationship to Audiobus

• Inputs produce audio
• Outputs receive audio
• Filters receive from inputs and send to
outputs

• Points of connection are called ports
http://developer.audiob.us/doc/index.html
Basic Audiobus
Integration
• Decide if you’re an input, output, or filter
• Decide if you can work with the Remote
IO unit or Audiobus’ port API

• Adopt the Audiobus SDK to connect to
Audiobus at runtime

• Register at audiob.us
An Audiobus
Integration Case Study
Audiobus Web Radio
• Web Radio app developed as in-class exercise
for Thursday's all-day Core Audio class

• Will also be at CocoaConf Atlanta

• Uses Audio File Stream to receive packets of
MP3 and play them with Audio Queue

Packets
Packets
2
Packets

Packets
Packets
1

0
Packets
LPCM or GTFO
• Audiobus ports and AURemoteIO only

work with uncompressed LPCM audio

• Web radio app is dealing in MP3 or AAC
• Conversion to LPCM happens inside the
Audio Queue
Offline Queues

Packets
Packets
2
Packets

1
Packets

Packets
0
Packets

AURemoteIO

AudioQueueOfflineRender()
Libraries
• Download the Audiobus SDK from
developer.audiob.us

• Add libAudiobus.a and the Audiobus
headers to your project

• Add Accelerate, AudioToolbox,

QuartzCore, CoreGraphics, and Security
frameworks to your project
Enable background audio
• Add “audio” to the app’s “Required

Background Modes” if it’s not already
present

• All Audiobus-enabled apps must

participate in backgrounding, since they
must be able to keep running when
Audiobus is in foreground
Create a launch URL
scheme
• You must have a URL scheme for your app

that ends in “.audiobus” for Audiobus to be
able to launch you

• Add this to the target’s “URL Types”
Get Audiobus API key
• For apps registered with iTunes Connect,
submit your App Store URL or ID

• For unpublished apps or tinkering, register
for a temporary ID, good for 14 days

• This requires dropping the Info.plist from
your app bundle (not from project!)
Audiobus API Keys
• Audiobus app gets a master list of known
keys from a server every 30 minutes

• For temporary IDs, click the link from the

developer page on the device that you’re using
Audiobus on to register your App ID

• e.g., audiobus-registry://
developer.audiob.us/tempreg?t=0ff37
• The dev page can mail you the link
Set Audiobus-compatible
behaviors
• Audio Session category must be playback
or play-and-record

• Must also set the mix-with-others property
on the audio session

• Often do both these things in the
AppDelegate
UInt32 audioCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,

 
 
 
 
 
 sizeof(audioCategory),



 
 
 
 
 
 &audioCategory);


UInt32 allowMixing = YES;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategory
MixWithOthers,

 
 
 
 
 
 
 
 sizeof (allowMixing),


 
 
 
 
 
 
 
 &allowMixing);


Note: Audio Session is deprecated in iOS 7
Modern apps can use the AV Foundation equivalents
Setup Your App’s Audio
System
• Your app’s audio infrastructure needs to be up
and running before you connect to Audiobus

• If you’re going to send audio via the

ABAudioBusAudioUnitWrapper, you’ll need
to initialize your AURemoteIO

• For the web radio app, I send an

NSNotification once the player class starts
playing
Instantiate
ABAudiobusController
• ABAudiobusController is your app’s

connection to Audiobus; probably gets held
as a strong property somewhere

• init method takes the launch URL and your
API key

• Obviously, these must match what you
registered on audiob.us
self.audiobusController = [[ABAudiobusController alloc]

 
 
 
 

initWithAppLaunchURL:
[NSURL URLWithString:@"audiobuswebradio.audiobus://"]

 
 
 
 

apiKey:AUDIOBUS_API_KEY];
Create ABOutputPort
(and Audio Unit wrapper)
• ABOutputPort sends audio to Audiobus

(via ABOutputPortSendAudio() function)

• If you use a RemoteIO unit for your output,
the ABAudiobusAudioUnitWrapper will
make these calls for you
CCFViewController *vc =
(CCFViewController*) self.window.rootViewController;

ABOutputPort *output = [self.audiobusController

 
 
 
 
 addOutputPortNamed:@"Audio Output"


 
 
 
 
 title:NSLocalizedString(@"Main App Output", @"")];


self.audiobusAudioUnitWrapper = [[ABAudiobusAudioUnitWrapper alloc]

 
 
 
 
 initWithAudiobusController:self.audiobusController


 
 
 
 
 
 

audioUnit:vc.player.remoteIOUnit

 
 
 
 
 
 

output:output

 
 
 
 
 
 

input:nil];
Demo
Demo
Ports
• Apps that don’t use the Audio Unit

Wrapper use ports directly instead

• ABOutputPortSendAudio() for senders
(inputs and filters)

• Block-based callback or poll with

ABInputPortReceive() for receivers (filters
and outputs)
Filters & Outputs
• If you produce audio output based on input,
you need to tell the ABInputPort, so that
the signal isn’t doubled in Audiobus.
As for iOS 7…
iOS 7 Inter-App Audio
Sherlocked?
Embrace & Extend!
From: michael@audiob.us
Date: June 19, 2013
Subject: Important Information Regarding Audiobus, iOS 7 and Inter-App
Audio 


iOS 7 introduces many new features, including Apple’s own Inter-App
Audio framework which we’re planning to incorporate into Audiobus so you
don’t have to. For details and further discussion, we highly recommend
checking out our thread on the Apple developer forums:

https://devforums.apple.com/thread/191197
Closing Thoughts
• Audiobus is approachable for developers
already working at the Audio Unit level

• Adding Audiobus will get it seen by users

who’ve proven willing to pay for good apps
(we love music app users!)

• Future-proofed for iOS 7
Q&A
Slides & code will be posted to the CocoaConf Glassboard,
and announced on my Twitter & app.net (@invalidname)

More Related Content

What's hot

[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing
Alive Kuo
 
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Chris Adamson
 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Chris Adamson
 

What's hot (20)

Capturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV FoundationCapturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV Foundation
 
Core Audio Cranks It Up
Core Audio Cranks It UpCore Audio Cranks It Up
Core Audio Cranks It Up
 
Building Modern Audio Apps with AVAudioEngine
Building Modern Audio Apps with AVAudioEngineBuilding Modern Audio Apps with AVAudioEngine
Building Modern Audio Apps with AVAudioEngine
 
Understanding open max il
Understanding open max ilUnderstanding open max il
Understanding open max il
 
Introduction to AV Foundation
Introduction to AV FoundationIntroduction to AV Foundation
Introduction to AV Foundation
 
Mastering Media with AV Foundation
Mastering Media with AV FoundationMastering Media with AV Foundation
Mastering Media with AV Foundation
 
Composing and Editing Media with AV Foundation
Composing and Editing Media with AV FoundationComposing and Editing Media with AV Foundation
Composing and Editing Media with AV Foundation
 
Core audio
Core audioCore audio
Core audio
 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las Vegas
 
HTML5 Audio & Video
HTML5 Audio & VideoHTML5 Audio & Video
HTML5 Audio & Video
 
Master Video with AV Foundation
Master Video with AV FoundationMaster Video with AV Foundation
Master Video with AV Foundation
 
Managing Eclipse Preferences for Teams (EclipseCon 2011)
Managing Eclipse Preferences for Teams (EclipseCon 2011)Managing Eclipse Preferences for Teams (EclipseCon 2011)
Managing Eclipse Preferences for Teams (EclipseCon 2011)
 
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)
 
[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing
 
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started
 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
 
Real life-maf-2015
Real life-maf-2015Real life-maf-2015
Real life-maf-2015
 
5
55
5
 

Viewers also liked

Viewers also liked (7)

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...
 
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)
 
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)
 
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
Stupid Video TricksStupid Video Tricks
Stupid Video Tricks
 
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
 

Similar to Get On The Audiobus (CocoaConf Boston, October 2013)

Similar to Get On The Audiobus (CocoaConf Boston, October 2013) (20)

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)
 
Inter-process audio options on iOS
Inter-process audio options on iOSInter-process audio options on iOS
Inter-process audio options on iOS
 
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)
 
Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)
 
Podcasting
PodcastingPodcasting
Podcasting
 
Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017Habitat Workshop at Velocity London 2017
Habitat Workshop at Velocity London 2017
 
Appium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanAppium Overview - by Daniel Puterman
Appium Overview - by Daniel Puterman
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
 
Android Multimedia Player Project Presentation
Android Multimedia Player Project PresentationAndroid Multimedia Player Project Presentation
Android Multimedia Player Project Presentation
 
A Framework Driven Development
A Framework Driven DevelopmentA Framework Driven Development
A Framework Driven Development
 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
 
WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Cordova: APIs and instruments
Cordova: APIs and instrumentsCordova: APIs and instruments
Cordova: APIs and instruments
 
Apache Cordova
Apache CordovaApache Cordova
Apache Cordova
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker bud
 
CROSS-OS DEVELOPMENT PLATFORM ADVANTAGES
CROSS-OS DEVELOPMENT PLATFORM ADVANTAGESCROSS-OS DEVELOPMENT PLATFORM ADVANTAGES
CROSS-OS DEVELOPMENT PLATFORM ADVANTAGES
 
Kubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster SystemKubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster System
 
iPlayground: CarPlay and MFI Hearing Aids
iPlayground: CarPlay and MFI Hearing AidsiPlayground: CarPlay and MFI Hearing Aids
iPlayground: CarPlay and MFI Hearing Aids
 

More from Chris Adamson

Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
Chris Adamson
 

More from Chris Adamson (10)

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
 
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
 
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
 
Core Audio Intro (Detroit Mobile City 2013)
Core Audio Intro (Detroit Mobile City 2013)Core Audio Intro (Detroit Mobile City 2013)
Core Audio Intro (Detroit Mobile City 2013)
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
Core Audio in iOS 6 (CocoaConf Raleigh, Dec. '12)
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Get On The Audiobus (CocoaConf Boston, October 2013)

  • 1. Get on the Audiobus Chris Adamson • @invalidname CocoaConf Boston • October, 2013 Slides & code will be posted to the CocoaConf Glassboard, and announced on my Twitter & app.net (@invalidname)
  • 2.
  • 3. Roadmap • How audio works on iOS • What Audiobus is and how it connects apps • Adopting Audiobus in your audio app
  • 4. Audio on iOS • Each app is responsible for its own audio • No access to audio to/from other apps • Apps use the Audio Session API to interact with the system • See also AVAudioSession in AV Foundation
  • 5. Audio Session • Allows inspection of hardware properties (sampling rate, hardware latencies) and negotiation of access to system audio resources • Audio “category” declares what your app does with audio • This affects things like whether you mix with other apps’ audio, honor ring/silent, can play in background, etc.
  • 6. Audio Categories • Ambient • Solo Ambient • Playback • Record • Play and Record • Audio Processing • Multi-Route
  • 7. Audio Engines • How your app interacts with audio hardware, i.e., captures or produces sound • OpenAL (play-out only) • Audio Queue • Audio Units
  • 8. AURemoteIO Bus 1: audio in AURemoteIO Bus 0: audio out
  • 11. Every App is an Island • Only awareness of other apps’ audio is value of kAudioSessionProperty_OtherAudioIsPlaying property • No access to what other apps are playing audio, how loud it is, etc.
  • 12. Which means… • You can’t record audio from one app in another app • Production apps can’t specialize; have to provide everything (instruments, filters/ effects, recording) that you’d ever need
  • 14. Audiobus • Standalone app that coordinates inter-app audio • Currently on 50% off sale ($4.99) • Only works with apps that adopt the Audiobus API • 300 and counting!
  • 15. Demo
  • 16. What Audiobus Is • Audiobus is an app for users to coordinate audio across supported apps • User decides which apps are the inputs, effects, and outputs
  • 17. What Audiobus Isn’t • Audiobus is not a general-purpose systemlevel audio capture (like Audio Hijack on Mac) • Audiobus cannot get audio from or send audio to an arbitrary app • Apps must adopt the Audiobus SDK and register with the Audiobus website
  • 18. How the heck does it even work? Considering that inter-app communication is nearly impossible on iOS…
  • 19. Secret Sauce! • Audiobus began with MIDI “System Exclusive” (SysEx) messages, defined as being arbitrary blobs of data unique to a given MIDI device • Originally meant for synths to exchange waveforms, patches or other software/firmware upgrades, etc. • MIDI messages available to all interested apps via Core MIDI • Later switched to Mach Ports, which Core MIDI is implemented atop
  • 20. Audiobus Concepts • Apps take on roles based on their relationship to Audiobus • Inputs produce audio • Outputs receive audio • Filters receive from inputs and send to outputs • Points of connection are called ports
  • 22. Basic Audiobus Integration • Decide if you’re an input, output, or filter • Decide if you can work with the Remote IO unit or Audiobus’ port API • Adopt the Audiobus SDK to connect to Audiobus at runtime • Register at audiob.us
  • 24. Audiobus Web Radio • Web Radio app developed as in-class exercise for Thursday's all-day Core Audio class • Will also be at CocoaConf Atlanta • Uses Audio File Stream to receive packets of MP3 and play them with Audio Queue Packets Packets 2 Packets Packets Packets 1 0 Packets
  • 25. LPCM or GTFO • Audiobus ports and AURemoteIO only work with uncompressed LPCM audio • Web radio app is dealing in MP3 or AAC • Conversion to LPCM happens inside the Audio Queue
  • 27. Libraries • Download the Audiobus SDK from developer.audiob.us • Add libAudiobus.a and the Audiobus headers to your project • Add Accelerate, AudioToolbox, QuartzCore, CoreGraphics, and Security frameworks to your project
  • 28.
  • 29. Enable background audio • Add “audio” to the app’s “Required Background Modes” if it’s not already present • All Audiobus-enabled apps must participate in backgrounding, since they must be able to keep running when Audiobus is in foreground
  • 30.
  • 31. Create a launch URL scheme • You must have a URL scheme for your app that ends in “.audiobus” for Audiobus to be able to launch you • Add this to the target’s “URL Types”
  • 32.
  • 33. Get Audiobus API key • For apps registered with iTunes Connect, submit your App Store URL or ID • For unpublished apps or tinkering, register for a temporary ID, good for 14 days • This requires dropping the Info.plist from your app bundle (not from project!)
  • 34.
  • 35. Audiobus API Keys • Audiobus app gets a master list of known keys from a server every 30 minutes • For temporary IDs, click the link from the developer page on the device that you’re using Audiobus on to register your App ID • e.g., audiobus-registry:// developer.audiob.us/tempreg?t=0ff37 • The dev page can mail you the link
  • 36.
  • 37. Set Audiobus-compatible behaviors • Audio Session category must be playback or play-and-record • Must also set the mix-with-others property on the audio session • Often do both these things in the AppDelegate
  • 38. UInt32 audioCategory = kAudioSessionCategory_MediaPlayback; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory); UInt32 allowMixing = YES; AudioSessionSetProperty(kAudioSessionProperty_OverrideCategory MixWithOthers, sizeof (allowMixing), &allowMixing); Note: Audio Session is deprecated in iOS 7 Modern apps can use the AV Foundation equivalents
  • 39. Setup Your App’s Audio System • Your app’s audio infrastructure needs to be up and running before you connect to Audiobus • If you’re going to send audio via the ABAudioBusAudioUnitWrapper, you’ll need to initialize your AURemoteIO • For the web radio app, I send an NSNotification once the player class starts playing
  • 40. Instantiate ABAudiobusController • ABAudiobusController is your app’s connection to Audiobus; probably gets held as a strong property somewhere • init method takes the launch URL and your API key • Obviously, these must match what you registered on audiob.us
  • 41. self.audiobusController = [[ABAudiobusController alloc] initWithAppLaunchURL: [NSURL URLWithString:@"audiobuswebradio.audiobus://"] apiKey:AUDIOBUS_API_KEY];
  • 42. Create ABOutputPort (and Audio Unit wrapper) • ABOutputPort sends audio to Audiobus (via ABOutputPortSendAudio() function) • If you use a RemoteIO unit for your output, the ABAudiobusAudioUnitWrapper will make these calls for you
  • 43. CCFViewController *vc = (CCFViewController*) self.window.rootViewController; ABOutputPort *output = [self.audiobusController addOutputPortNamed:@"Audio Output" title:NSLocalizedString(@"Main App Output", @"")]; self.audiobusAudioUnitWrapper = [[ABAudiobusAudioUnitWrapper alloc] initWithAudiobusController:self.audiobusController audioUnit:vc.player.remoteIOUnit output:output input:nil];
  • 44. Demo
  • 45. Demo
  • 46. Ports • Apps that don’t use the Audio Unit Wrapper use ports directly instead • ABOutputPortSendAudio() for senders (inputs and filters) • Block-based callback or poll with ABInputPortReceive() for receivers (filters and outputs)
  • 47. Filters & Outputs • If you produce audio output based on input, you need to tell the ABInputPort, so that the signal isn’t doubled in Audiobus.
  • 48. As for iOS 7…
  • 49.
  • 51. Sherlocked? Embrace & Extend! From: michael@audiob.us Date: June 19, 2013 Subject: Important Information Regarding Audiobus, iOS 7 and Inter-App Audio iOS 7 introduces many new features, including Apple’s own Inter-App Audio framework which we’re planning to incorporate into Audiobus so you don’t have to. For details and further discussion, we highly recommend checking out our thread on the Apple developer forums: https://devforums.apple.com/thread/191197
  • 52. Closing Thoughts • Audiobus is approachable for developers already working at the Audio Unit level • Adding Audiobus will get it seen by users who’ve proven willing to pay for good apps (we love music app users!) • Future-proofed for iOS 7
  • 53. Q&A Slides & code will be posted to the CocoaConf Glassboard, and announced on my Twitter & app.net (@invalidname)