What's New in AVAudioEngine
이번 세션 내용은 Audio API 변경에 대한 세션입니다.
AVAudioEngine
AVAudioEngine 개선사항
- Voice processing 지원
- 새로운 실시간 오디오 입력 출력 node
- AVAudioSinkNode
- AVAudioSourceNode
- Spatial audio rendering 개선
AVAudioEngine - Voice Processing
- VoIP app 안에서 사용
- 수동 렌더링 모드에서는 지원하지 않음
- 입력 또는 출력 노드 중 하나를 설정함
echo cancellation의 경우 입출력 노드 모두 voice processing mode에서 작동한다.
✅ Source and Sink Node
앱이 AVAudioEngine으로부터 음성을 보내거나 받도록 허용하는 사용자 정의된 블럭으로 래핑한다.
- AVAudioSinkNode
- AVAudioSourceNode
- 장치에서 렌더링될 때 블럭은 실시간 제약에서 작동하며 메모리 할당, lib dispatch, mutex에 대한 차단과 같은 호출을 하면 안된다.
✅ AVAudioSourceNode
오디오 IO 쓰레드의 데이터에 음성을 제공하는 사용자 정의 렌더링 블럭을 래핑한다.
- 실시간, 수동 렌더링 모드를 모두 지원한다.
- 샘플 비율이나 bit depth 변환 같은
선형 PCM 변환
을 지원한다. - 1개의 output bus를 가지며 입력은 없다.
- 예제 - Building a Signal Generator
// Create Engine
let engine = AVAudioEngine()
// Create and Attach AVAudioSourceNode
let sourceNode = AVAudioSourceNode() { (silence, timeStamp, frameCount, audioBufferList) -> OSStatus in
let ablPointer = UnsafeMutableAudioBufferListPointer(audioBufferList)
for buffer in ablPointer {
...
}
return noErr
}
✅ AVAudioSinkNode
오디오 IO 쓰레드에서 입력을 받도록 사용자 정의 블록을 래핑한다.
- 반드시 입력 노드의 downstream이어야 하며 실시간에서 동작해야 한다.
- 포맷 변환을 지원하지 않으며 포맷은 하드웨어 입력 포맷과 같은 형식을 가져야 한다.
- 1개의 input bus를 가지며 출력은 없다.
- AVAudioSourceNode와 꽤 비슷하다.
// Create Engine
let engine = AVAudioEngine()
// Create and Attach AVAudioSinkNode
let sinkNode = AVAudioSinkNode() { (timeStamp, frames, audioBufferList) -> OSStatus in
...
}
engine.attach(sourceNode)
✅ AVAudioEngine - Spatial Rendering
Automatic spatial rendering algorithm
멀티채널 오디오 컨텐츠의 spatialization 지원을 개선
Auto Spatial Rendering Algorithm
현재 방법에 가장 적절한 spatialization algorithm이 자동으로 선택된다.
→ 이것은 개발자들이 어떤 알고리즘이 헤드폰이나 다른 스피커 설정에 알맞는지 찾을 필요가 없다는 것을 의미한다.
헤드폰을 렌더링하기 위해 near-field와 in-head rendering이 추가되었다.
빌트인 스피커를 위한 가상 서라운드는 2018년 이후 출시된 iOS 기기와 랩탑에서 사용 가능하다.
✅ AVAudio3DMixing
AVAudio3DMixingRenderingAlgorithm
enum은 auto
라는 새로운 entry를 가진다.
Property를 auto로 설정해서 output type은 실시간 mode 안에서 자동으로 감지될 수 있다.
public enum AVAudio3DMixingRenderingAlgorithm : Int {
...
case auto
}
open var outputType: AVAudioEnvironmentOutputType
public enum AVAudioEnvironmentOutputType : Int {
case auto
}
✅ Ability to Spatialize Multichannel Stream
point-source, ambience bed rendering 지원
채널 기반 포맷과 3차 higher-order Ambisonics를 지원
pointSource
- 오디오가 모노로 합쳐져 플레이어 노드의 위치에서 렌더링ambienceBed
- 오디오가 3D 세계에 고정되고 청취자 방향을 기준으로 플레이어 노드의 위치로 회전 가능
var sourceMode: AVAudio3DMixingSourceMode
public enum AVAudio3DMixingSourceMode : Int {
case spatializeIfMono
case bypass
case pointSource
case ambienceBed
}
var pointSourceInHeadMode: AVAudio3DMixingPointSourceInHeadMode
public enum AVAudio3DMixingPointSourceInHeadMode : Int {
case mono
case bypass
}
//---------------------------------------------------
//Example: Ambience Bed with Auto Rendering Algorithm
let engine = AVAudioEngine()
// Create and Configure Environment Node
let environment = AVAudioEnvironmentNode()
// use automatic detection of output type (does not work inManual Rendering modes)
environment.outputType = .auto
engine.attach(environment)
// Create an Ambience Bed Using Auto Rendering Algorithmlet
player = AVAudioPlayerNode()
player.renderingAlgorithm = .auto
What's New in AVAudioSession
✅ AVAudioSessionPromptStyle
재생되는 prompts의 스타일을 수정하기 위해 음성 prompts를 재생하는 앱들에게 힌트가 된다. (A hint to apps that play voice prompts to modify the style of prompt played)
- prompt 스타일은 Siri나 전화같은 시스템 위에 다른 오디오 액티비티가 반응하면 변경된다.
- 더 나은 사용자 경험을 위해 내비게이션 앱에 추천된다.
none
- 현재 앱에 prompt가 표시되지 않게 하는 옵션short
- 앱은 짧고 비 언어적 prompt를 발행해야 하는 옵션normal
- 앱에서 긴 음성 안내를 사용할 수 있는 옵션
✅ Other AVAudioSession Enhancements
기본 방침은 오디오 녹화가 실행 중일 때 haptic과 시스템 사운드를 음소거 해야 한다.
새로운 프로퍼티인 allow haptics and system sounds during recording
는 오디오 입력을 사용하는 세션이 활성화된 동안 시스템 사운드와 haptic 재생하는 것을 허용한다.
'Programming > WWDC' 카테고리의 다른 글
WWDC20 Keynote Summary (0) | 2020.06.26 |
---|---|
Accessibility Inspector - WWDC2019 (0) | 2020.06.21 |
Embedding and Sharing Visually Rich Links 정리 - WWDC2019 (0) | 2020.05.31 |
Face Tracking with ARKit 정리 - Tech talks (0) | 2020.05.22 |
Creating a Great Accessible Reading Experience 정리 - WWDC19 (0) | 2020.05.14 |