【发布时间】:2015-12-07 22:41:43
【问题描述】:
我想知道我应该如何从实例化的 SceneKit 场景中提取 SCNRenderer。我正在尝试获取位于 SCNRenderer 中的 AVAudioEngine,以便我可以将音频过滤器应用于我的节点。
这里是覆盖didFinishLaunching 部分简化为相关代码:
override func awakeFromNib() {
// create a new scene
let scene = SCNScene()
// create and add a camera to the scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
// place the camera
cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
// set the scene to the view
self.gameView!.scene = scene
gameView.delegate = self
}
如果有人能给我指点,我将非常感激,因为我能够在位置上运行声音,但现在我坚持使用 AVEngine 图表来执行以下操作:
AVAudioInput > AVAudioUnitDistortion > AVAudioOutput 并开始做一些有趣的混音。
编辑:
这是我对引擎的想法:
distortion = AVAudioUnitDistortion()
let URL = NSURL(fileURLWithPath: dataPath+"/welcome.aiff")
if(NSFileManager.defaultManager().fileExistsAtPath(dataPath+"/welcome.aiff")){
let source = SCNAudioSource(URL: URL)!
source.volume = 30.0
source.reverbBlend = 50.0
source.rate = 0.9
let clip = SCNAudioPlayer(source: source)
engine = clip.audioNode!.engine
distortion.loadFactoryPreset(AVAudioUnitDistortionPreset.SpeechRadioTower)
engine.attachNode(distortion)
engine.connect(clip.audioNode!, to: distortion, format: nil)
engine.connect(self.distortion, to: engine.outputNode, format: nil)
return clip
但是我现在在失真 AVAudioUnitDistortion 实例上有一个空指针异常。
我哪里错了?
【问题讨论】: