iPadで音声に効果をつけられるエフェクターアプリを製作したいと思っています。色々なサイトを参考にして以下のようなコードになりました。プログラムの内容は、ボタンを押すとマイクから入力された音が、エフェクト処理されスピーカーから出るという内容です。
Swift
1import UIKit 2import AVFoundation 3class ViewController: UIViewController { 4 5 let engine = AVAudioEngine() 6 let format = AVAudioFormat() 7 @IBAction func PushEffect(sender: AnyObject){ 8 9 do{ 10 let delay = AVAudioUnitDelay() 11 12 engine.attach(delay) 13 14 let inputNode = engine.inputNode! 15 let outputNode = engine.outputNode 16 17 engine.connect(inputNode, to: delay, format: format) 18 engine.connect(delay, to: outputNode, format: format) 19 20 delay.delayTime = 1.5 21 delay.feedback = 20 22 do{ 23 try engine.start() 24 }catch let error{ 25 print("ERROR",error) 26 } 27 } 28 } 29 override func viewDidLoad() { 30 super.viewDidLoad() 31 // Do any additional setup after loading the view, typically from a nib. 32 } 33 34 override func didReceiveMemoryWarning() { 35 super.didReceiveMemoryWarning() 36 // Dispose of any resources that can be recreated. 37 } 38 39 40} 41
ですが実行すると以下のエラーが出てフリーズしてしまいます。
Swift
12017-01-27 12:34:25.731812 Effecter2[5859:1470997] [Accessibility] ****************** Loading GAX Client Bundle **************** 22017-01-27 12:34:27.144009 Effecter2[5859:1470997] [central] 54: ERROR: [0x1aba66c40] >avae> AVAudioEngineGraph.mm:1664: _Connect: required condition is false: IsFormatSampleRateAndChannelCountValid(format) 32017-01-27 12:34:27.144400 Effecter2[5859:1470997] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)' 4*** First throw call stack: 5(0x186a0d1b8 0x18544455c 0x186a0d08c 0x19fec7300 0x19fedbfec 0x19fedf708 0x19ff4725c 0x19ff47318 0x1000ff018 0x1000ff40c 0x18c8f0d30 0x18c8f0cb0 0x18c8db128 0x18c8f059c 0x18c8f00c4 0x18c8eb328 0x18c8bbda0 0x18d0a575c 0x18d09f130 0x1869bab5c 0x1869ba4a4 0x1869b80a4 0x1868e62b8 0x18839a198 0x18c9267fc 0x18c921534 0x100101614 0x1858c95b8) 6libc++abi.dylib: terminating with uncaught exception of type NSException
iPad iOS10.2 (14C92)
Xcode Version 8.2.1 (8C1002)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/27 14:45
2017/01/28 08:43
2017/01/28 11:23