SCNAudioPlayer performance issue

Hi!

I am trying to add SCNAudioPlayer to my node that represent monster in the Scene, so I want play positional audio, such monster can be more than 1 etc(1-10) objects, so I clone root node of this monster and add AudioPlayer for each cloned node, but at this time I receive a huge performance issue that my frame rate decries from 60 to 30 frames/sec.


Than I found one way that I can share 1 instance of SCNAudioSouce between all my copies, like it posible with geometry, but its not working for me, because SCNAudioPlayer added only to 1 node from 10 that I cloned.


Source code:

private lazy var _beeMinion: SCNReferenceNode = {
        if let filePath = Bundle.main.path(forResource: "Bee Enemy", ofType: "scn", inDirectory: "art.scnassets"), let refereceNode = SCNReferenceNode(url: URL(fileURLWithPath: filePath)) {
            return refereceNode
        }
        print("Node not loaded !!!")
        abort()
    }()
    var beeMinion: SCNReferenceNode {
        if !_beeMinion.isLoaded {
            _beeMinion.load()
            AudioEngine.instance.actionSoundPlayer?.play3DSound(.BeeMinion, node: _beeMinion, volume: 0.1, delay: 0.0, looping: true, waitForCompletion: true, cooldownTimeInterval: 0.0)
        }
  
        return _beeMinion
    }


And play3DSound method:

audioSource.isPositional = true
 audioSource.volume = volume
 audioSource.loops = looping
 let player = SCNAudioPlayer(source: audioSource)
 node.addAudioPlayer(player)


Can anybody help me how I can play many positional audio asyncronusly without performance issues ?

Best Regurds,

Amin

SCNAudioPlayer performance issue
 
 
Q