SlideShare a Scribd company logo
@bobmccune
Bob McCune
with AVAudioEngine
Building Modern Audio Apps
-MN Developer and Instructor
-Owner of TapHarmonic, LLC.
-Author of Learning AV Foundation
About...
Bob McCune
http://LearningAVFoundation.com
-What is AVAudioEngine?
- Goals and Capabilities
-Understanding AVAudioEngine
- Understanding Audio Nodes
- Playing and Recording Audio
- Audio Mixing and Effect Processing
- Working with MIDI and Samplers
Agenda
What will I learn?
AV Foundation Evolution
Humble Beginnings
AV Foundation
MediaPlayer AVKit
UIKit AppKit
Core Video Core MediaCore Animation
Audio-Only
Core Audio
MavericksiOS 7
AV Foundation Evolution
Humble Beginnings
AVKit AVKit
UIKit AppKit
Core Video Core MediaCore Animation Core Audio
AVF Video AVF Audio
YosemiteiOS 8
AVAudioEngine
An Introduction
-Objective-C API simplifying low-latency, real-time audio
-Features and Capabilities:
- Read and write audio files in all Core Audio supported formats
- Play and record audio using files and buffers
- Dynamically configure audio processing blocks
- Perform audio tap processing
- Perform Stereo and 3D mixing off audio signals
- MIDI playback and control over sampler instruments
AVAudioEngine
Core Audio for Mortals
Sample Use Cases
What kind of apps can you build?
-Manages graphs of audio nodes
-Connects audio node into active chains
-Dynamically attach and reconfigure graph
-Start and stop the engine
The Engine
AVAudioEngine
-Nodes are audio blocks
- Source Nodes: Player, Microphone
- Processing Nodes: Mixer, Audio Unit Effect
- Destination: Speaker, Headphones
Nodes
AVAudioNode
-AVAudioEngine provides 3 implicit nodes:
- AVAudioInputNode: system input, cannot be created
- AVAudioOutputNode: system output, cannot be created
- AVAudioMixerNode: mixes multiple inputs to a single output
-Nodes are connected via their input and output busses
- Most nodes have one input and one output
- AVAudioMixerNode has multiple inputs and one output
- Busses have an associated audio format
Nodes
AVAudioNode
-Nodes are connected to form an active chain
- Source Node Destination Node = Active Chain
- Establishes and active render thread
Node Connections
Establishing Active Chains
Destination

Node

(Output)
Source

Node

(Player)
Node Connections
Establishing Active Chains
Destination

Node

(Output)
Source

Node

(Player)
Processing 

Node

(Mixer)
-Nodes are connected to form an active chain
- Source Node Destination Node = Active Chain
- Establishes and active render thread
Node Connections
Establishing Active Chains
Destination

Node

(Output)
Source

Node

(Player)
Processing 

Node

