core-audio

How to control hardware mic input gain/level on iPhone?

跟風遠走 提交于 2019-11-28 07:47:39
My audio-analysis function responds better on the iPad (2) than the iPhone (4). It seems sensitive to softer sounds on the iPad, whereas the iPhone requires much louder input to respond properly. Whether this is because of mic placement, different components, different software configurations or some other factor, I'd like to be able to control for it in my app. Obviously I could just multiply all of my audio samples to programmatically apply gain. Of course that has a software cost too, so: Is it possible to control the mic's gain from software in iOS, similarly to how it is in MacOS? I can't

iPhone: AudioBufferList init and release

久未见 提交于 2019-11-28 07:44:10
What are the correct ways of initializing (allocating memory) and releasing (freeing) an AudioBufferList with 3 AudioBuffers? (I'm aware that there might be more than one ways of doing this.) I'd like to use those 3 buffers to read sequential parts of an audio file into them and play them back using Audio Units. Here is how I do it: AudioBufferList * AllocateABL(UInt32 channelsPerFrame, UInt32 bytesPerFrame, bool interleaved, UInt32 capacityFrames) { AudioBufferList *bufferList = NULL; UInt32 numBuffers = interleaved ? 1 : channelsPerFrame; UInt32 channelsPerBuffer = interleaved ?

Detecting a clap in IOS

不问归期 提交于 2019-11-28 07:43:55
I am trying to build an IOS application that counts claps. I have been watching the WWDC videos on CoreAudio, and the topic seems so vast that I'm not quite sure where to look. I have found similar problems here in stackoverflow. Here is one in C# for detecting a door slam: Given an audio stream, find when a door slams (sound pressure level calculation?) It seems that I need to do this: Divide the samples up into sections Calculate the energy of each section Take the ratio of the energies between the previous window and the current window If the ratio exceeds some threshold, determine that

How can I record AMR audio format on the iPhone?

前提是你 提交于 2019-11-28 07:39:09
A voice recorder doesn't need uncompressed Linear PCM audio. Compressed AMR would do fine. The iPhone framework built for recording audio is simple enough, but the only examples I've found for setting up the audio format (which come from Apple) use LinearPCM. I've tried various other combinations of values, but can't seem to get anything to work. Does anybody have any code that actually records AMR ? Edit: The AMR format is one of the options for setting the data type, but the other options (packet size, frame size, etc.) don't seem to match up no matter what I set them to. Edit: Here's what I

OSStatus error 1718449215

纵然是瞬间 提交于 2019-11-28 07:13:56
I have created an iPhone application to record our voice. When I try to record, I am getting error message in following statement. recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err]; Error Domain=NSOSStatusErrorDomain Code=1718449215 "Operation could not be completed. (OSStatus error 1718449215.)" If I tried to record in .caf file, it is working fine. If I tried with .m4a, I am getting this error message. Please help me to resolve it. Thanks. 1718449215 is the decimal representation of the four character code for the kAudioFormatUnsupportedDataFormatError

How do I use CoreAudio's AudioConverter to encode AAC in real-time?

若如初见. 提交于 2019-11-28 06:38:57
All the sample code I can find that uses AudioConverterRef focuses on use cases where I have all the data up-front (such as converting a file on disk). They commonly call AudioConverterFillComplexBuffer with the PCM to be converted as the inInputDataProcUserData and just fill it in in the callback. (Is that really how it's supposed to be used? Why does it need a callback, then?) For my use case, I'm trying to stream aac audio from the microphone, so I have no file, and my PCM buffer is being filled in in real time. Since I don't have all the data up-front, I've tried doing *ioNumberDataPackets

core audio: how can one packet = one byte when clearly one packet = 4 bytes

前提是你 提交于 2019-11-28 05:44:01
问题 I was going over core audio conversion services in the Learning Core Audio and I was struck by this example in their sample code: while(1) { // wrap the destination buffer in an AudioBufferList AudioBufferList convertedData; convertedData.mNumberBuffers = 1; convertedData.mBuffers[0].mNumberChannels = mySettings->outputFormat.mChannelsPerFrame; convertedData.mBuffers[0].mDataByteSize = outputBufferSize; convertedData.mBuffers[0].mData = outputBuffer; UInt32 frameCount = packetsPerBuffer; //

iOS Core Audio : Converting between kAudioFormatFlagsCanonical and kAudioFormatFlagsAudioUnitCanonical

我们两清 提交于 2019-11-28 05:11:54
问题 I need to convert between this format : format.mSampleRate = 44100.0; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kAudioFormatFlagsCanonical | kLinearPCMFormatFlagIsNonInterleaved; format.mBytesPerPacket = sizeof(AudioUnitSampleType); format.mFramesPerPacket = 1; format.mBytesPerFrame = sizeof(AudioUnitSampleType); format.mChannelsPerFrame = 2 ; format.mBitsPerChannel = sizeof(AudioUnitSampleType)*8; and this format format.mSampleRate = 44100.0; format.mFormatID =

How to record sound produced by mixer unit output (iOS Core Audio & Audio Graph)

て烟熏妆下的殇ゞ 提交于 2019-11-28 04:12:00
I'm trying to record sound produced by a mixer unit output. For the moment, my code is based on the apple MixerHost iOS app demo : A mixer node is connected to a remote IO node on the audio graphe. And i try to set an input callback on the remote IO node input on the mixer output. I do something wrong but I can not find the error. Here is the code below. This is done just after the Multichannel Mixer unit Setup : UInt32 flag = 1; // Enable IO for playback result = AudioUnitSetProperty(iOUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, // Output bus &flag, sizeof(flag)); if

Change Volume on Mac programmatically

无人久伴 提交于 2019-11-28 04:02:30
问题 I'm looking for a not applescript way to change the system volume on Mac OS X programmatically. I just couldn't find a solution. Anyone any ideas? 回答1: Take a look at this class: https://github.com/InerziaSoft/ISSoundAdditions It can change system volume and make use of CoreAudio API. An example of usage should look like this: [NSSound setSystemVolume:0.5] 来源: https://stackoverflow.com/questions/6278589/change-volume-on-mac-programmatically