iOS multitasking for an Audio Recording application

You can. Skype does this. You presumably need to set <key>UIBackgroundModes</key><array><string>audio</string></array> in Info.plist, and you need to make sure that the audio session is active/running/whatever before you switch apps (the assumption is that you won’t suddenly start recording/playing music/whatever when your app is in the background). The docs say that “audio” lets you play audio … Read more

AVAudioEngine downsample issue

An other way to do it , with AVAudioConverter in Swift 5 let engine = AVAudioEngine() func setup() { let input = engine.inputNode let bus = 0 let inputFormat = input.outputFormat(forBus: bus ) guard let outputFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 8000, channels: 1, interleaved: true), let converter = AVAudioConverter(from: inputFormat, to: outputFormat) else{ return } … Read more

Write Audio To Disk From IO Unit

After a couple of days of tears & hair pulling I have a solution. In my code and in other examples I have seen extaudiofilewriteasync was called in the callback for the remoteio unit like so. ** remoteiounit callback ** static OSStatus masterChannelMixerUnitCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) … Read more

Forcing iPhone Microphone as Audio Input

I believe the answer to this question to be ‘no’. I used an iPhone 4 and the new-to-iOS 4 AVFoundation to experiment, focussing on the AVCaptureDevice class. I added the following to an application: NSLog(@”%@”, [AVCaptureDevice devices]); So that asks that all devices that can be used for capturing audio and/or video be listed. Without … Read more

Playing back audio using AVAudioPlayer iOS 7

You’re having an ARC issue here. myPlayer is being cleaned up when it’s out of scope. Create a strong property, assign the AVAudioPlayer and you’re probably all set! @property(nonatomic, strong) AVAudioPlayer *myPlayer; … // create new audio player self.myPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:fileURL error:nil]; [self.myPlayer play];

How to check if the system audio is muted?

VB.Net rewriting (+ Bonus) of the CoreAudio API implementation γηράσκω δ’ αεί πολλά διδασκόμε posted. The code in wrapped in a Class (CoreAudio) and includes the original IsMuted() method, plus other methods I implemented on the fly (because, why not). More information on the Windows CoreAudio APIs on MSDN. GitHub NAudio CoreAudioApi implementation (C#). Methods … Read more

AudioObjectGetPropertyData to get a list of input devices

To determine if a device is an input device you need to check and see if it has any input channels. Here is code modified from the Objective-C class here: static BOOL DeviceHasBuffersInScope(AudioObjectID deviceID, AudioObjectPropertyScope scope) { NSCParameterAssert(deviceID != kAudioObjectUnknown); AudioObjectPropertyAddress propertyAddress = { .mSelector = kAudioDevicePropertyStreamConfiguration, .mScope = scope, .mElement = kAudioObjectPropertyElementWildcard }; UInt32 … Read more

core audio offline rendering GenericOutput

Offline rendering Worked for me using GenericOutput AudioUnit. I am sharing the working code here. core-audio framework seems a little though. But small-small things in it like ASBD, parameters …etc are making these issues. try hard it will work. Don’t give-up :-). core-audio is very powerful and useful while dealing with low-level audio. Thats what … Read more