(Mixer)
X
-Nodes are connected to form an active chain
- Source Node Destination Node = Active Chain
- Establishes and active render thread
1. Create the engine
2. Create the nodes
3. Attach the nodes to the engine
4. Connect the nodes together
5. Start the engine
Basic Recipe
Configuring the Graph
Engine Setup
Basic Recipe
// 1. Create engine (example only, needs to be strong reference)
AVAudioEngine *engine = [[AVAudioEngine alloc] init];
// 2. Create a player node
AVAudioPlayerNode *player = [[AVAudioPlayerNode alloc] init];
// 3. Attach node to the engine
[engine attachNode:player];
// 4. Connect player node to engine's main mixer
AVAudioMixerNode *mixer = engine.mainMixerNode;
[engine connect:player to:mixer format:[mixer outputFormatForBus:0]];
// 5. Start engine
NSError *error;
if (![engine startAndReturnError:&error]) {
// handle error
}
Playing Audio
Players, Files, and Buffers
Files, Buffers, and Formats
AVAudioPCMBuffer
AVAudioFormat
AVAudioFile
-Reads and writes files in all Core Audio supported formats
-Automatically decodes when reading, encodes when writing
- Does not support sample rate conversion
-File has both a file format and a processing format
- fileFormat: on-disk format
- processingFormat: uncompressed, in-memory format
- Both are instances of AVAudioFormat
Audio Files
AVAudioFile
-Provides a format descriptor for the digital audio samples
- Provides access to sample rate, channel count, interleaving, etc.
- Wrapper over Core Audio AudioStreamBasicDescription
-Core Audio uses a “Standard” format for both platforms
- Noninterleaved linear PCM, 32-bit floating point samples
- Canonical formats are deprecated!
-Additionally supports “Common” formats
- AVAudioCommonFormat: 16/32-bit integer, 32/64-but floating point
Audio Formats
AVAudioFormat
-Memory buffer for audio data in any Linear PCM format
- Format and buffer capacity defined upon creation
-Provides a wrapper over a Core Audio AudioBufferList
- audioBufferList and mutableAudioBufferList properties
Audio Buffers
AVAudioPCMBuffer
@property (nonatomic, readonly) float * const *floatChannelData;
@property (nonatomic, readonly) int16_t * const *int16ChannelData;
@property (nonatomic, readonly) int32_t * const *int32ChannelData;
-Sample data accessed using:
-Pushes audio data onto the active render thread
-Schedule audio data from files and buffers
- Scheduled to play immediately or at future time
- Future times specified with AVAudioTime
- Files
- Schedule file or file segment with completion callback
- Buffers
- Schedule multiple buffers with individual completion callbacks
- Schedule looping buffer
Player Nodes
AVAudioPlayerNode
Creating Files and Buffers
AVAudioFile and AVAudioPCMBuffer
NSURL *url = [[NSBundle mainBundle] URLForResource:@"groove"
withExtension:@"m4a"];
// Create AVAudioFile
AVAudioFile *file = [[AVAudioFile alloc] initForReading:url
error:nil];
// Create AVAudioPCMBuffer
AVAudioFormat *format = file.processingFormat;
AVAudioFrameCount capacity = (AVAudioFrameCount)file.length;
AVAudioPCMBuffer *buffer =
[[AVAudioPCMBuffer alloc] initWithPCMFormat:format
frameCapacity:capacity];
// Read AVAudioFile -> AVAudioPCMBuffer
[file readIntoBuffer:buffer error:nil];
AVPlayerNode
Scheduling Files and Buffers
Immediate File Playback
[playerNode scheduleFile:audioFile atTime:nil completionHandler:nil];
[playerNode play];
Future Buffer Playback
// Play audio file 5 seconds from now
double sampleRate = buffer.format.sampleRate;
double sampleTime = sampleRate * 5.0;
AVAudioTime *futureTime = [AVAudioTime timeWithSampleTime:sampleTime
atRate:sampleRate];
[playerNode scheduleBuffer:audioBuffer atTime:futureTime options:0 completionHandler:nil];
[playerNode play];
[playerNode scheduleBuffer:audioBuffer completionHandler:nil];
[playerNode play];
Immediate Buffer Playback
-Scheduling multiple buffers queues them serially
Scheduling Options
AVAudioPlayerNodeBufferOptions
[playerNode scheduleBuffer:buffer1 atTime:nil options:0 completionHandler:nil];
[playerNode play];
[playerNode scheduleBuffer:buffer2 atTime:nil options:0 completionHandler:nil];
buffer1 buffer2
time
[playerNode scheduleBuffer:buffer2
atTime:nil
options:AVAudioPlayerNodeBufferInterrupts completionHandler:nil];
-Schedule with interruption option to change this behavior
buffer1 buffer2
time
-Schedule a single looping buffer
Scheduling Options
AVAudioPlayerNodeBufferOptions
[playerNode scheduleBuffer:buffer1
atTime:nil
options:AVAudioPlayerNodeBufferLoops completionHandler:nil];
buffer1
[playerNode scheduleBuffer:buffer2
atTime:nil
options:AVAudioPlayerNodeBufferInterruptsAtLoop completionHandler:nil];
-Schedule with interruption or interruption at loop
buffer1 buffer2
Audio Mixing
AVAudioMixerNode
-Node that mixes multiple inputs into a single output
- Efficiently performs sample rate conversions
- Can upmix/downmix channel counts where needed
Audio Mixing
AVAudioMixerNode
AVAudioMixerNode
Input 1
Input 2
-Group and process similar inputs
- Simplify and improve efficiency of similar audio processing
Audio Mixing
Using Submixes
AVAudioMixerNode
Input 1
Input 2
AVAudioMixerNode
Input 3
Input 4
AVAudioMixerNode

