AVAudioNode

RSS for tag

Use the AVAudioNode abstract class for audio generation, processing, or I/O block.

Posts under AVAudioNode tag

84 Posts

Post

Replies

Boosts

Views

Activity

Spatial Audio Head Tracking With AVAudioEngine
I want to create a sort of soundscape in surround sound. Imagine something along the lines of the user can place the sound of a waterfall to their front right and the sound of frogs croaking to their left etc. etc. I have an AVAudioEngine playing a number of AVAudioPlayerNodes. I'm using AVAudioEnvironmentNode to simulate the positioning of these. The position seems to work correctly. However, I'd like these to work with head tracking so if the user moves their head the sounds from the players move accordingly. I can't figure out for to do it or find any docs on the subject. Is it possible to make AVAudioEngine output surround sound and if it can would the tracking just work automagically the same as it does when playing surround sound content using AVPlayerItem. If not is the only way to achieve this effect to use CMHeadphonemotionmanager and manually move the listener AVAudioEnvironmentNode listener around?
1
0
2k
Oct ’21
Audio remains mono after turning voiceProcessing off
Using AVAudioEngine with an AVAudioPlayerNode which plays stereo sound works perfectly. I even understand that turning setVoiceProcessingEnabled on the inputNode turns the sound mono. But after I stop the session and the engine, and turn voice processing off, the sound remains mono. This issue is only present with the built in speakers. This is what the I/O formats of the nodes look like before and after the voiceProcessing on-off: Before: mainMixer input<AVAudioFormat 0x281896580: 2 ch, 44100 Hz, Float32, non-inter> mainMixer output<AVAudioFormat 0x2818919f0: 2 ch, 44100 Hz, Float32, non-inter> outputNode input<AVAudioFormat 0x281891cc0: 2 ch, 44100 Hz, Float32, non-inter> outputNode output<AVAudioFormat 0x281891770: 2 ch, 44100 Hz, Float32, non-inter> After: mainMixer input<AVAudioFormat 0x2818acaf0: 2 ch, 44100 Hz, Float32, non-inter> mainMixer output<AVAudioFormat 0x2818acaa0: 1 ch, 44100 Hz, Float32> outputNode input<AVAudioFormat 0x281898820: 1 ch, 44100 Hz, Float32> outputNode output<AVAudioFormat 0x2818958b0: 2 ch, 44100 Hz, Float32, non-inter> Sadly just changing the connection type does not solve anything, I already tried that with (this solves the stereo issue on headphones, but not on built in speakers): let format = AVAudioFormat(standardFormatWithSampleRate: 48000, channels: 2)! audioEngine.connect(audioEngine.mainMixerNode, to: audioEngine.outputNode, format: format)
0
0
853
Sep ’21
AVAudioSinkNode v.s AVAudioNode "installTap(::)"
I'm trying to understand the difference between the use of an AVAudioSinkNode v.s installTap() on an AVAudioNode. In "WWDC 510 - Whats new in core audio" https://developer.apple.com/videos/play/wwdc2019/510, the presenter states that AVAudioSinkNode works in a realtime context (better for VOIP, for example) where as installTap() on an AVAudioNode does not. It's unclear to me why one is better to use over the other. Why is AVAudioSinkNode better for realtime apps over using installTap()??
1
0
911
Aug ’21
Playing samples from external MIDI multi pad instrument
Hi, I am developing an application in Objective-C in which at a given moment I have to play samples (its duration is 1 second aprox) when the user hits a pad of his instrument (which has several pads). I receive the notes through a MIDI interface (CoreMIDI-Wrapper, available in Github) and to play the samples I'm doing the following: Previously I have an AVAudioEngine instantiated and in its mixer node (AVAudioMixerNode) I have attached 16 AVAudioPlayerNode. I have an integer (iCurrentNode ranging from 0 to 15) that points to the current AVAudioPlayerNode. When the user hits a pad I do: [aAVAudioPlayerNode[iCurrentNode] scheduleBuffer:PCMbuffer_note atTime:nil completionHandler{}]; iCurrentNode++; if(iCurrentNode == 16)iCurrentNode = 0; The reason for the 16 playback nodes is that scheduleBuffer does not allow overlapping sounds. Therefore, if the user hits a pad and hits it again before the first sound has finished playing, that is queued instead of being overlapped. The implementation gives me too lag on iPad Pro 10,5" (about half a second). I think I have done a bad approach to the problem... Somebody could help me? Thanks
0
0
911
Jul ’21
Spatial Audio Head Tracking With AVAudioEngine
I want to create a sort of soundscape in surround sound. Imagine something along the lines of the user can place the sound of a waterfall to their front right and the sound of frogs croaking to their left etc. etc. I have an AVAudioEngine playing a number of AVAudioPlayerNodes. I'm using AVAudioEnvironmentNode to simulate the positioning of these. The position seems to work correctly. However, I'd like these to work with head tracking so if the user moves their head the sounds from the players move accordingly. I can't figure out for to do it or find any docs on the subject. Is it possible to make AVAudioEngine output surround sound and if it can would the tracking just work automagically the same as it does when playing surround sound content using AVPlayerItem. If not is the only way to achieve this effect to use CMHeadphonemotionmanager and manually move the listener AVAudioEnvironmentNode listener around?
Replies
1
Boosts
0
Views
2k
Activity
Oct ’21
Audio remains mono after turning voiceProcessing off
Using AVAudioEngine with an AVAudioPlayerNode which plays stereo sound works perfectly. I even understand that turning setVoiceProcessingEnabled on the inputNode turns the sound mono. But after I stop the session and the engine, and turn voice processing off, the sound remains mono. This issue is only present with the built in speakers. This is what the I/O formats of the nodes look like before and after the voiceProcessing on-off: Before: mainMixer input<AVAudioFormat 0x281896580: 2 ch, 44100 Hz, Float32, non-inter> mainMixer output<AVAudioFormat 0x2818919f0: 2 ch, 44100 Hz, Float32, non-inter> outputNode input<AVAudioFormat 0x281891cc0: 2 ch, 44100 Hz, Float32, non-inter> outputNode output<AVAudioFormat 0x281891770: 2 ch, 44100 Hz, Float32, non-inter> After: mainMixer input<AVAudioFormat 0x2818acaf0: 2 ch, 44100 Hz, Float32, non-inter> mainMixer output<AVAudioFormat 0x2818acaa0: 1 ch, 44100 Hz, Float32> outputNode input<AVAudioFormat 0x281898820: 1 ch, 44100 Hz, Float32> outputNode output<AVAudioFormat 0x2818958b0: 2 ch, 44100 Hz, Float32, non-inter> Sadly just changing the connection type does not solve anything, I already tried that with (this solves the stereo issue on headphones, but not on built in speakers): let format = AVAudioFormat(standardFormatWithSampleRate: 48000, channels: 2)! audioEngine.connect(audioEngine.mainMixerNode, to: audioEngine.outputNode, format: format)
Replies
0
Boosts
0
Views
853
Activity
Sep ’21
AVAudioSinkNode v.s AVAudioNode "installTap(::)"
I'm trying to understand the difference between the use of an AVAudioSinkNode v.s installTap() on an AVAudioNode. In "WWDC 510 - Whats new in core audio" https://developer.apple.com/videos/play/wwdc2019/510, the presenter states that AVAudioSinkNode works in a realtime context (better for VOIP, for example) where as installTap() on an AVAudioNode does not. It's unclear to me why one is better to use over the other. Why is AVAudioSinkNode better for realtime apps over using installTap()??
Replies
1
Boosts
0
Views
911
Activity
Aug ’21
Playing samples from external MIDI multi pad instrument
Hi, I am developing an application in Objective-C in which at a given moment I have to play samples (its duration is 1 second aprox) when the user hits a pad of his instrument (which has several pads). I receive the notes through a MIDI interface (CoreMIDI-Wrapper, available in Github) and to play the samples I'm doing the following: Previously I have an AVAudioEngine instantiated and in its mixer node (AVAudioMixerNode) I have attached 16 AVAudioPlayerNode. I have an integer (iCurrentNode ranging from 0 to 15) that points to the current AVAudioPlayerNode. When the user hits a pad I do: [aAVAudioPlayerNode[iCurrentNode] scheduleBuffer:PCMbuffer_note atTime:nil completionHandler{}]; iCurrentNode++; if(iCurrentNode == 16)iCurrentNode = 0; The reason for the 16 playback nodes is that scheduleBuffer does not allow overlapping sounds. Therefore, if the user hits a pad and hits it again before the first sound has finished playing, that is queued instead of being overlapped. The implementation gives me too lag on iPad Pro 10,5" (about half a second). I think I have done a bad approach to the problem... Somebody could help me? Thanks
Replies
0
Boosts
0
Views
911
Activity
Jul ’21