123
#WWDC17 © 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Akshatha Nagesh, AudioEngine-eer Béla Balázs, Audio Artisan Torrey Holbrook Walker, Audio/MIDI Black Ops What’s New in Audio Session 501 Media

•What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

#WWDC17

© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Akshatha Nagesh, AudioEngine-eer Béla Balázs, Audio Artisan Torrey Holbrook Walker, Audio/MIDI Black Ops

•What’s New in Audio • Session 501

Media

Page 2: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Stack

Application

AudioHAL and Drivers

AVFoundation

AudioToolbox

Core MIDI

Delivering an Exceptional Audio Experience WWDC16

AVAudioPlayer

AVAudioRecorder

AVAudioSession

AVAudioEngine

AVPlayer

AVCapture

AUAudioUnit Audio Codecs

Page 3: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AVAudioEngine •AVAudioSession •watchOS •AUAudioUnit •Other Enhancements •Inter-Device Audio Mode (IDAM)

Page 4: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AVAudioEngine

Page 5: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Recap

Powerful, feature-rich, Objective-C / Swift API set

Simplifies realtime audio, easier to use

Supports • Playback, recording, processing, mixing • 3D spatialization

AVAudioEngine in Practice WWDC14

What’s New in Core Audio WWDC15

Page 6: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 7: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 8: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 9: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 10: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 11: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Karaoke

NodeTapBlock (Analyze)

InputNodeEffectNode

(EQ)

PlayerNode (Backing Track)

PlayerNode (Sound Effects)

MixerNode OutputNode

Page 12: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

What’s New

AVAudioEngine • Manual rendering • Auto shutdown

AVAudioPlayerNode • Completion callbacks

NEW

Page 13: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

What’s New

AVAudioEngine • Manual rendering • Auto shutdown

AVAudioPlayerNode • Completion callbacks

NEW

Page 14: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup

InputNode

OutputNode

NodeTapBlock (Analyze)

EffectNode

PlayerNode

PlayerNode

MixerNode

Page 15: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup

InputNode

OutputNode

NodeTapBlock (Analyze)

EffectNode

PlayerNode

PlayerNode

MixerNode

Page 16: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Manual rendering

NodeTapBlock (Analyze)

InputNode EffectNode

PlayerNode

PlayerNode

MixerNode OutputNode

NEW

Page 17: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Manual rendering

NodeTapBlock (Analyze)

InputNode EffectNode

PlayerNode

PlayerNode

MixerNode OutputNode

NEW

Application

Page 18: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Sample Engine Setup Manual rendering

NodeTapBlock (Analyze)

InputNode EffectNode

PlayerNode

PlayerNode

MixerNode OutputNode

NEW

Application

Page 19: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Engine is not connected to any audio device

Renders in response to requests from the client

Modes • Offline • Realtime

Manual RenderingNEW

Page 20: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Engine and nodes operate under no deadlines or realtime constraints

A node may choose to: • Use a more expensive signal processing algorithm • Block on render thread for more data if needed

- For example, player node may wait until its worker thread reads the data from disk

Offline Manual Rendering NEW

Page 21: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Offline Manual Rendering Example

NEW

Page 22: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Application

Offline Manual Rendering Example

NEW

Source File Destination File

Page 23: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Application

Offline Context

Offline Manual Rendering Example

NEW

Source File Destination File

PlayerNode EffectNode OutputNode

Page 24: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Post-processing of audio files, for example, apply reverb, effects etc.

Mixing of audio files

Offline audio processing using CPU intensive (higher quality) algorithms

Tuning, debugging or testing the engine setup

Offline Manual Rendering Applications

NEW

Page 25: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•Demo •AVAudioEngine - Offline Manual Rendering

Page 26: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

The engine and nodes: • Operate under realtime constraints • Do not make any blocking calls like blocking on a mutex, calling libdispatch etc.,

on the render thread - A node may drop the data if it is not ready to be rendered in time

Realtime Manual Rendering NEW

Page 27: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Processing audio in an AUAudioUnit’s internalRenderBlock

Processing audio data in a movie/video during streaming/playback

Realtime Manual Rendering Applications

NEW

