I am trying to implement a simple drum pads machine application with pitch shifting filter. I am using AVAudioEngine API.
There are 12 pads in app. Each pad has own class with its own AVAudioPlayerNode. When there are no other filters connected, the app is working pretty fast. Almost without any delay.
But when I am trying to attach AVAudioUnitTimePitch to the chain, the CPU usage rises up to 100% and the app hangs up after initialization. Was tested on iPad3.
This code goes for each Pad initialization.
_playerNode = [[AVAudioPlayerNode alloc] init];
_pitchFilter = [[AVAudioUnitTimePitch alloc] init];
[_audioEngine attachNode:_playerNode];
[_audioEngine attachNode:_pitchFilter];
[_audioEngine connect:_playerNode to:_pitchFilter format:_buffer.format];
[_audioEngine connect:_pitchFilter to:_audioEngine.mainMixerNode format: _buffer.format];
Is there a way to reduce CPU usage somehow?
P.S. Also I tested this app on iPad Air. And it works. But the CPU usage still is pretty high: 25-30% after init. And about 50% while playing audio.