(main mixer)
-AVAudioMixing Protocol:
- Defines properties to be applied to an input bus of a mixer node
- Source and mixer nodes conform to this protocol
Audio Mixing
AVAudioMixing
AVAudioOutputNodeAVAudioMixerNode
AVAudioPlayerNode
AVAudioPlayerNode
volume pan
volume pan
Input Bus 0
Input Bus 1
Audio Taps
Installing Node Taps
-Node tap pulls data off the render thread
-Captures the output of a particular node
- Record data from microphone
- Record data from a pre-recorded or live audio mix
- Perform data visualization or analysis
-Can install one tap per output bus
-Dynamically install and remove taps
-Audio data returned in a block callback
Node Taps
Pulling Data
Node Taps
Installing a tap
AVAudioMixerNode *mixer = self.engine.mainMixerNode;
AVAudioFrameCount bufferSize = 4096;
AVAudioFormat *format = [mixer outputFormatForBus:0];
[mixer installTapOnBus:0
bufferSize:bufferSize
format:format
block:^(AVAudioPCMBuffer *buffer, AVAudioTime *when) {
// Process AVAudioPCMBuffer
}];
Audio Processing
Applying Audio Effects
Effect Nodes
Digital Signal Processing
-There are two main categories of effects available:
- AVAudioUnitEffect: performs real-time audio processing
- AVAudioUnitTimeEffect: performs non real-time audio processing
AVAudioUnitDelay
AVAudioUnitEQ
AVAudioUnitDistortion
AVAudioUnitReverb
AVAudioUnitEffect AVAudioUnitTimeEffect
AVAudioUnitTimePitch
AVAudioUnitVarispeed
-Delays original signal by delay time and mixes with original
-Configuration parameters:
- delayTime: The delay time of the input signal (up to 2 seconds)
- feedback: Amount of output fed back into delay line
- lowPassCutoff: Frequency past which high frequencies rolled off
- wetDryMix: The blend of wet/dry signals (0% to 100%)
Delay
AVAudioUnitDelay
-Multi-band equalizer and filter unit
-Configuration parameters:
- bands: Array of AVAudioUnitEQFilterParameters objects
- globalGain: Overall gain adjustment applied to input signal (-96 to 24db)
Equalization
AVAudioUnitEQ
-Used to define the EQ parameters to be applied
- Retrieved from the AVAudioUnitEQ object’s bands property
-Configuration parameters:
- filterType: Parametric, Low/High Pass, Band Pass, Low/High Shelf
- frequency: The center frequency or cutoff frequency
- bandwidth: The width around the main frequency in octaves
- gain: The gain adjustment (boost or cut) to the frequency
- bypass: The bypass state
Equalization (Continued)
AVAudioUnitEQFilterParameters
-Multi-stage distortion effect of original signal
-Configuration presets:
- loadFactoryPreset:(AVAudioUnitDistortionPreset)preset
- DrumsBitBrush, MultiBrokenSpeaker, SpeechWaves, etc
-Configuration parameters:
- preGain: Gain applied to signal before distorted (-80dB to 20dB)
- wetDryMix: The blend of wet/dry signals (0% to 100%)
Distortion
AVAudioUnitDistortion
-Simulates the reflective qualities of a particular environment
-Configuration presets:
- loadFactoryPreset:(AVAudioUnitReverbPreset)preset
- Small Room, Large Hall, Cathedral, etc.

-Configuration parameters:
- wetDryMix: The blend of wet/dry signals (0% to 100%)
Reverb
AVAudioUnitReverb
Demo
GarageMix
Using MIDI
MIDI Playback
-Musical Instrument Digital Interface
-Specification defining:
- Communication protocol for controlling electronic instruments
- Hardware cables and connectors
- Standard MIDI file format
-Extensions:
- General MIDI (GM)
- Downloadable Sounds (DLS)
MIDI
What is MIDI?
http://www.midi.org
-High-quality sampler instrument to play sampled sounds
-Loads samples in EXS, SF2, or DLS formats
- Can additionally load and arbitrary array of sample data
-Responds to all standard MIDI messages
- Note on/off, controller messages, pitch bend, etc.
-Great solution for a live performance instrument
- What about playing sequences?
Sampling Instrument
AVAudioUnitSampler
-AVAudioEngine has a musicSequence property
- AudioToolbox MusicSequence type
-Use the MusicPlayer and MusicSequence APIs
- Attach the MusicSequence to the engine to play through Sampler
MusicSequence
Core MIDI Type
Demo
EXSSampler
-Powerful new addition to AV Foundation
- Simplifies low-latency, realtime audio
- Great solution for music, audio, and gaming applications
- Core Audio for Mortals
-Enables you to build advanced audio applications
- Read and write audio files
- Play and record audio using files and buffers
- Add DSP effects: Reverb, Delays, etc.
- Perform Stereo and 3D mixing off audio signals
- MIDI playback and control over sampler instruments
Summary
AVAudioEngine