Page 28: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Realtime Manual Rendering Example

NEW

Page 29: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Realtime Manual Rendering Example

NEW

ApplicationAudio from an Input Movie Stream

Audio into anOutput Movie Stream

TV

Page 30: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Realtime Manual Rendering Example

NEW

Realtime Context

ApplicationAudio from an Input Movie Stream

Audio into anOutput Movie Stream

InputNode EffectNode OutputNode

TV

Page 31: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Realtime Manual Rendering Code example

NEW

Realtime Context

Application

InputNode EffectNode OutputNode

Page 32: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Realtime Manual Rendering, code example

do { let engine = AVAudioEngine() // by default engine will render to/from the audio device // make connections, e.g. inputNode -> effectNode -> outputNode

// switch to manual rendering mode engine.stop() try engine.enableManualRenderingMode(.realtime, format: outputPCMFormat, maximumFrameCount: frameCount) // e.g. 1024 @ 48 kHz = 21.33 ms

let renderBlock = engine.manualRenderingBlock // cache the render block

NEW

Page 33: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Realtime Manual Rendering, code example

do { let engine = AVAudioEngine() // by default engine will render to/from the audio device // make connections, e.g. inputNode -> effectNode -> outputNode

// switch to manual rendering mode engine.stop() try engine.enableManualRenderingMode(.realtime, format: outputPCMFormat, maximumFrameCount: frameCount) // e.g. 1024 @ 48 kHz = 21.33 ms

let renderBlock = engine.manualRenderingBlock // cache the render block

NEW

Page 34: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Realtime Manual Rendering, code example

do { let engine = AVAudioEngine() // by default engine will render to/from the audio device // make connections, e.g. inputNode -> effectNode -> outputNode

// switch to manual rendering mode engine.stop() try engine.enableManualRenderingMode(.realtime, format: outputPCMFormat, maximumFrameCount: frameCount) // e.g. 1024 @ 48 kHz = 21.33 ms

let renderBlock = engine.manualRenderingBlock // cache the render block

NEW

Page 35: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Realtime Manual Rendering, code example

do { let engine = AVAudioEngine() // by default engine will render to/from the audio device // make connections, e.g. inputNode -> effectNode -> outputNode

// switch to manual rendering mode engine.stop() try engine.enableManualRenderingMode(.realtime, format: outputPCMFormat, maximumFrameCount: frameCount) // e.g. 1024 @ 48 kHz = 21.33 ms

let renderBlock = engine.manualRenderingBlock // cache the render block

NEW

Page 36: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// set the block to provide input data to engine engine.inputNode.setManualRenderingInputPCMFormat(inputPCMFormat) { (inputFrameCount) -> UnsafePointer<AudioBufferList>? in guard haveData else { return nil } // fill and return the input audio buffer list return inputBufferList }) // create output buffer, cache the buffer list let buffer = AVAudioPCMBuffer(pcmFormat: outputPCMFormat, frameCapacity: engine.manualRenderingMaximumFrameCount)! buffer.frameLength = buffer.frameCapacity let outputBufferList = buffer.mutableAudioBufferList try engine.start() } catch { // handle errors }

NEW

Page 37: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// set the block to provide input data to engine engine.inputNode.setManualRenderingInputPCMFormat(inputPCMFormat) { (inputFrameCount) -> UnsafePointer<AudioBufferList>? in guard haveData else { return nil } // fill and return the input audio buffer list return inputBufferList }) // create output buffer, cache the buffer list let buffer = AVAudioPCMBuffer(pcmFormat: outputPCMFormat, frameCapacity: engine.manualRenderingMaximumFrameCount)! buffer.frameLength = buffer.frameCapacity let outputBufferList = buffer.mutableAudioBufferList try engine.start() } catch { // handle errors }

NEW

Page 38: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// set the block to provide input data to engine engine.inputNode.setManualRenderingInputPCMFormat(inputPCMFormat) { (inputFrameCount) -> UnsafePointer<AudioBufferList>? in guard haveData else { return nil } // fill and return the input audio buffer list return inputBufferList }) // create output buffer, cache the buffer list let buffer = AVAudioPCMBuffer(pcmFormat: outputPCMFormat, frameCapacity: engine.manualRenderingMaximumFrameCount)! buffer.frameLength = buffer.frameCapacity let outputBufferList = buffer.mutableAudioBufferList try engine.start() } catch { // handle errors }

NEW

Page 39: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// set the block to provide input data to engine engine.inputNode.setManualRenderingInputPCMFormat(inputPCMFormat) { (inputFrameCount) -> UnsafePointer<AudioBufferList>? in guard haveData else { return nil } // fill and return the input audio buffer list return inputBufferList }) // create output buffer, cache the buffer list let buffer = AVAudioPCMBuffer(pcmFormat: outputPCMFormat, frameCapacity: engine.manualRenderingMaximumFrameCount)! buffer.frameLength = buffer.frameCapacity let outputBufferList = buffer.mutableAudioBufferList try engine.start() } catch { // handle errors }

NEW

Page 40: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// set the block to provide input data to engine engine.inputNode.setManualRenderingInputPCMFormat(inputPCMFormat) { (inputFrameCount) -> UnsafePointer<AudioBufferList>? in guard haveData else { return nil } // fill and return the input audio buffer list return inputBufferList }) // create output buffer, cache the buffer list let buffer = AVAudioPCMBuffer(pcmFormat: outputPCMFormat, frameCapacity: engine.manualRenderingMaximumFrameCount)! buffer.frameLength = buffer.frameCapacity let outputBufferList = buffer.mutableAudioBufferList try engine.start() } catch { // handle errors }

NEW

Page 41: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// to render from realtime context OSStatus outputError = noErr; const auto status = renderBlock(framesToRender, outputBufferList, &outputError); switch (status) { case AVAudioEngineManualRenderingStatusSuccess: handleProcessedOutput(outputBufferList); // data rendered successfully break;

case AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode: handleProcessedOutput(outputBufferList); // input node did not provide data, // but other sources may have rendered break; .. default: break; }

NEW

Page 42: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// to render from realtime context OSStatus outputError = noErr; const auto status = renderBlock(framesToRender, outputBufferList, &outputError); switch (status) { case AVAudioEngineManualRenderingStatusSuccess: handleProcessedOutput(outputBufferList); // data rendered successfully break;

case AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode: handleProcessedOutput(outputBufferList); // input node did not provide data, // but other sources may have rendered break; .. default: break; }

NEW

Page 43: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// to render from realtime context OSStatus outputError = noErr; const auto status = renderBlock(framesToRender, outputBufferList, &outputError); switch (status) { case AVAudioEngineManualRenderingStatusSuccess: handleProcessedOutput(outputBufferList); // data rendered successfully break;

case AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode: handleProcessedOutput(outputBufferList); // input node did not provide data, // but other sources may have rendered break; .. default: break; }

NEW

Page 44: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

// to render from realtime context OSStatus outputError = noErr; const auto status = renderBlock(framesToRender, outputBufferList, &outputError); switch (status) { case AVAudioEngineManualRenderingStatusSuccess: handleProcessedOutput(outputBufferList); // data rendered successfully break;

case AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode: handleProcessedOutput(outputBufferList); // input node did not provide data, // but other sources may have rendered break; .. default: break; }

NEW

Page 45: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Offline • Can use either ObjC/Swift render method or the block based render call

Realtime • Must use the block based render call

Manual Rendering Render calls

NEW

Page 46: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

What’s New

AVAudioEngine • Manual rendering • Auto shutdown

AVAudioPlayerNode • Completion callbacks

NEW

Page 47: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Hardware is stopped if running idle for a certain duration, started dynamically when needed

Safety net for conserving power

Enforced behavior on watchOS, optional on other platforms

Auto Shutdown

isAutoShutdownEnabled

NEW

Page 48: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

What’s New

AVAudioEngine • Manual rendering • Auto shutdown

AVAudioPlayerNode • Completion callbacks

NEW

Page 49: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Existing buffer/file completion handlers called when the data has been consumed

New completion handler and callback types

Completion Callbacks

AVAudioPlayerNodeCompletionCallbackType .dataConsumed .dataRendered .dataPlayedBack

NEW

Page 50: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

• Data has been consumed, same as the existing completion handlers • The buffer can be recycled, more data can be scheduled

• Data has been output by the player • Useful in manual rendering mode • Does not account for any downstream signal processing latency

Completion Callbacks

.dataConsumed

.dataRendered

NEW

Page 51: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

• Buffer/file has finished playing • Applicable only when the engine is rendering to an audio device • Accounts for both (small) downstream signal processing latency and (possibly

significant) audio playback device latency

Completion Callbacks

.dataPlayedBack

NEW

Page 52: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

• Buffer/file has finished playing • Applicable only when the engine is rendering to an audio device • Accounts for both (small) downstream signal processing latency and (possibly

significant) audio playback device latency

Completion Callbacks

.dataPlayedBack

NEW

Page 53: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

• Buffer/file has finished playing • Applicable only when the engine is rendering to an audio device • Accounts for both (small) downstream signal processing latency and (possibly

significant) audio playback device latency

Completion Callbacks

.dataPlayedBack

NEW

player.scheduleFile(file, at: nil, completionCallbackType: .dataPlayedBack) { (callbackType) in // file has finished playing from listener’s perspective // notify to stop the engine and update UI })

Page 54: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

AVAudioEngine Summary

AVAudioEngine • Manual rendering • Auto shutdown

AVAudioPlayerNode • Completion callbacks

Deprecation coming soon (2018) • AUGraph

NEW

Page 55: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AVAudioSession

Page 56: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

AirPlay 2 Support

AirPlay 2 - new technology on iOS, tvOS and macOS • Multi-room audio with AirPlay 2 capable devices

Long-form audio applications • Content - music, podcasts etc. • Separate, shared audio route to AirPlay 2 devices • New AVAudioSession API for an application to identify itself as long-form

Introducing AirPlay 2 Session 509 Thursday 4:10PM

NEW

Page 57: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Page 58: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Page 59: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Interrupted

Page 60: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Interrupted

Page 61: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Interrupted

Page 62: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Routing (iOS) - Current Behavior Music and phone call

Session Arbitration and Mixing

AirPlay System Audio

Page 63: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (iOS) Music and phone call coexistence

Long-form Audio (AirPlay 2)

System Audio

NEW

Page 64: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (iOS) Music and phone call coexistence

Long-form Audio (AirPlay 2)

System Audio

Long-form audio route

Session Arbitration

NEW

Page 65: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (iOS) Music and phone call coexistence

Long-form Audio (AirPlay 2)

System Audio

Long-form audio route

Session Arbitration

NEW

Page 66: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (iOS) Music and phone call coexistence

Long-form Audio (AirPlay 2)

System Audio

Long-form audio route

Session Arbitration

System audio route

Session Arbitration and Mixing

NEW

Page 67: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

NEWLong-form Audio Routing (iOS and tvOS)

Long-form Audio (AirPlay 2)

Session Arbitration

Applications that usethe long-form audio route

Page 68: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

NEWLong-form Audio Routing (iOS and tvOS)

Long-form Audio (AirPlay 2)

Session Arbitration

Applications that usethe long-form audio route

System Audio

Session Arbitration and Mixing

Applications that usethe system audio route

Page 69: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (iOS and tvOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm) } catch { // handle errors }

NEW

Page 70: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (iOS and tvOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm) } catch { // handle errors }

NEW

Page 71: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (iOS and tvOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm) } catch { // handle errors }

NEW

Page 72: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (iOS and tvOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm) } catch { // handle errors }

NEW

Page 73: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (macOS)

Long-form Audio (AirPlay 2)

Arbitration

Applications that usethe long-form audio route

NEW

Page 74: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Long-form Audio Routing (macOS)

Long-form Audio (AirPlay 2)

Arbitration

Applications that usethe long-form audio route

NEW

Default Device

Mixing

Applications that usethe system audio route

Page 75: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (macOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setRouteSharingPolicy(.longForm) } catch { // handle errors }

NEW

Page 76: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (macOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setRouteSharingPolicy(.longForm) } catch { // handle errors }

NEW

Page 77: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//Long-form Audio Routing (macOS), code example

let mySession = AVAudioSession.sharedInstance() do { try mySession.setRouteSharingPolicy(.longForm) } catch { // handle errors }

NEW

Page 78: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•Enhancements in watchOS

Page 79: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

watchOS 4.0 Playback and recording

Playback • AVAudioPlayer (watchOS 3.1 SDK)

Recording • AVAudioInputNode (AVAudioEngine) • AVAudioRecorder • AVAudioSession recording permissions

Formats supported • AAC-LC, AAC-ELD, HE-AAC, HE-AACv2, MP3 (decoding only), Opus

NEW

Page 80: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

watchOS 4.0 Recording policies

Recording can start only in foreground

Recording allowed to continue in the background (red microphone icon displayed)

Recording in background is CPU limited • https://developer.apple.com/reference/

healthkit/hkworkoutsession

NEW

Page 81: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AVAudioEngine •AVAudioSession •watchOS •AUAudioUnit •Other Enhancements •Inter-Device Audio Mode (IDAM)

Page 82: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AUAudioUnit

Page 83: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

AU View Configuration

Host applications decide how to display UI for AUs

Current limitations • No standard view sizes defined • AUs are supposed to adapt to any view size chosen by host

Page 84: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Unit ExtensionHost

AU Preferred View ConfigurationNEW

Page 85: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Unit ExtensionHost

AU Preferred View Configuration

supportedViewConfigurations (availableViewConfigurations)

Array of all possible view configurations

NEW

Page 86: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Unit ExtensionHost

AU Preferred View Configuration

supportedViewConfigurations (availableViewConfigurations)

Array of all possible view configurations

IndexSet of supported view configurations

NEW

Page 87: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Unit ExtensionHost

AU Preferred View Configuration

supportedViewConfigurations (availableViewConfigurations)

Array of all possible view configurations

IndexSet of supported view configurations

Chosen view configuration select(viewConfiguration)

NEW

Page 88: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

AU Preferred View Configuration Code example - AU extension

Audio Unit ExtensionHost

supportedViewConfigurations (availableViewConfigurations)

Array of all possible view configurations

IndexSet of supported view configurations

Chosen view configuration select(viewConfiguration)

NEW

Page 89: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func supportedViewConfigurations(_ availableViewConfigurations: [AUAudioUnitViewConfiguration]) -> IndexSet { var result = NSMutableIndexSet() for (index, config) in availableViewConfigurations.enumerated() { // check if the config (width, height, hostHasController) is supported // a config of 0x0 (default full size) must always be supported if isConfigurationSupported(config) { result.add(index) } } return result as IndexSet }

NEW

Page 90: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func supportedViewConfigurations(_ availableViewConfigurations: [AUAudioUnitViewConfiguration]) -> IndexSet { var result = NSMutableIndexSet() for (index, config) in availableViewConfigurations.enumerated() { // check if the config (width, height, hostHasController) is supported // a config of 0x0 (default full size) must always be supported if isConfigurationSupported(config) { result.add(index) } } return result as IndexSet }

NEW

Page 91: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func supportedViewConfigurations(_ availableViewConfigurations: [AUAudioUnitViewConfiguration]) -> IndexSet { var result = NSMutableIndexSet() for (index, config) in availableViewConfigurations.enumerated() { // check if the config (width, height, hostHasController) is supported // a config of 0x0 (default full size) must always be supported if isConfigurationSupported(config) { result.add(index) } } return result as IndexSet }

NEW

Page 92: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func supportedViewConfigurations(_ availableViewConfigurations: [AUAudioUnitViewConfiguration]) -> IndexSet { var result = NSMutableIndexSet() for (index, config) in availableViewConfigurations.enumerated() { // check if the config (width, height, hostHasController) is supported // a config of 0x0 (default full size) must always be supported if isConfigurationSupported(config) { result.add(index) } } return result as IndexSet }

NEW

Page 93: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func supportedViewConfigurations(_ availableViewConfigurations: [AUAudioUnitViewConfiguration]) -> IndexSet { var result = NSMutableIndexSet() for (index, config) in availableViewConfigurations.enumerated() { // check if the config (width, height, hostHasController) is supported // a config of 0x0 (default full size) must always be supported if isConfigurationSupported(config) { result.add(index) } } return result as IndexSet }

NEW

Page 94: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func select(_ viewConfiguration: AUAudioUnitViewConfiguration) { // configuration selected by host, used by view controller to re-arrange its view self.currentViewConfiguration = viewConfiguration self.viewController?.selectViewConfig(self.currentViewConfiguration) }

NEW

Page 95: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func select(_ viewConfiguration: AUAudioUnitViewConfiguration) { // configuration selected by host, used by view controller to re-arrange its view self.currentViewConfiguration = viewConfiguration self.viewController?.selectViewConfig(self.currentViewConfiguration) }

NEW

Page 96: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - AU extension

override public func select(_ viewConfiguration: AUAudioUnitViewConfiguration) { // configuration selected by host, used by view controller to re-arrange its view self.currentViewConfiguration = viewConfiguration self.viewController?.selectViewConfig(self.currentViewConfiguration) }

NEW

Page 97: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Unit Extension

AU Preferred View Configuration Code example - host application

Host

supportedViewConfigurations (availableViewConfigurations)

Array of all possible view configurations

IndexSet of supported view configurations

Chosen view configuration select(viewConfiguration)

NEW

Page 98: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - host application

var smallConfigActive: Bool = false // true if the small view is the currently active one @IBAction func toggleViewModes(_ sender: AnyObject?) { guard audioUnit = self.engine.audioUnit else { return } let largeConfig = AUAudioUnitViewConfiguration(width: 600, height: 400, hostHasController: false) let smallConfig = AUAudioUnitViewConfiguration(width: 300, height: 200, hostHasController: true)

let supportedIndices = audioUnit.supportedViewConfigurations([smallConfig, largeConfig]) if supportedIndices.count == 2 { audioUnit.select(self.smallConfigActive ? largeConfig : smallConfig) self.smallConfigActive = !self.smallConfigActive } }

NEW

Page 99: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - host application

var smallConfigActive: Bool = false // true if the small view is the currently active one @IBAction func toggleViewModes(_ sender: AnyObject?) { guard audioUnit = self.engine.audioUnit else { return } let largeConfig = AUAudioUnitViewConfiguration(width: 600, height: 400, hostHasController: false) let smallConfig = AUAudioUnitViewConfiguration(width: 300, height: 200, hostHasController: true)

let supportedIndices = audioUnit.supportedViewConfigurations([smallConfig, largeConfig]) if supportedIndices.count == 2 { audioUnit.select(self.smallConfigActive ? largeConfig : smallConfig) self.smallConfigActive = !self.smallConfigActive } }

NEW

Page 100: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - host application

var smallConfigActive: Bool = false // true if the small view is the currently active one @IBAction func toggleViewModes(_ sender: AnyObject?) { guard audioUnit = self.engine.audioUnit else { return } let largeConfig = AUAudioUnitViewConfiguration(width: 600, height: 400, hostHasController: false) let smallConfig = AUAudioUnitViewConfiguration(width: 300, height: 200, hostHasController: true)

let supportedIndices = audioUnit.supportedViewConfigurations([smallConfig, largeConfig]) if supportedIndices.count == 2 { audioUnit.select(self.smallConfigActive ? largeConfig : smallConfig) self.smallConfigActive = !self.smallConfigActive } }

NEW

Page 101: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

//AU Preferred View Configuration Code example - host application

var smallConfigActive: Bool = false // true if the small view is the currently active one @IBAction func toggleViewModes(_ sender: AnyObject?) { guard audioUnit = self.engine.audioUnit else { return } let largeConfig = AUAudioUnitViewConfiguration(width: 600, height: 400, hostHasController: false) let smallConfig = AUAudioUnitViewConfiguration(width: 300, height: 200, hostHasController: true)

let supportedIndices = audioUnit.supportedViewConfigurations([smallConfig, largeConfig]) if supportedIndices.count == 2 { audioUnit.select(self.smallConfigActive ? largeConfig : smallConfig) self.smallConfigActive = !self.smallConfigActive } }

NEW

Page 102: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

AU MIDI Output

AU can emit MIDI output synchronized with its audio output

Host sets a block on the AU to be called every render cycle

Host can record/edit both MIDI performance and audio output from the AU *MIDIOutputNames MIDIOutputEventBlock

NEW

Page 103: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Other Updates

Entitlement • AU extension host applications linked against

iOS 11 SDK and later will need 'inter-app-audio' entitlement

AU short name *audioUnitShortName

NEW

Page 104: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Béla Balázs, Audio Artisan

•Demo •AUAudioUnit

Page 105: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•Other Enhancements

Page 106: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Audio Formats

FLAC (Free Lossless Audio Codec) • Codec, file, and streaming support • Content distribution, streaming applications

Opus • Codec support • File I/O using .caf container • VOIP applications

NEW

Page 107: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Spatial Audio Formats B-Format

Audio stream is regular PCM

File container .caf

B-format: W,X,Y,Z • 1st order ambisonics kAudioChannelLayoutTag_Ambisonic_B_Format

NEW

Page 108: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Spatial Audio Formats Higher Order Ambisonics

N order ambisonics (N is 1..254) kAudioChannelLayoutTag_HOA_ACN_SN3D - SN3D normalized streams kAudioChannelLayoutTag_HOA_ACN_N3D - N3D normalized streams

ACN (Ambisonic Channel Number) Channels kAudioChannelLabel_HOA_ACN_0..65024

AudioFormat support for converting • Between B-format, ACN_SN3D, ACN_N3D • From ambisonics to arbitrary speaker layout

NEW

Page 109: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Spatial Mixer Head-Related Transfer Function (HRTF)

AUSpatialMixer - kSpatializationAlgorithm_HRTFHQ

AVAudioEnvironmentNode - AVAudio3DMixingRenderingAlgorithmHRTFHQ

Features • Better frequency response • Better localization of sources in a 3D space

NEW

Page 110: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•AVAudioEngine •AVAudioSession •watchOS •AUAudioUnit •Other Enhancements •Inter-Device Audio Mode (IDAM)

Page 111: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Torrey Holbrook Walker, Audio/MIDI Black Ops

•Inter-Device Audio Mode (IDAM)

Page 112: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio Mode

Record audio digitally via Lightning-to-USB cable

USB 2.0 audio class-compliant implementation

Available since El Capitan and iOS 9

Page 113: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio ModeIDAM

Page 114: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio ModeIDAM

Page 115: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio Mode+ MIDIIDAM

Page 116: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio + MIDI

Send and receive MIDI via Lightning-to-USB cable

Class-compliant USB MIDI implementation

Requires iOS 11 and macOS El Capitan or later

Auto-enabled in IDAM configuration

NEW

Page 117: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Inter-Device Audio + MIDI

Device can charge and sync in IDAM configuration

Photo import and tethering are temporarily disabled

Audio device aggregation is ok

Use your iOS devices as a MIDI controllers, destinations, or both

NEW

Page 118: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

•Demo •MIDI using IDAM Configuration

Page 119: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Summary

AVAudioEngine - manual rendering

AVAudioSession - Airplay 2 support

watchOS - recording

AUAudioUnit - preferred view size, MIDI output

Other enhancements - audio formats (FLAC, Opus, HOA)

Inter-Device Audio and MIDI

Page 120: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

More Informationhttps://developer.apple.com/wwdc17/501

Page 121: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Related Sessions

Introducing MusicKit Grand Ballroom B Tuesday 3:10PM

What's New in watchOS Hall 2 Wednesday 9:00AM

Introducing AirPlay 2 Executive Ballroom Thursday 4:10PM

Page 122: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox

Labs

Audio Lab Technology Lab F Tue 4:10PM–6:00PM

Airplay Lab Technology Lab A Wed 11:00AM-1:00PM

Audio Lab Technology Lab G Thu 1:00PM–3:00PM

Airplay Lab Technology Lab A Fri 9:00AM-11:00AM

Page 123: •What’s New in Audio...Torrey Holbrook Walker, Audio/MIDI Black Ops •What’s New in Audio • Session 501 Media Audio Stack Application AudioHAL and Drivers AVFoundation AudioToolbox