AudioUnit

RSS for tag

Create audio unit extensions and add sophisticated audio manipulation and processing capabilities to your app using AudioUnit.

Posts under AudioUnit tag

139 Posts

Post

Replies

Boosts

Views

Activity

Low level audio recording on macOS. Please Help!
I am struggling to see why the following low-level audio recording function - which is based on tn2091 - Device input using the HAL Output Audio Unit - (a great article, btw, although a bit dated, and it would be wonderful if it was updated to use Swift and non deprecated stuff at some point!) fails to work under macOS: func createMicUnit() -> AUAudioUnit { let compDesc = AudioComponentDescription( componentType: kAudioUnitType_Output, componentSubType: kAudioUnitSubType_HALOutput, // I am on macOS, os this is good componentManufacturer: kAudioUnitManufacturer_Apple, componentFlags: 0, componentFlagsMask: 0) return try! AUAudioUnit(componentDescription: compDesc, options: []) } func startMic() { // mic permision is already granted at this point, but let's check let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.audio) precondition(status == .authorized) // yes, all good let unit = createMicUnit() unit.isInputEnabled = true unit.isOutputEnabled = false precondition(!unit.canPerformInput) // can't record yet, and know why? print(deviceName(unit.deviceID)) // "MacBook Pro Speakers" - this is why let micDeviceID = defaultInputDeviceID print(deviceName(micDeviceID)) // "MacBook Pro Microphone" - this is better try! unit.setDeviceID(micDeviceID) // let's switch device to mic precondition(unit.canPerformInput) // now we can record print("\(String(describing: unit.channelMap))") // channel map is "nil" by default unit.channelMap = [0] // not sure if this helps or not let sampleRate = deviceActualFrameRate(micDeviceID) print(sampleRate) // 48000.0 let format = AVAudioFormat( commonFormat: .pcmFormatFloat32, sampleRate: sampleRate, channels: 1, interleaved: false)! try! unit.outputBusses[1].setFormat(format) unit.inputHandler = { flags, timeStamp, frameCount, bus in fatalError("never gets here") // now the weird part - this is never called! } try! unit.allocateRenderResources() try! unit.startHardware() // let's go! print("mic should be working now... why it doesn't?") // from now on the (UI) app continues its normal run loop } All sanity checks pass with flying colors but unit's inputHandler is not being called. Any idea why? Thank you!
3
0
2.5k
Jan ’23
AUv3 -- deinit / dealloc never called
Hi, I am designing an AUv3 plugin for Logic / Garageband. I heavily relied upon the AUv3Filter demo supplied by Apple due to lack of documentation on building AUv3 plugins. However, I noticed a problem both in my plugin and Apple's AUv3Filter demo plugin. When I add a deinit function to Apple's AUv3FilterDemo.swift class, it never gets called. Not when the plugin is removed from a Logic project, not when Logic exits, never. My plugin, unsurprisingly, has the same problem (dealloc / Objective-C). It's pretty serious however, because my plugin is a wrapper for a C++ class that has a lot of stuff going on and needs to be deconstructed when it finishes running. I spent a few hours with Apple's demo trying to track down any strong references that might persist after the plugin exits, but nothing I did seemed to make any difference. Anybody else have this issue?
3
1
2.1k
Jan ’23
AUv2 development on Xcode 14
Hi, I want to do some work on an audio unit after a gap of (many) years, and am not clear about the status of v2 AUs. There's no template for them in the current Xcode, and the relevant CoreAudio classes (AUBase and subclasses) are also absent. Have I missed some optional download from Apple that restores these things, or is it all over for v2?
2
0
1.4k
Nov ’22
[AudioUnit] kAudioUnitSubType_NewTimePitch make music quality very bad after iOS 16
We have a music type app, and I've received some users feedback that complain about the music quality become very bad after update to iOS 16. At last, we found the reason is that they shift the pitch by using "kAudioUnitSubType_NewTimePitch" which is one of our offered function. iOS 15 and other earlier version can works well. Is there any Apple engineer can solve my problem?
1
0
1k
Oct ’22
file unit callback shows stereo channels in buffer, but the file loaded was 6 channel
I want to generate a sample withAudioFilePlayerUnit to play 6 channel audio file. The issue here is that, the AudioFilePlayerUnit callback shows stereo channel in buffer, but the file loaded to the fileUnit was of 6 channels. I have tried setting the input and output format for the fileUnit to that of file's stream format(6 channels), but still the callback shows stereo channels in buffer. I have added my code snippet below. OSStatus error = AudioFileOpenURL(audioFileURL, kAudioFileReadPermission, 0, &_audioInputFileId); UInt32 dataSize = sizeof(AudioStreamBasicDescription); AudioFileGetProperty(_audioInputFileId, kAudioFilePropertyDataFormat, &dataSize, &_fileStreamDescription); setting the input and outputFormat for the unit : UInt32 propertySize = sizeof(_fileStreamDescription); AudioUnitScope scope = kAudioUnitScope_Input; OSStatus err = AudioUnitSetProperty(filePlayerUnit, kAudioUnitProperty_StreamFormat, scope, 0, &_fileStreamDescription, propertySize); OSStatus err = AudioUnitSetProperty(filePlayerUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &_fileStreamDescription, propertySize); here setting the input and output format also throws error. I have added the callback using AudioUnitRenderNotify method to the fileUnit but when check the buffer in the callback I can see it returning as stereo channels.
1
0
1.3k
Oct ’22
AUAudioUnit – Impossible to handle frame count limitation in render?
Summary: I've created an AUAudioUnit to host some third party signal processing code and am running into a edge case limitation where I can only process and supply output audio data (from the internalRenderBlock) if it's an exact multiple of a specific number of frames. More Detail: This third party code ONLY works with exactly 10ms of data at time. For example, say with 48khz audio, it only accepts 480 frames on each processing function call. If the AUAudioUnit's internalRenderBlock is called with 1024 frames as the frame count, I can use the pullInputBlock to get 480 frames, process it, another 480 frames, and process that, but what should I then do with the remaining 64 frames? Possible Solutions Foiled: a) It seems there's no way to indicate to the host that I have only consumed 960 frames and will only be supplying 960 frames of output. I thought perhaps the host would observe that if the outputData ABL buffers have less than the frame count passed into the internalRenderBlock, that it might appropriately advance the timestamp only by that much the next time time around, but it does not. So it's required that all the audio be processed before the block returns, but I can only do that if the block is requested to handle exactly a multiple of 10ms of data. b) I can't buffer up the "remainder" input and process it on the next internalRenderBlock cycle because all of the output must be provided on return as discussed in A. c) As an alternative, I see no way to have the unit explicitly indicate to the host, how many frames the unit can process at a time. maximumFramesToRender is the host telling the unit (not the reverse), and either way it's a maximum only, not a minumum as well. What can I do?
1
0
2.5k
Aug ’22
Swift generics cause a loading error
Hello, I've tried to make my AudioUnitViewController more generic. Here minimal example of what I have: open class AudioUnitViewControllerBase<T>: AUViewController, AUAudioUnitFactory { private var audioUnit: AUAudioUnit? open override func loadView() { view = NSView() } open func createAudioUnit(with desc: AudioComponentDescription) throws -> AUAudioUnit { audioUnit = try MyAudioUnit(componentDescription: desc, options: []) return audioUnit! } } public class AudioUnitViewController: AudioUnitViewControllerBase<Any> { } It is successfully compiled, but works and passes validation only if AudioUnitViewControllerBase has no generic type paramers. auval prints following: TESTING OPEN TIMES: COLD: FATAL ERROR: OpenAComponent: result: -10863,0xFFFFD591 What am I doing wrong?
0
1
1k
Aug ’22
AudioUnit: AUParameterEvent vs AUParameterTree implementorValueObserver
Hello, I'm trying to write my own audio unit extension and I have a problem. I don't understand the difference between implementorValueObserver and AUParameterEvent. It looks like both of them can be used to update parameters in DSPKernel. It seems natural to use an observer, but it requires to think about thread safety in contrast to AUParameterEvent handling. Can someone comment on this or give me more context about this two entities?
0
0
1.1k
Aug ’22
Why is internalRenderBlock fetched and used before allocateRenderResources() is called?
I have a working AUv3 AUAudioUnit app extension but I had to work around a strange issue: I found that the internalRenderBlock value is fetched and invoked before allocateRenderResources() is called. I have not found any documentation stating that this would be the case, and intuitively it does not make any sense. Is there something I am doing in my code that would be causing this to be the case? Should I *force* a call to allocateRenderResources() if it has not been called before internalRenderBlock is fetched? Thanks! Brad
6
1
3.3k
Jul ’22
Bug when using multiple AVAudioUnitSampler instances
Hi there, I'm building an audio app for iOS and ran into a very weird bug when using multiple AVAudioUnitSampler instances to play different instruments at the same time. I narrowed down the repro to: let sampler = AVAudioUnitSampler() self.audioEngine.attach(sampler) self.audioEngine.connect(sampler, to: self.audioEngine.mainMixerNode, format: nil) try! sampler.loadInstrument(at: Bundle.main.url(forResource: "SteinwayPiano-v1", withExtension: "aupreset")!) let sampler2 = AVAudioUnitSampler() self.audioEngine.attach(sampler2) self.audioEngine.connect(sampler2, to: self.audioEngine.mainMixerNode, format: nil) try! sampler2.loadInstrument(at: Bundle.main.url(forResource: "Rhodes-v1", withExtension: "aupreset")!) I get the following error on the console (real device and simulator): 2022-07-02 21:27:28.329147+0200 soundboard[23592:612358] [default]     ExtAudioFile.cpp:193  about to throw -42: open audio file 2022-07-02 21:27:28.329394+0200 soundboard[23592:612358] [default]      FileSample.cpp:52  about to throw -42: FileSample::LoadFromURL: ExtAudioFileOpenURL 2022-07-02 21:27:28.330206+0200 soundboard[23592:612358]     SampleManager.cpp:434  Failed to load sample 'Sounds/Rhodes/A_050__D3_4-ST.wav -- file:///Users/deermichel/Library/Developer/CoreSimulator/Devices/79ACB2AD-5155-4798-8E96-649964CB274E/data/Containers/Bundle/Application/A10C7802-3F4B-445D-A390-B6A84D8071EE/soundboard.app/': error -42 2022-07-02 21:27:28.330414+0200 soundboard[23592:612358] [default]     SampleManager.cpp:435  about to throw -42: Failed to load sample Sometimes the app crashes after that, but most importantly, sampler2 won't work. Now, if I only create one of the samplers, it works as expected. Also, if both samplers reference to the same aupreset, it works. Only if I try to load different samples, I end up in undefined behavior. Adding a audioEngine.detach(sampler) before creating sampler2 doesn't solve the issue either - it will fail loading the samples with the same error. However, when deferring removal of sampler and creation of sampler2 a little bit, it magically starts working (though that's not what I want because I need both samplers simultaneously): let sampler = AVAudioUnitSampler() self.audioEngine.attach(sampler) self.audioEngine.connect(sampler, to: self.audioEngine.mainMixerNode, format: nil) try! sampler.loadInstrument(at: Bundle.main.url(forResource: "SteinwayPiano-v1", withExtension: "aupreset")!) DispatchQueue.main.async { self.audioEngine.detach(sampler)   let sampler2 = AVAudioUnitSampler()   self.audioEngine.attach(sampler2)   self.audioEngine.connect(sampler2, to: self.audioEngine.mainMixerNode, format: nil)   try! sampler2.loadInstrument(at: Bundle.main.url(forResource: "Rhodes-v1", withExtension: "aupreset")!) } My samples are linked to the bundle as a folder alias - and I have a feeling that there is some exclusive lock... however I don't have the source code to debug the errors on the console further. Any help is appreciated, have a good one :)
2
0
2.3k
Jul ’22
testing multichannel AudioUnit output with AVAudioEngine
I'm extending an AudioUnit to generate multi-channel output, and trying to write a unit test using AVAudioEngine. My test installs a tap on the AVAudioNode's output bus and ensures the output is not silence. This works for stereo. I've currently got: auto avEngine = [[AVAudioEngine alloc] init]; [avEngine attachNode:avAudioUnit]; auto format = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100. channels:channelCount]; [avEngine connect:avAudioUnit to:avEngine.mainMixerNode format:format]; where avAudioUnit is my AU. So it seems I need to do more than simply setting the channel count for the format when connecting, because after this code, [avAudioUnit outputFormatForBus:0].channelCount is still 2. Printing the graph yields: AVAudioEngineGraph 0x600001e0a200: initialized = 1, running = 1, number of nodes = 3 ******** output chain ******** node 0x600000c09a80 {'auou' 'ahal' 'appl'}, 'I' inputs = 1 (bus0, en1) <- (bus0) 0x600000c09e00, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] node 0x600000c09e00 {'aumx' 'mcmx' 'appl'}, 'I' inputs = 1 (bus0, en1) <- (bus0) 0x600000c14300, {'augn' 'brnz' 'brnz'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] outputs = 1 (bus0, en1) -> (bus0) 0x600000c09a80, {'auou' 'ahal' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] node 0x600000c14300 {'augn' 'brnz' 'brnz'}, 'I' outputs = 1 (bus0, en1) -> (bus0) 0x600000c09e00, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] So AVAudioEngine just silently ignores whatever channel counts I pass to it. If I do: auto numHardwareOutputChannels = [avEngine.outputNode outputFormatForBus:0].channelCount; NSLog(@"hardware output channels %d\n", numHardwareOutputChannels); I get 30, because I have an audio interface connected. So I would think AVAudioEngine would support this. I've also tried setting the format explicitly on the connection between the mainMixerNode and the outputNode to no avail.
0
2
1.8k
Jun ’22
The AudioUnit user presets system has ceased to work as expected in iPadOS 14
The AUAudioUnit in my app uses the user presets system that was introduced with iPadOS/iOS 13. The user presets system worked well in iPadOS 13, and it worked in at least one of the pre-release beta versions of iPadOS 14. However, it has not worked since iPadOS 14.0 was released. The problem is (superficially, at least) that: saveUserPreset no longer writes preset files to the app's Documents folder, but the method doesn't fail either. The userPresets array, which typically contains the presets that were deserialised from the files stored in the Documents folder, is invariably empty. The presets that the array would contain prior to upgrading from iPadOS 13 are no longer accessible. In other words, prior to upgrading to iPadOS 14, my app could save user presets using the saveUserPreset method and subsequently access their contents from the userPresets array. Since upgrading to iPadOS 14, the userPresets array is invariably empty and the saveUserPreset method no longer saves presets to the Documents folder. Has anyone else experienced this problem?
1
0
1.7k
Jun ’22
CoreAudio crash on MacOS12.x system
Hello, my app crashed on the new MacOS12.x system, it works well on MacOS 11 BigSur. I'm developing an audio app on MacOS using AudioUnit, it sometime crashed when i switch devices. the relevant api is: AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, kAudioUnitOutputBus, &rnd_id, sizeof(rnd_id)); it troubles me for month, i can't find the reason or any useful info, any help will be appreciate. the crash log is: OS Version:      macOS 12.1 (21C51) Report Version:    12 Bridge OS Version:  6.1 (19P647) Crashed Thread:    43 schedule-thread Exception Type:    EXC_BAD_ACCESS (SIGSEGV) Exception Codes:   KERN_INVALID_ADDRESS at 0x00000a14f8969188 Exception Codes:   0x0000000000000001, 0x00000a14f8969188 Exception Note:    EXC_CORPSE_NOTIFY Application Specific Information: objc_msgSend() selector name: copy Thread 43 Crashed:: schedule-thread 0 libobjc.A.dylib         0x7ff815ef405d objc_msgSend + 29 1 CoreAudio            0x7ff817a237b9 HALC_ShellDevice::_GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*, unsigned int&, AudioObjectPropertyAddress&, bool&) const + 1133 2 CoreAudio            0x7ff817c57b81 invocation function for block in HALC_ShellObject::GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*) const + 107 3 CoreAudio            0x7ff817e8a606 HALB_CommandGate::ExecuteCommand(void () block_pointer) const + 98 4 CoreAudio            0x7ff817c56a98 HALC_ShellObject::GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*) const + 376 5 CoreAudio            0x7ff817b04235 HAL_HardwarePlugIn_ObjectGetPropertyData(AudioHardwarePlugInInterface**, unsigned int, AudioObjectPropertyAddress const*, unsigned int, void const*, unsigned int*, void*) + 349 6 CoreAudio            0x7ff817c16109 HALPlugIn::ObjectGetPropertyData(HALObject const&, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 59 7 CoreAudio            0x7ff817bd2f5d HALObject::GetPropertyData(AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 461 8 CoreAudio            0x7ff817f2ffca HALDevice::GetPropertyData(AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 644 9 CoreAudio            0x7ff8179809ab AudioObjectGetPropertyData + 275 10 AudioDSP              0x134b6df19 0x13490b000 + 2502425 11 AudioDSP              0x134b69776 0x13490b000 + 2484086 12 AudioDSP              0x134cc4eb4 0x13490b000 + 3907252 13 AudioDSP              0x134cc5f56 0x13490b000 + 3911510 14 AudioDSP              0x134e17b2c 0x13490b000 + 5294892 15 AudioDSP              0x134e0f4d1 0x13490b000 + 5260497
5
1
2.8k
Jun ’22
AUParameterNode defaultValue ??
We're seeing the following when running auvaltool It seems AUParameterNode cannot be constructed with a default value and has no option to set default values via property or method so what does this mean? .... Does it mean we ALSO have to iterate all the parameters using the old fashioned long winded toolbox calls ? Or does it mean nothing at all? The "Will fail in future auval version" is worrying! Values: Minimum = 5.000000, Default = 0.000000, Maximum = 300.000000 Flags: Expert Mode, Readable,  WARNING: use -strict_DefP flag * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Parameter's Published defaultvalue does not fall with [min, max] range  * * This will fail using -strict option. Will fail in future auval version  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   -parameter PASS
2
0
2.3k
May ’22
AUv3 running "in-process" resolves different URLS to required directories depending on which Host is hosting the AU
This seems to be a sandboxing issue but the solution is not so obvious ...  Our sandboxed Audio unit extension requires a permanent folder in which to store a database which can be used by all instances of the AU. Where can we store the database in a directory so that the AU can find it regardless of which host app it's running in ? The AU supports loading in-process. The problem we have is that when the AU is running in-process in a sandboxed host app URLs to the usual directories ( ~documents, shared, app support etc ) all resolve to the sandbox container.   But when the AU is hosted in a non-sandboxed host  ( ie. Logic Pro )  the URLs resolve to the actual user folder.  (~/users/xxx/documents etc  ) How can the AU automatically obtain a URL that will always resolve to the same place, will be permanent, wont be hidden from the user AND still remain “legal” for distributing in the App Store?   …   thanks!
1
0
1.9k
May ’22
Logic no longer allows plugins to use things like ifstream, NSOpenPanel, ect.?
I've noticed that on Monterey/Big Sur certain system and C++ functions in Logic no longer appear to work on files located outside of /Library/Audio/Plug-Ins/Components. For example, if you try to use std::ifstream on a file outside of the system plugin directory, it simply doesn't work (but still works fine in DAWs like Reaper, Ableton, ect). Certain graphics functions like NSOpenPanel appear to no longer work at all: Logic seems to prevent the window from opening, but still allows pop-up windows like CFUserNotificationDisplayAlert to display. Again, in other DAWs this all works fine. Has anyone noticed this, and if so, what's going on here? Is this the intended behavior for Logic now? It's not a huge deal, but some users like to install or place the sample directories of my plugins on different hard drives and things like that, and it seems like this is maybe no longer possible if they are using Logic? Tested in Logic 10.7.3 Monterey 12.3. Older AU SDK, but doubtful that's what has caused this.
2
0
1.6k
May ’22
Low level audio recording on macOS. Please Help!
I am struggling to see why the following low-level audio recording function - which is based on tn2091 - Device input using the HAL Output Audio Unit - (a great article, btw, although a bit dated, and it would be wonderful if it was updated to use Swift and non deprecated stuff at some point!) fails to work under macOS: func createMicUnit() -> AUAudioUnit { let compDesc = AudioComponentDescription( componentType: kAudioUnitType_Output, componentSubType: kAudioUnitSubType_HALOutput, // I am on macOS, os this is good componentManufacturer: kAudioUnitManufacturer_Apple, componentFlags: 0, componentFlagsMask: 0) return try! AUAudioUnit(componentDescription: compDesc, options: []) } func startMic() { // mic permision is already granted at this point, but let's check let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.audio) precondition(status == .authorized) // yes, all good let unit = createMicUnit() unit.isInputEnabled = true unit.isOutputEnabled = false precondition(!unit.canPerformInput) // can't record yet, and know why? print(deviceName(unit.deviceID)) // "MacBook Pro Speakers" - this is why let micDeviceID = defaultInputDeviceID print(deviceName(micDeviceID)) // "MacBook Pro Microphone" - this is better try! unit.setDeviceID(micDeviceID) // let's switch device to mic precondition(unit.canPerformInput) // now we can record print("\(String(describing: unit.channelMap))") // channel map is "nil" by default unit.channelMap = [0] // not sure if this helps or not let sampleRate = deviceActualFrameRate(micDeviceID) print(sampleRate) // 48000.0 let format = AVAudioFormat( commonFormat: .pcmFormatFloat32, sampleRate: sampleRate, channels: 1, interleaved: false)! try! unit.outputBusses[1].setFormat(format) unit.inputHandler = { flags, timeStamp, frameCount, bus in fatalError("never gets here") // now the weird part - this is never called! } try! unit.allocateRenderResources() try! unit.startHardware() // let's go! print("mic should be working now... why it doesn't?") // from now on the (UI) app continues its normal run loop } All sanity checks pass with flying colors but unit's inputHandler is not being called. Any idea why? Thank you!
Replies
3
Boosts
0
Views
2.5k
Activity
Jan ’23
AUv3 -- deinit / dealloc never called
Hi, I am designing an AUv3 plugin for Logic / Garageband. I heavily relied upon the AUv3Filter demo supplied by Apple due to lack of documentation on building AUv3 plugins. However, I noticed a problem both in my plugin and Apple's AUv3Filter demo plugin. When I add a deinit function to Apple's AUv3FilterDemo.swift class, it never gets called. Not when the plugin is removed from a Logic project, not when Logic exits, never. My plugin, unsurprisingly, has the same problem (dealloc / Objective-C). It's pretty serious however, because my plugin is a wrapper for a C++ class that has a lot of stuff going on and needs to be deconstructed when it finishes running. I spent a few hours with Apple's demo trying to track down any strong references that might persist after the plugin exits, but nothing I did seemed to make any difference. Anybody else have this issue?
Replies
3
Boosts
1
Views
2.1k
Activity
Jan ’23
AUv2 development on Xcode 14
Hi, I want to do some work on an audio unit after a gap of (many) years, and am not clear about the status of v2 AUs. There's no template for them in the current Xcode, and the relevant CoreAudio classes (AUBase and subclasses) are also absent. Have I missed some optional download from Apple that restores these things, or is it all over for v2?
Replies
2
Boosts
0
Views
1.4k
Activity
Nov ’22
[AudioUnit] kAudioUnitSubType_NewTimePitch make music quality very bad after iOS 16
We have a music type app, and I've received some users feedback that complain about the music quality become very bad after update to iOS 16. At last, we found the reason is that they shift the pitch by using "kAudioUnitSubType_NewTimePitch" which is one of our offered function. iOS 15 and other earlier version can works well. Is there any Apple engineer can solve my problem?
Replies
1
Boosts
0
Views
1k
Activity
Oct ’22
file unit callback shows stereo channels in buffer, but the file loaded was 6 channel
I want to generate a sample withAudioFilePlayerUnit to play 6 channel audio file. The issue here is that, the AudioFilePlayerUnit callback shows stereo channel in buffer, but the file loaded to the fileUnit was of 6 channels. I have tried setting the input and output format for the fileUnit to that of file's stream format(6 channels), but still the callback shows stereo channels in buffer. I have added my code snippet below. OSStatus error = AudioFileOpenURL(audioFileURL, kAudioFileReadPermission, 0, &_audioInputFileId); UInt32 dataSize = sizeof(AudioStreamBasicDescription); AudioFileGetProperty(_audioInputFileId, kAudioFilePropertyDataFormat, &dataSize, &_fileStreamDescription); setting the input and outputFormat for the unit : UInt32 propertySize = sizeof(_fileStreamDescription); AudioUnitScope scope = kAudioUnitScope_Input; OSStatus err = AudioUnitSetProperty(filePlayerUnit, kAudioUnitProperty_StreamFormat, scope, 0, &_fileStreamDescription, propertySize); OSStatus err = AudioUnitSetProperty(filePlayerUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &_fileStreamDescription, propertySize); here setting the input and output format also throws error. I have added the callback using AudioUnitRenderNotify method to the fileUnit but when check the buffer in the callback I can see it returning as stereo channels.
Replies
1
Boosts
0
Views
1.3k
Activity
Oct ’22
AUAudioUnit – Impossible to handle frame count limitation in render?
Summary: I've created an AUAudioUnit to host some third party signal processing code and am running into a edge case limitation where I can only process and supply output audio data (from the internalRenderBlock) if it's an exact multiple of a specific number of frames. More Detail: This third party code ONLY works with exactly 10ms of data at time. For example, say with 48khz audio, it only accepts 480 frames on each processing function call. If the AUAudioUnit's internalRenderBlock is called with 1024 frames as the frame count, I can use the pullInputBlock to get 480 frames, process it, another 480 frames, and process that, but what should I then do with the remaining 64 frames? Possible Solutions Foiled: a) It seems there's no way to indicate to the host that I have only consumed 960 frames and will only be supplying 960 frames of output. I thought perhaps the host would observe that if the outputData ABL buffers have less than the frame count passed into the internalRenderBlock, that it might appropriately advance the timestamp only by that much the next time time around, but it does not. So it's required that all the audio be processed before the block returns, but I can only do that if the block is requested to handle exactly a multiple of 10ms of data. b) I can't buffer up the "remainder" input and process it on the next internalRenderBlock cycle because all of the output must be provided on return as discussed in A. c) As an alternative, I see no way to have the unit explicitly indicate to the host, how many frames the unit can process at a time. maximumFramesToRender is the host telling the unit (not the reverse), and either way it's a maximum only, not a minumum as well. What can I do?
Replies
1
Boosts
0
Views
2.5k
Activity
Aug ’22
Swift generics cause a loading error
Hello, I've tried to make my AudioUnitViewController more generic. Here minimal example of what I have: open class AudioUnitViewControllerBase<T>: AUViewController, AUAudioUnitFactory { private var audioUnit: AUAudioUnit? open override func loadView() { view = NSView() } open func createAudioUnit(with desc: AudioComponentDescription) throws -> AUAudioUnit { audioUnit = try MyAudioUnit(componentDescription: desc, options: []) return audioUnit! } } public class AudioUnitViewController: AudioUnitViewControllerBase<Any> { } It is successfully compiled, but works and passes validation only if AudioUnitViewControllerBase has no generic type paramers. auval prints following: TESTING OPEN TIMES: COLD: FATAL ERROR: OpenAComponent: result: -10863,0xFFFFD591 What am I doing wrong?
Replies
0
Boosts
1
Views
1k
Activity
Aug ’22
AudioUnit: AUParameterEvent vs AUParameterTree implementorValueObserver
Hello, I'm trying to write my own audio unit extension and I have a problem. I don't understand the difference between implementorValueObserver and AUParameterEvent. It looks like both of them can be used to update parameters in DSPKernel. It seems natural to use an observer, but it requires to think about thread safety in contrast to AUParameterEvent handling. Can someone comment on this or give me more context about this two entities?
Replies
0
Boosts
0
Views
1.1k
Activity
Aug ’22
Why is internalRenderBlock fetched and used before allocateRenderResources() is called?
I have a working AUv3 AUAudioUnit app extension but I had to work around a strange issue: I found that the internalRenderBlock value is fetched and invoked before allocateRenderResources() is called. I have not found any documentation stating that this would be the case, and intuitively it does not make any sense. Is there something I am doing in my code that would be causing this to be the case? Should I *force* a call to allocateRenderResources() if it has not been called before internalRenderBlock is fetched? Thanks! Brad
Replies
6
Boosts
1
Views
3.3k
Activity
Jul ’22
Bug when using multiple AVAudioUnitSampler instances
Hi there, I'm building an audio app for iOS and ran into a very weird bug when using multiple AVAudioUnitSampler instances to play different instruments at the same time. I narrowed down the repro to: let sampler = AVAudioUnitSampler() self.audioEngine.attach(sampler) self.audioEngine.connect(sampler, to: self.audioEngine.mainMixerNode, format: nil) try! sampler.loadInstrument(at: Bundle.main.url(forResource: "SteinwayPiano-v1", withExtension: "aupreset")!) let sampler2 = AVAudioUnitSampler() self.audioEngine.attach(sampler2) self.audioEngine.connect(sampler2, to: self.audioEngine.mainMixerNode, format: nil) try! sampler2.loadInstrument(at: Bundle.main.url(forResource: "Rhodes-v1", withExtension: "aupreset")!) I get the following error on the console (real device and simulator): 2022-07-02 21:27:28.329147+0200 soundboard[23592:612358] [default]     ExtAudioFile.cpp:193  about to throw -42: open audio file 2022-07-02 21:27:28.329394+0200 soundboard[23592:612358] [default]      FileSample.cpp:52  about to throw -42: FileSample::LoadFromURL: ExtAudioFileOpenURL 2022-07-02 21:27:28.330206+0200 soundboard[23592:612358]     SampleManager.cpp:434  Failed to load sample 'Sounds/Rhodes/A_050__D3_4-ST.wav -- file:///Users/deermichel/Library/Developer/CoreSimulator/Devices/79ACB2AD-5155-4798-8E96-649964CB274E/data/Containers/Bundle/Application/A10C7802-3F4B-445D-A390-B6A84D8071EE/soundboard.app/': error -42 2022-07-02 21:27:28.330414+0200 soundboard[23592:612358] [default]     SampleManager.cpp:435  about to throw -42: Failed to load sample Sometimes the app crashes after that, but most importantly, sampler2 won't work. Now, if I only create one of the samplers, it works as expected. Also, if both samplers reference to the same aupreset, it works. Only if I try to load different samples, I end up in undefined behavior. Adding a audioEngine.detach(sampler) before creating sampler2 doesn't solve the issue either - it will fail loading the samples with the same error. However, when deferring removal of sampler and creation of sampler2 a little bit, it magically starts working (though that's not what I want because I need both samplers simultaneously): let sampler = AVAudioUnitSampler() self.audioEngine.attach(sampler) self.audioEngine.connect(sampler, to: self.audioEngine.mainMixerNode, format: nil) try! sampler.loadInstrument(at: Bundle.main.url(forResource: "SteinwayPiano-v1", withExtension: "aupreset")!) DispatchQueue.main.async { self.audioEngine.detach(sampler)   let sampler2 = AVAudioUnitSampler()   self.audioEngine.attach(sampler2)   self.audioEngine.connect(sampler2, to: self.audioEngine.mainMixerNode, format: nil)   try! sampler2.loadInstrument(at: Bundle.main.url(forResource: "Rhodes-v1", withExtension: "aupreset")!) } My samples are linked to the bundle as a folder alias - and I have a feeling that there is some exclusive lock... however I don't have the source code to debug the errors on the console further. Any help is appreciated, have a good one :)
Replies
2
Boosts
0
Views
2.3k
Activity
Jul ’22
testing multichannel AudioUnit output with AVAudioEngine
I'm extending an AudioUnit to generate multi-channel output, and trying to write a unit test using AVAudioEngine. My test installs a tap on the AVAudioNode's output bus and ensures the output is not silence. This works for stereo. I've currently got: auto avEngine = [[AVAudioEngine alloc] init]; [avEngine attachNode:avAudioUnit]; auto format = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100. channels:channelCount]; [avEngine connect:avAudioUnit to:avEngine.mainMixerNode format:format]; where avAudioUnit is my AU. So it seems I need to do more than simply setting the channel count for the format when connecting, because after this code, [avAudioUnit outputFormatForBus:0].channelCount is still 2. Printing the graph yields: AVAudioEngineGraph 0x600001e0a200: initialized = 1, running = 1, number of nodes = 3 ******** output chain ******** node 0x600000c09a80 {'auou' 'ahal' 'appl'}, 'I' inputs = 1 (bus0, en1) <- (bus0) 0x600000c09e00, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] node 0x600000c09e00 {'aumx' 'mcmx' 'appl'}, 'I' inputs = 1 (bus0, en1) <- (bus0) 0x600000c14300, {'augn' 'brnz' 'brnz'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] outputs = 1 (bus0, en1) -> (bus0) 0x600000c09a80, {'auou' 'ahal' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] node 0x600000c14300 {'augn' 'brnz' 'brnz'}, 'I' outputs = 1 (bus0, en1) -> (bus0) 0x600000c09e00, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved] So AVAudioEngine just silently ignores whatever channel counts I pass to it. If I do: auto numHardwareOutputChannels = [avEngine.outputNode outputFormatForBus:0].channelCount; NSLog(@"hardware output channels %d\n", numHardwareOutputChannels); I get 30, because I have an audio interface connected. So I would think AVAudioEngine would support this. I've also tried setting the format explicitly on the connection between the mainMixerNode and the outputNode to no avail.
Replies
0
Boosts
2
Views
1.8k
Activity
Jun ’22
The AudioUnit user presets system has ceased to work as expected in iPadOS 14
The AUAudioUnit in my app uses the user presets system that was introduced with iPadOS/iOS 13. The user presets system worked well in iPadOS 13, and it worked in at least one of the pre-release beta versions of iPadOS 14. However, it has not worked since iPadOS 14.0 was released. The problem is (superficially, at least) that: saveUserPreset no longer writes preset files to the app's Documents folder, but the method doesn't fail either. The userPresets array, which typically contains the presets that were deserialised from the files stored in the Documents folder, is invariably empty. The presets that the array would contain prior to upgrading from iPadOS 13 are no longer accessible. In other words, prior to upgrading to iPadOS 14, my app could save user presets using the saveUserPreset method and subsequently access their contents from the userPresets array. Since upgrading to iPadOS 14, the userPresets array is invariably empty and the saveUserPreset method no longer saves presets to the Documents folder. Has anyone else experienced this problem?
Replies
1
Boosts
0
Views
1.7k
Activity
Jun ’22
CoreAudio crash on MacOS12.x system
Hello, my app crashed on the new MacOS12.x system, it works well on MacOS 11 BigSur. I'm developing an audio app on MacOS using AudioUnit, it sometime crashed when i switch devices. the relevant api is: AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, kAudioUnitOutputBus, &rnd_id, sizeof(rnd_id)); it troubles me for month, i can't find the reason or any useful info, any help will be appreciate. the crash log is: OS Version:      macOS 12.1 (21C51) Report Version:    12 Bridge OS Version:  6.1 (19P647) Crashed Thread:    43 schedule-thread Exception Type:    EXC_BAD_ACCESS (SIGSEGV) Exception Codes:   KERN_INVALID_ADDRESS at 0x00000a14f8969188 Exception Codes:   0x0000000000000001, 0x00000a14f8969188 Exception Note:    EXC_CORPSE_NOTIFY Application Specific Information: objc_msgSend() selector name: copy Thread 43 Crashed:: schedule-thread 0 libobjc.A.dylib         0x7ff815ef405d objc_msgSend + 29 1 CoreAudio            0x7ff817a237b9 HALC_ShellDevice::_GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*, unsigned int&, AudioObjectPropertyAddress&, bool&) const + 1133 2 CoreAudio            0x7ff817c57b81 invocation function for block in HALC_ShellObject::GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*) const + 107 3 CoreAudio            0x7ff817e8a606 HALB_CommandGate::ExecuteCommand(void () block_pointer) const + 98 4 CoreAudio            0x7ff817c56a98 HALC_ShellObject::GetPropertyData(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int, unsigned int&, void*) const + 376 5 CoreAudio            0x7ff817b04235 HAL_HardwarePlugIn_ObjectGetPropertyData(AudioHardwarePlugInInterface**, unsigned int, AudioObjectPropertyAddress const*, unsigned int, void const*, unsigned int*, void*) + 349 6 CoreAudio            0x7ff817c16109 HALPlugIn::ObjectGetPropertyData(HALObject const&, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 59 7 CoreAudio            0x7ff817bd2f5d HALObject::GetPropertyData(AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 461 8 CoreAudio            0x7ff817f2ffca HALDevice::GetPropertyData(AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&, void*) const + 644 9 CoreAudio            0x7ff8179809ab AudioObjectGetPropertyData + 275 10 AudioDSP              0x134b6df19 0x13490b000 + 2502425 11 AudioDSP              0x134b69776 0x13490b000 + 2484086 12 AudioDSP              0x134cc4eb4 0x13490b000 + 3907252 13 AudioDSP              0x134cc5f56 0x13490b000 + 3911510 14 AudioDSP              0x134e17b2c 0x13490b000 + 5294892 15 AudioDSP              0x134e0f4d1 0x13490b000 + 5260497
Replies
5
Boosts
1
Views
2.8k
Activity
Jun ’22
AUParameterNode defaultValue ??
We're seeing the following when running auvaltool It seems AUParameterNode cannot be constructed with a default value and has no option to set default values via property or method so what does this mean? .... Does it mean we ALSO have to iterate all the parameters using the old fashioned long winded toolbox calls ? Or does it mean nothing at all? The "Will fail in future auval version" is worrying! Values: Minimum = 5.000000, Default = 0.000000, Maximum = 300.000000 Flags: Expert Mode, Readable,  WARNING: use -strict_DefP flag * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Parameter's Published defaultvalue does not fall with [min, max] range  * * This will fail using -strict option. Will fail in future auval version  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   -parameter PASS
Replies
2
Boosts
0
Views
2.3k
Activity
May ’22
Apply AU effect to WebRTC realtime audio playback on iOS
Hi there, My App is playing back WebRTC audio from the Ant Media Servers on iOS. I need to be able to manipulate this audio and delay it around 150ms (variable). Ideally client side. How might i use a delay AU effect on realtime WebRTC audio? Alternatively could we code a buffer? If so, where/how would we insert this buffer? Thanks
Replies
0
Boosts
0
Views
1.3k
Activity
May ’22
AUv3 running "in-process" resolves different URLS to required directories depending on which Host is hosting the AU
This seems to be a sandboxing issue but the solution is not so obvious ...  Our sandboxed Audio unit extension requires a permanent folder in which to store a database which can be used by all instances of the AU. Where can we store the database in a directory so that the AU can find it regardless of which host app it's running in ? The AU supports loading in-process. The problem we have is that when the AU is running in-process in a sandboxed host app URLs to the usual directories ( ~documents, shared, app support etc ) all resolve to the sandbox container.   But when the AU is hosted in a non-sandboxed host  ( ie. Logic Pro )  the URLs resolve to the actual user folder.  (~/users/xxx/documents etc  ) How can the AU automatically obtain a URL that will always resolve to the same place, will be permanent, wont be hidden from the user AND still remain “legal” for distributing in the App Store?   …   thanks!
Replies
1
Boosts
0
Views
1.9k
Activity
May ’22
Logic no longer allows plugins to use things like ifstream, NSOpenPanel, ect.?
I've noticed that on Monterey/Big Sur certain system and C++ functions in Logic no longer appear to work on files located outside of /Library/Audio/Plug-Ins/Components. For example, if you try to use std::ifstream on a file outside of the system plugin directory, it simply doesn't work (but still works fine in DAWs like Reaper, Ableton, ect). Certain graphics functions like NSOpenPanel appear to no longer work at all: Logic seems to prevent the window from opening, but still allows pop-up windows like CFUserNotificationDisplayAlert to display. Again, in other DAWs this all works fine. Has anyone noticed this, and if so, what's going on here? Is this the intended behavior for Logic now? It's not a huge deal, but some users like to install or place the sample directories of my plugins on different hard drives and things like that, and it seems like this is maybe no longer possible if they are using Logic? Tested in Logic 10.7.3 Monterey 12.3. Older AU SDK, but doubtful that's what has caused this.
Replies
2
Boosts
0
Views
1.6k
Activity
May ’22