More Related Content

What's hot

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
Asterisk sip channel performance
Asterisk sip channel performanceAsterisk sip channel performance
Asterisk sip channel performance
Flavio Eduardo de Andrade Goncalves
 
Como conectar visual basic 6.0 a una base de datos microsoft sql server
Como conectar visual basic 6.0 a una base de datos microsoft sql serverComo conectar visual basic 6.0 a una base de datos microsoft sql server
Como conectar visual basic 6.0 a una base de datos microsoft sql server
KarolaynCardozo1
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Grand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CGrand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-C
Pavel Albitsky
 
Introduction to ACI APIs
Introduction to ACI APIsIntroduction to ACI APIs
Introduction to ACI APIs
Cisco DevNet
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Pierre-jean Texier
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Character drivers
Character driversCharacter drivers
Character drivers
pradeep_tewani
 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)
Chris Adamson
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11흥배 최
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
RuggedBoardGroup
 
/proc/irq/<irq>/smp_affinity
/proc/irq/<irq>/smp_affinity/proc/irq/<irq>/smp_affinity
/proc/irq/<irq>/smp_affinityTakuya ASADA
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
SUSE Labs Taipei
 
Linux Inter Process Communication
Linux Inter Process CommunicationLinux Inter Process Communication
Linux Inter Process Communication
Abhishek Sagar
 
Building RT image with Yocto
Building RT image with YoctoBuilding RT image with Yocto
Building RT image with Yocto
Alexandre LAHAYE
 
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
Bob McCune
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)fefe7270
 

What's hot (20)

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Asterisk sip channel performance
Asterisk sip channel performanceAsterisk sip channel performance
Asterisk sip channel performance
 
Como conectar visual basic 6.0 a una base de datos microsoft sql server
Como conectar visual basic 6.0 a una base de datos microsoft sql serverComo conectar visual basic 6.0 a una base de datos microsoft sql server
Como conectar visual basic 6.0 a una base de datos microsoft sql server
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Grand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CGrand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-C
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
Introduction to ACI APIs
Introduction to ACI APIsIntroduction to ACI APIs
Introduction to ACI APIs
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Character drivers
Character driversCharacter drivers
Character drivers
 
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)
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
/proc/irq/<irq>/smp_affinity
/proc/irq/<irq>/smp_affinity/proc/irq/<irq>/smp_affinity
/proc/irq/<irq>/smp_affinity
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
 
Linux Inter Process Communication
Linux Inter Process CommunicationLinux Inter Process Communication
Linux Inter Process Communication
 
Building RT image with Yocto
Building RT image with YoctoBuilding RT image with Yocto
Building RT image with Yocto
 
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
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 

Similar to Building Modern Audio Apps with AVAudioEngine

KKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - DolphinKKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - Dolphin
Liyao Chen
 
Core audio
Core audioCore audio
Core audio
scussen
 
Introduction to AV Foundation
Introduction to AV FoundationIntroduction to AV Foundation
Introduction to AV Foundation
Chris Adamson
 
Movi presentation Singapore video tech meetup
Movi presentation Singapore video tech meetupMovi presentation Singapore video tech meetup
Movi presentation Singapore video tech meetup
Lars-Erik M Ravn
 
Voice That Matter 2010 - Core Audio
Voice That Matter 2010 - Core AudioVoice That Matter 2010 - Core Audio
Voice That Matter 2010 - Core Audio
Kevin Avila
 
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Core Audio in iOS 6 (CocoaConf Portland, Oct. '12)
Chris Adamson
 
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Chris Adamson
 
Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)
Chris Adamson
 
Web audio, Trackers and Making Music
Web audio, Trackers and Making MusicWeb audio, Trackers and Making Music
Web audio, Trackers and Making Music
GibDevs
 
Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378CallumDrakeCPFC
 
Ig2 task 1 work sheet newi9979
Ig2 task 1 work sheet newi9979Ig2 task 1 work sheet newi9979
Ig2 task 1 work sheet newi9979CallumDrakeCPFC
 
