Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
iOSにおけるサウンド処理
2015
• me.name = “Tamiya Tokihiko”
• me.company = “Classmethod, Inc.”
• company.blog = “Developers.IO”
自己紹介(プロパティ)
概要
• AVAudioEngine
• iOS 8 から加わったクラス
• Audio Unit Extension
• iOS 9 で追加されたExtension Point
• Audio Unit をアプリ間で共有できる
• AVAud...
AVAudioEngine
このままだと不便
© Apple
© Apple
AVFoudation が拡充
© Apple
© Apple
AVAudioEngine
AVAudioPlayer
Node
AVAudioUnit
Delay
AVAudioMixer
Node
AVAudio
OutputNode
AVAudioFile
@property (nonatomic, strong) AVAudioEngine *engine;
@property (nonatomic, strong) AVAudioPlayerNode *audioPlayerNode;
@pr...
self.engine = [AVAudioEngine new];
NSString *path = [[NSBundle mainBundle]
pathForResource:@"loop.m4a" ofType:nil];
self.a...
self.audioPlayerNode = [AVAudioPlayerNode new];
[self.engine attachNode:self.audioPlayerNode];
AVAudioPlayerNode
AVAudioEn...
self.audioUnitDelay = [AVAudioUnitDelay new];
self.audioUnitDelay.wetDryMix = 50;
[self.engine attachNode:self.audioUnitDe...
AVAudioMixerNode *mixerNode = [self.engine
mainMixerNode];
AVAudioEngine
AVAudioPlayer
Node
AVAudioUnit
Delay
AVAudioMixer...
[self.engine connect:self.audioPlayerNode
to:self.audioUnitDelay
format:self.audioFile.processingFormat];
AVAudioEngine
AV...
[self.engine connect:self.audioUnitDelay
to:mixerNode
format:self.audioFile.processingFormat];
AVAudioEngine
AVAudioPlayer...
NSError *error;
[self.engine startAndReturnError:&error];
AVAudioEngine
AVAudioPlayer
Node
AVAudioUnit
Delay
AVAudioMixer
...
AVAudioPlayerNodeで
音を再生
AVAudioEngine
AVAudioPlayer
Node
AVAudioUnit
Delay
AVAudioMixer
Node
[self.audioPlayerNode schedul...
/*! @property delayTime
Time taken by the delayed input signal to reach the
output
@abstract
Range: 0 -> 2
Default: 1
Unit...
/*! @property lowPassCutoff
@abstract
Cutoff frequency above which high frequency content is
rolled off
Range: 10 -> (samp...
demo
AudioUnitExtension
© Apple
AVAudioPlayer
Node
AVAudioUnit
Delay
AVAudioMixer
Node
AVAudio
OutputNode
AVAudioFile
@property (nonatomic) AVAudioEngine *engine;
@property (nonatomic) AVAudioPlayerNode
*audioPlayerNode;
@property (nonatomi...
self.audioPlayerNode = [AVAudioPlayerNode new];
self.engine = [AVAudioEngine new];
self.effect = [AVAudioUnit new];
[self....
[self.engine connect:self.audioPlayerNode
to:self.engine.mainMixerNode
format:self.file.processingFormat];
ノード同士をつなぐ
AVAudioUnitComponent
が入った配列を取得
AudioComponentDescription anyEffectDescription;
anyEffectDescription.componentType = kAudio...
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.engine startAndReturnError:nil];
[self sche...
[self.audioPlayerNode pause];
[self.engine disconnectNodeInput:self.effect];
[self.engine
disconnectNodeInput:self.engine....
self.effect = audioUnit;
(略)
[self.engine connect:self.audioPlayerNode to:self.effect
format:self.file.processingFormat];
...
AVAudioUnitComponent *auComponent
 = self.items[indexPath.row - 1];
auComponent.name;
auComponent.manufacturerName;
AVAudi...
auComponent = self.items[indexPath.row - 1];
[self
selectEffectWithComponentDescription:auComponent
.audioComponentDescrip...
[self.audioUnit
requestViewControllerWithCompletionHandler:
^(AUViewController * _Nullable
viewController) {}];
独自の View を...
demo
AVAudioSessionMode
SpokenAudio
声のコンテンツでありがちな問題
聞き逃した!
Podcast に切替え
巻き戻し
早送り
再生
AVAudioSessionCategoryOptionInterrupt
SpokenAudioAndMixWithOthers
AVAudioSessionModeSpokenAudio
一時停止
ちょっと巻き戻し
概要
• AVAudioEngine
• iOS 8 から加わったクラス
• Audio Unit Extension
• iOS 9 で追加されたExtension Point
• Audio Unit をアプリ間で共有できる
• AVAud...
Próxima SlideShare
Cargando en…5
×

iOS におけるサウンド処理2015

2.212 visualizaciones

Publicado el

iOS 9 週連続 Bootcamp 2週目 で発表した内容です。
http://dev.classmethod.jp/news/ios9-bootcamp-2nd/

Publicado en: Ingeniería
  • Sé el primero en comentar

iOS におけるサウンド処理2015

  1. 1. iOSにおけるサウンド処理 2015
  2. 2. • me.name = “Tamiya Tokihiko” • me.company = “Classmethod, Inc.” • company.blog = “Developers.IO” 自己紹介(プロパティ)
  3. 3. 概要 • AVAudioEngine • iOS 8 から加わったクラス • Audio Unit Extension • iOS 9 で追加されたExtension Point • Audio Unit をアプリ間で共有できる • AVAudioSessionModeSpokenAudio • 声コンテンツが他アプリの音声の妨げにならない仕組み
  4. 4. AVAudioEngine
  5. 5. このままだと不便 © Apple
  6. 6. © Apple
  7. 7. AVFoudation が拡充 © Apple
  8. 8. © Apple
  9. 9. AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node AVAudio OutputNode AVAudioFile
  10. 10. @property (nonatomic, strong) AVAudioEngine *engine; @property (nonatomic, strong) AVAudioPlayerNode *audioPlayerNode; @property (nonatomic, strong) AVAudioFile *audioFile; @property (nonatomic, strong) AVAudioUnitDelay *audioUnitDelay; プロパティ
  11. 11. self.engine = [AVAudioEngine new]; NSString *path = [[NSBundle mainBundle] pathForResource:@"loop.m4a" ofType:nil]; self.audioFile = [[AVAudioFile alloc] initForReading:[NSURL fileURLWithPath:path] error:nil]; AVAudioEngine と AVAudioFile AVAudioEngine
  12. 12. self.audioPlayerNode = [AVAudioPlayerNode new]; [self.engine attachNode:self.audioPlayerNode]; AVAudioPlayerNode AVAudioEngine AVAudioPlayer Node
  13. 13. self.audioUnitDelay = [AVAudioUnitDelay new]; self.audioUnitDelay.wetDryMix = 50; [self.engine attachNode:self.audioUnitDelay]; AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioUnitDelay
  14. 14. AVAudioMixerNode *mixerNode = [self.engine mainMixerNode]; AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node AVAudioMixerNode を生成
  15. 15. [self.engine connect:self.audioPlayerNode to:self.audioUnitDelay format:self.audioFile.processingFormat]; AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node ノード同士をつなぐ
  16. 16. [self.engine connect:self.audioUnitDelay to:mixerNode format:self.audioFile.processingFormat]; AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node ノード同士をつなぐ
  17. 17. NSError *error; [self.engine startAndReturnError:&error]; AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node
  18. 18. AVAudioPlayerNodeで 音を再生 AVAudioEngine AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node [self.audioPlayerNode scheduleFile:self.audioFile atTime:nil completionHandler:^() {}]; AVAudio OutputNode AVAudioFile
  19. 19. /*! @property delayTime Time taken by the delayed input signal to reach the output @abstract Range: 0 -> 2 Default: 1 Unit: Seconds */ @property (nonatomic) NSTimeInterval delayTime; /*! @property feedback @abstract Amount of the output signal fed back into the delay line Range: -100 -> 100 Default: 50 Unit: Percent */ @property (nonatomic) float feedback; AVAudioUnitDelay.h
  20. 20. /*! @property lowPassCutoff @abstract Cutoff frequency above which high frequency content is rolled off Range: 10 -> (samplerate/2) Default: 15000 Unit: Hertz */ @property (nonatomic) float lowPassCutoff; /*! @property wetDryMix @abstract Blend of the wet and dry signals Range: 0 (all dry) -> 100 (all wet) Default: 100 Unit: Percent */ @property (nonatomic) float wetDryMix; AVAudioUnitDelay.h
  21. 21. demo
  22. 22. AudioUnitExtension
  23. 23. © Apple
  24. 24. AVAudioPlayer Node AVAudioUnit Delay AVAudioMixer Node AVAudio OutputNode AVAudioFile
  25. 25. @property (nonatomic) AVAudioEngine *engine; @property (nonatomic) AVAudioPlayerNode *audioPlayerNode; @property (nonatomic) AVAudioFile *file; @property (nonatomic) AUAudioUnit *audioUnit; @property (nonatomic) AVAudioUnit *effect; @property (nonatomic) NSArray *items; プロパティ
  26. 26. self.audioPlayerNode = [AVAudioPlayerNode new]; self.engine = [AVAudioEngine new]; self.effect = [AVAudioUnit new]; [self.engine attachNode:self.audioPlayerNode];
  27. 27. [self.engine connect:self.audioPlayerNode to:self.engine.mainMixerNode format:self.file.processingFormat]; ノード同士をつなぐ
  28. 28. AVAudioUnitComponent が入った配列を取得 AudioComponentDescription anyEffectDescription; anyEffectDescription.componentType = kAudioUnitType_Effect; anyEffectDescription.componentSubType = 0; anyEffectDescription.componentManufacturer = 0; anyEffectDescription.componentFlags = 0; anyEffectDescription.componentFlagsMask = 0; self.items = [[AVAudioUnitComponentManager sharedAudioUnitComponentManager] componentsMatchingDescription:anyEffectDescription];
  29. 29. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.engine startAndReturnError:nil]; [self scheduleLoop]; [self.audioPlayerNode play]; } - (void)scheduleLoop { [self.audioPlayerNode scheduleFile:self.file atTime:nil completionHandler:^{ [self scheduleLoop]; }]; } AVAudioPlayerNode 再生
  30. 30. [self.audioPlayerNode pause]; [self.engine disconnectNodeInput:self.effect]; [self.engine disconnectNodeInput:self.engine.mainMixerNode]; [self.engine connect:self.audioPlayerNode to:self.engine.mainMixerNode format:self.file.processingFormat]; self.effect = nil; self.audioUnit = nil; ノードをつなぎ直す
  31. 31. self.effect = audioUnit; (略) [self.engine connect:self.audioPlayerNode to:self.effect format:self.file.processingFormat]; [self.engine connect:self.effect to:self.engine.mainMixerNode format:self.file.processingFormat]; 特定のエフェクトを実現する AVAudioUnit を取得 [AVAudioUnit instantiateWithComponentDescription:componentDescription options:kAudioComponentInstantiation_LoadOutOfProcess completionHandler:^(__kindof AVAudioUnit * _Nullable audioUnit, NSError * _Nullable error) {}]; AVAudioUnit を使いノードをつなぐ
  32. 32. AVAudioUnitComponent *auComponent  = self.items[indexPath.row - 1]; auComponent.name; auComponent.manufacturerName; AVAudioUnitComponent の名前・製造元
  33. 33. auComponent = self.items[indexPath.row - 1]; [self selectEffectWithComponentDescription:auComponent .audioComponentDescription];
  34. 34. [self.audioUnit requestViewControllerWithCompletionHandler: ^(AUViewController * _Nullable viewController) {}]; 独自の View を持っている場合 取得
  35. 35. demo
  36. 36. AVAudioSessionMode SpokenAudio
  37. 37. 声のコンテンツでありがちな問題
  38. 38. 聞き逃した! Podcast に切替え 巻き戻し 早送り 再生
  39. 39. AVAudioSessionCategoryOptionInterrupt SpokenAudioAndMixWithOthers
  40. 40. AVAudioSessionModeSpokenAudio
  41. 41. 一時停止 ちょっと巻き戻し
  42. 42. 概要 • AVAudioEngine • iOS 8 から加わったクラス • Audio Unit Extension • iOS 9 で追加されたExtension Point • Audio Unit をアプリ間で共有できる • AVAudioSessionModeSpokenAudio • 声コンテンツが他アプリの音声の妨げにならない仕組み

×