Tag: avivoundation

AVAudioPlayerNode不播放声音

我正在尝试使用下面的代码生成声音。 Everthing罚款没有错误。 但是当我执行这个代码时,没有声音。 我该如何解决这个问题? 顺便说一句,我使用这个例子: http : //www.tmroyal.com/playing-sounds-in-swift-audioengine.html var ae:AVAudioEngine var player:AVAudioPlayerNode? var mixer:AVAudioMixerNode var buffer:AVAudioPCMBuffer ae = AVAudioEngine() player = AVAudioPlayerNode() mixer = ae.mainMixerNode; buffer = AVAudioPCMBuffer(pcmFormat: player!.outputFormat(forBus:0), frameCapacity: 100) buffer.frameLength = 100 // generate sine wave. var sr:Float = Float(mixer.outputFormat(forBus:0).sampleRate) var n_channels = mixer.outputFormat(forBus:0).channelCount var i:Int=0 while i < Int(buffer.frameLength) { var val […]