Live streaming your podcast
Live streaming your podcastLive streaming your podcast
Live streaming your podcast
Paul Richards
 
Michael williamsig2task1worksheet
Michael williamsig2task1worksheetMichael williamsig2task1worksheet
Michael williamsig2task1worksheetHooaax
 
[@NaukriEngineering] Video handlings on apple platforms
[@NaukriEngineering] Video handlings on apple platforms[@NaukriEngineering] Video handlings on apple platforms
[@NaukriEngineering] Video handlings on apple platforms
Naukri.com
 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014
Chris Adamson
 
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Chris Adamson
 
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
dgmit2009
 
Web Streaming a Radio Station
Web Streaming a Radio StationWeb Streaming a Radio Station
Web Streaming a Radio Stationsean
 
A (Mis-) Guided Tour of the Web Audio API
A (Mis-) Guided Tour of the Web Audio APIA (Mis-) Guided Tour of the Web Audio API
A (Mis-) Guided Tour of the Web Audio API
Edward B. Rockower
 
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_isUplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
Satya Harish
 

Similar to Building Modern Audio Apps with AVAudioEngine (20)

KKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - DolphinKKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Airplay 2 - Dolphin
 
Core audio
Core audioCore audio
Core audio
 
Introduction to AV Foundation
Introduction to AV FoundationIntroduction to AV Foundation
Introduction to AV Foundation
 
Movi presentation Singapore video tech meetup
Movi presentation Singapore video tech meetupMovi presentation Singapore video tech meetup
Movi presentation Singapore video tech meetup
 
Voice That Matter 2010 - Core Audio
Voice That Matter 2010 - Core AudioVoice That Matter 2010 - Core Audio
Voice That Matter 2010 - Core Audio
 
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)
 
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)
 
Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)
 
Web audio, Trackers and Making Music
Web audio, Trackers and Making MusicWeb audio, Trackers and Making Music
Web audio, Trackers and Making Music
 
Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378Ig2 task 1 work sheet 12378
Ig2 task 1 work sheet 12378
 
Ig2 task 1 work sheet newi9979
Ig2 task 1 work sheet newi9979Ig2 task 1 work sheet newi9979
Ig2 task 1 work sheet newi9979
 
Live streaming your podcast
Live streaming your podcastLive streaming your podcast
Live streaming your podcast
 
Michael williamsig2task1worksheet
Michael williamsig2task1worksheetMichael williamsig2task1worksheet
Michael williamsig2task1worksheet
 
[@NaukriEngineering] Video handlings on apple platforms
[@NaukriEngineering] Video handlings on apple platforms[@NaukriEngineering] Video handlings on apple platforms
[@NaukriEngineering] Video handlings on apple platforms
 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014
 
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)
 
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
제 5회 DGMIT R&D 컨퍼런스: Sound Module With OperSLEs
 
Web Streaming a Radio Station
Web Streaming a Radio StationWeb Streaming a Radio Station
Web Streaming a Radio Station
 
A (Mis-) Guided Tour of the Web Audio API
A (Mis-) Guided Tour of the Web Audio APIA (Mis-) Guided Tour of the Web Audio API
A (Mis-) Guided Tour of the Web Audio API
 
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_isUplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
UplinQ - enhance qualcomm® snapdragon™ audio using android audio ap_is
 

More from Bob McCune

Quartz 2D with Swift 3
Quartz 2D with Swift 3Quartz 2D with Swift 3
Quartz 2D with Swift 3
Bob McCune
 
Master Video with AV Foundation
Master Video with AV FoundationMaster Video with AV Foundation
Master Video with AV Foundation
Bob McCune
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
Bob McCune
 
Drawing with Quartz on iOS
Drawing with Quartz on iOSDrawing with Quartz on iOS
Drawing with Quartz on iOS
Bob McCune
 
Core Animation
Core AnimationCore Animation
Core Animation
Bob McCune
 
Objective-C for Java Developers
Objective-C for Java DevelopersObjective-C for Java Developers
Objective-C for Java Developers
Bob McCune
 

More from Bob McCune (6)

Quartz 2D with Swift 3
Quartz 2D with Swift 3Quartz 2D with Swift 3
Quartz 2D with Swift 3
 
Master Video with AV Foundation
Master Video with AV FoundationMaster Video with AV Foundation
Master Video with AV Foundation
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
Drawing with Quartz on iOS
Drawing with Quartz on iOSDrawing with Quartz on iOS
Drawing with Quartz on iOS
 
Core Animation
Core AnimationCore Animation
Core Animation
 
Objective-C for Java Developers
Objective-C for Java DevelopersObjective-C for Java Developers
Objective-C for Java Developers
 

Recently uploaded

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Building Modern Audio Apps with AVAudioEngine

  • 2. -MN Developer and Instructor -Owner of TapHarmonic, LLC. -Author of Learning AV Foundation About... Bob McCune http://LearningAVFoundation.com
  • 3. -What is AVAudioEngine? - Goals and Capabilities -Understanding AVAudioEngine - Understanding Audio Nodes - Playing and Recording Audio - Audio Mixing and Effect Processing - Working with MIDI and Samplers Agenda What will I learn?
  • 4. AV Foundation Evolution Humble Beginnings AV Foundation MediaPlayer AVKit UIKit AppKit Core Video Core MediaCore Animation Audio-Only Core Audio MavericksiOS 7
  • 5. AV Foundation Evolution Humble Beginnings AVKit AVKit UIKit AppKit Core Video Core MediaCore Animation Core Audio AVF Video AVF Audio YosemiteiOS 8
  • 7. -Objective-C API simplifying low-latency, real-time audio -Features and Capabilities: - Read and write audio files in all Core Audio supported formats - Play and record audio using files and buffers - Dynamically configure audio processing blocks - Perform audio tap processing - Perform Stereo and 3D mixing off audio signals - MIDI playback and control over sampler instruments AVAudioEngine Core Audio for Mortals
  • 8. Sample Use Cases What kind of apps can you build?
  • 9. -Manages graphs of audio nodes -Connects audio node into active chains -Dynamically attach and reconfigure graph -Start and stop the engine The Engine AVAudioEngine
  • 10. -Nodes are audio blocks - Source Nodes: Player, Microphone - Processing Nodes: Mixer, Audio Unit Effect - Destination: Speaker, Headphones Nodes AVAudioNode
  • 11. -AVAudioEngine provides 3 implicit nodes: - AVAudioInputNode: system input, cannot be created - AVAudioOutputNode: system output, cannot be created - AVAudioMixerNode: mixes multiple inputs to a single output -Nodes are connected via their input and output busses - Most nodes have one input and one output - AVAudioMixerNode has multiple inputs and one output - Busses have an associated audio format Nodes AVAudioNode
  • 12. -Nodes are connected to form an active chain - Source Node Destination Node = Active Chain - Establishes and active render thread Node Connections Establishing Active Chains Destination Node (Output) Source Node (Player)
  • 13. Node Connections Establishing Active Chains Destination Node (Output) Source Node (Player) Processing Node (Mixer) -Nodes are connected to form an active chain - Source Node Destination Node = Active Chain - Establishes and active render thread
  • 14. Node Connections Establishing Active Chains Destination Node (Output) Source Node (Player) Processing Node (Mixer) X -Nodes are connected to form an active chain - Source Node Destination Node = Active Chain - Establishes and active render thread
  • 15. 1. Create the engine 2. Create the nodes 3. Attach the nodes to the engine 4. Connect the nodes together 5. Start the engine Basic Recipe Configuring the Graph
  • 16. Engine Setup Basic Recipe // 1. Create engine (example only, needs to be strong reference) AVAudioEngine *engine = [[AVAudioEngine alloc] init]; // 2. Create a player node AVAudioPlayerNode *player = [[AVAudioPlayerNode alloc] init]; // 3. Attach node to the engine [engine attachNode:player]; // 4. Connect player node to engine's main mixer AVAudioMixerNode *mixer = engine.mainMixerNode; [engine connect:player to:mixer format:[mixer outputFormatForBus:0]]; // 5. Start engine NSError *error; if (![engine startAndReturnError:&error]) { // handle error }
  • 18. Files, Buffers, and Formats AVAudioPCMBuffer AVAudioFormat AVAudioFile
  • 19. -Reads and writes files in all Core Audio supported formats -Automatically decodes when reading, encodes when writing - Does not support sample rate conversion -File has both a file format and a processing format - fileFormat: on-disk format - processingFormat: uncompressed, in-memory format - Both are instances of AVAudioFormat Audio Files AVAudioFile
  • 20. -Provides a format descriptor for the digital audio samples - Provides access to sample rate, channel count, interleaving, etc. - Wrapper over Core Audio AudioStreamBasicDescription -Core Audio uses a “Standard” format for both platforms - Noninterleaved linear PCM, 32-bit floating point samples - Canonical formats are deprecated! -Additionally supports “Common” formats - AVAudioCommonFormat: 16/32-bit integer, 32/64-but floating point Audio Formats AVAudioFormat
  • 21. -Memory buffer for audio data in any Linear PCM format - Format and buffer capacity defined upon creation -Provides a wrapper over a Core Audio AudioBufferList - audioBufferList and mutableAudioBufferList properties Audio Buffers AVAudioPCMBuffer @property (nonatomic, readonly) float * const *floatChannelData; @property (nonatomic, readonly) int16_t * const *int16ChannelData; @property (nonatomic, readonly) int32_t * const *int32ChannelData; -Sample data accessed using:
  • 22. -Pushes audio data onto the active render thread -Schedule audio data from files and buffers - Scheduled to play immediately or at future time - Future times specified with AVAudioTime - Files - Schedule file or file segment with completion callback - Buffers - Schedule multiple buffers with individual completion callbacks - Schedule looping buffer Player Nodes AVAudioPlayerNode
  • 23. Creating Files and Buffers AVAudioFile and AVAudioPCMBuffer NSURL *url = [[NSBundle mainBundle] URLForResource:@"groove" withExtension:@"m4a"]; // Create AVAudioFile AVAudioFile *file = [[AVAudioFile alloc] initForReading:url error:nil]; // Create AVAudioPCMBuffer AVAudioFormat *format = file.processingFormat; AVAudioFrameCount capacity = (AVAudioFrameCount)file.length; AVAudioPCMBuffer *buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:capacity]; // Read AVAudioFile -> AVAudioPCMBuffer [file readIntoBuffer:buffer error:nil];
  • 24. AVPlayerNode Scheduling Files and Buffers Immediate File Playback [playerNode scheduleFile:audioFile atTime:nil completionHandler:nil]; [playerNode play]; Future Buffer Playback // Play audio file 5 seconds from now double sampleRate = buffer.format.sampleRate; double sampleTime = sampleRate * 5.0; AVAudioTime *futureTime = [AVAudioTime timeWithSampleTime:sampleTime atRate:sampleRate]; [playerNode scheduleBuffer:audioBuffer atTime:futureTime options:0 completionHandler:nil]; [playerNode play]; [playerNode scheduleBuffer:audioBuffer completionHandler:nil]; [playerNode play]; Immediate Buffer Playback
  • 25. -Scheduling multiple buffers queues them serially Scheduling Options AVAudioPlayerNodeBufferOptions [playerNode scheduleBuffer:buffer1 atTime:nil options:0 completionHandler:nil]; [playerNode play]; [playerNode scheduleBuffer:buffer2 atTime:nil options:0 completionHandler:nil]; buffer1 buffer2 time [playerNode scheduleBuffer:buffer2 atTime:nil options:AVAudioPlayerNodeBufferInterrupts completionHandler:nil]; -Schedule with interruption option to change this behavior buffer1 buffer2 time
  • 26. -Schedule a single looping buffer Scheduling Options AVAudioPlayerNodeBufferOptions [playerNode scheduleBuffer:buffer1 atTime:nil options:AVAudioPlayerNodeBufferLoops completionHandler:nil]; buffer1 [playerNode scheduleBuffer:buffer2 atTime:nil options:AVAudioPlayerNodeBufferInterruptsAtLoop completionHandler:nil]; -Schedule with interruption or interruption at loop buffer1 buffer2
  • 28. -Node that mixes multiple inputs into a single output - Efficiently performs sample rate conversions - Can upmix/downmix channel counts where needed Audio Mixing AVAudioMixerNode AVAudioMixerNode Input 1 Input 2
  • 29. -Group and process similar inputs - Simplify and improve efficiency of similar audio processing Audio Mixing Using Submixes AVAudioMixerNode Input 1 Input 2 AVAudioMixerNode Input 3 Input 4 AVAudioMixerNode (main mixer)
  • 30. -AVAudioMixing Protocol: - Defines properties to be applied to an input bus of a mixer node - Source and mixer nodes conform to this protocol Audio Mixing AVAudioMixing AVAudioOutputNodeAVAudioMixerNode AVAudioPlayerNode AVAudioPlayerNode volume pan volume pan Input Bus 0 Input Bus 1
  • 32. -Node tap pulls data off the render thread -Captures the output of a particular node - Record data from microphone - Record data from a pre-recorded or live audio mix - Perform data visualization or analysis -Can install one tap per output bus -Dynamically install and remove taps -Audio data returned in a block callback Node Taps Pulling Data
  • 33. Node Taps Installing a tap AVAudioMixerNode *mixer = self.engine.mainMixerNode; AVAudioFrameCount bufferSize = 4096; AVAudioFormat *format = [mixer outputFormatForBus:0]; [mixer installTapOnBus:0 bufferSize:bufferSize format:format block:^(AVAudioPCMBuffer *buffer, AVAudioTime *when) { // Process AVAudioPCMBuffer }];
  • 35. Effect Nodes Digital Signal Processing -There are two main categories of effects available: - AVAudioUnitEffect: performs real-time audio processing - AVAudioUnitTimeEffect: performs non real-time audio processing AVAudioUnitDelay AVAudioUnitEQ AVAudioUnitDistortion AVAudioUnitReverb AVAudioUnitEffect AVAudioUnitTimeEffect AVAudioUnitTimePitch AVAudioUnitVarispeed
  • 36. -Delays original signal by delay time and mixes with original -Configuration parameters: - delayTime: The delay time of the input signal (up to 2 seconds) - feedback: Amount of output fed back into delay line - lowPassCutoff: Frequency past which high frequencies rolled off - wetDryMix: The blend of wet/dry signals (0% to 100%) Delay AVAudioUnitDelay
  • 37. -Multi-band equalizer and filter unit -Configuration parameters: - bands: Array of AVAudioUnitEQFilterParameters objects - globalGain: Overall gain adjustment applied to input signal (-96 to 24db) Equalization AVAudioUnitEQ
  • 38. -Used to define the EQ parameters to be applied - Retrieved from the AVAudioUnitEQ object’s bands property -Configuration parameters: - filterType: Parametric, Low/High Pass, Band Pass, Low/High Shelf - frequency: The center frequency or cutoff frequency - bandwidth: The width around the main frequency in octaves - gain: The gain adjustment (boost or cut) to the frequency - bypass: The bypass state Equalization (Continued) AVAudioUnitEQFilterParameters
  • 39. -Multi-stage distortion effect of original signal -Configuration presets: - loadFactoryPreset:(AVAudioUnitDistortionPreset)preset - DrumsBitBrush, MultiBrokenSpeaker, SpeechWaves, etc -Configuration parameters: - preGain: Gain applied to signal before distorted (-80dB to 20dB) - wetDryMix: The blend of wet/dry signals (0% to 100%) Distortion AVAudioUnitDistortion
  • 40. -Simulates the reflective qualities of a particular environment -Configuration presets: - loadFactoryPreset:(AVAudioUnitReverbPreset)preset - Small Room, Large Hall, Cathedral, etc. -Configuration parameters: - wetDryMix: The blend of wet/dry signals (0% to 100%) Reverb AVAudioUnitReverb
  • 43. -Musical Instrument Digital Interface -Specification defining: - Communication protocol for controlling electronic instruments - Hardware cables and connectors - Standard MIDI file format -Extensions: - General MIDI (GM) - Downloadable Sounds (DLS) MIDI What is MIDI? http://www.midi.org
  • 44. -High-quality sampler instrument to play sampled sounds -Loads samples in EXS, SF2, or DLS formats - Can additionally load and arbitrary array of sample data -Responds to all standard MIDI messages - Note on/off, controller messages, pitch bend, etc. -Great solution for a live performance instrument - What about playing sequences? Sampling Instrument AVAudioUnitSampler
  • 45. -AVAudioEngine has a musicSequence property - AudioToolbox MusicSequence type -Use the MusicPlayer and MusicSequence APIs - Attach the MusicSequence to the engine to play through Sampler MusicSequence Core MIDI Type
  • 47. -Powerful new addition to AV Foundation - Simplifies low-latency, realtime audio - Great solution for music, audio, and gaming applications - Core Audio for Mortals -Enables you to build advanced audio applications - Read and write audio files - Play and record audio using files and buffers - Add DSP effects: Reverb, Delays, etc. - Perform Stereo and 3D mixing off audio signals - MIDI playback and control over sampler instruments Summary AVAudioEngine