core-audio

iPhone SDK: AVAudioRecorder metering -- how to change peakPowerForChannel from decibel into percentage?

The AVAudioRecorder in the iPhone SDK can be used to get the peak and average power for a channel, in decibels. The range is between 0db to 160db. What is the calculation used to convert this into a scale between 0 - 10 or something similar that can be used for an audio level meter? ...

implementation musical instrument using audio unit

post same question at apple developer forum ,too hi first sorry that my english is poor.. i want develop iphone application that playing musical instrument like 'ocarina' but don't need blow mic features. so first i tried to find that how implementation 'virtual musical instrument ' in iphone development. the during the decide imple...

AudioFileWriteBytes fails with error code -40

I'm trying to write raw audio bytes to a file using AudioFileWriteBytes(). Here's what I'm doing: void writeSingleChannelRingBufferDataToFileAsSInt16(AudioFileID audioFileID, AudioConverterRef audioConverter, ringBuffer *rb, SInt16 *holdingBuffer) { // First, figure out which bits of audio we'll be // writing to file from the ring buff...

How to speed up drawing of scaled image? Audio playback chokes during window resize.

I am writing an audio player for OSX. One view is a custom view that displays a waveform. The waveform is stored as a instance variable of type NSImage with an NSBitmapImageRep. The view also displays a progress indicator (a thick red line). Therefore, it is updated/redrawn every 30 milliseconds. Since it takes a rather long time to rec...

AudioOutputUnitStart takes time

Hello, I'm making an iPhone game application using Core Audio, Extended Audio File Services. It works OK, but when I first call AudioOutputUnitStart, it takes about 1-2 seconds. After the second call, no problem. For a game application, 1-2 seconds is very noticeable. (I tested this on iPhone simulator, and iPhone 3GS) Also, if I leav...

Finding out estimated duration of a stream using Core Audio

I am streaming a MP3 over network using custom feeding code, not AVAudioPlayer (which only works with URLs) using APIs like AudioFileStreamOpen and etc. Is there any way to estimate a length of the stream? I know that I can get a 'elapsed' property using: if(AudioQueueGetCurrentTime(queue.audioQueue, NULL, &t, &b) < 0) return 0;...

How can I find out if an external headset is connected to an iPhone?

I wonder if it's possible to detect that the user has an external headset plugged into the iPhone's 3.5mm connector or the 30-pin connector. I want to output audio only to an external audio device, and keep silent if nothing is connected. Ari. ...

Unexpected behavior with AudioQueueServices callback while recording audio

I'm recording a continuous stream of data using AudioQueueServices. It is my understanding that the callback will only be called when the buffer fills with data. In practice, the first callback has a full buffer, the 2nd callback is 3/4 full, the 3rd callback is full, the 4th is 3/4 full, and so on. These buffers are 8000 packets (rec...

Generating an LPCM buffer in memory for AVAudioPlayer initWithData

I want to generate a sound wave programmatically and play it with AVAudioPlayer. I have the code to encode my waveform as linear PCM, 44100Hz, mono, 8 bits per sample. I am not clear on what kind of envelope I need to wrap around this buffer so that AVAudioPlayer recognizes it as PCM. ...

AudioQueue ate my buffer (first 15 milliseconds of it)

I am generating audio programmatically. I hear gaps of silence between my buffers. When I hook my phone to a scope, I see that the first few samples of each buffer are missing, and in their place is silence. The length of this silence varies from almost nothing to as much as 20 ms. My first thought is that my original callback function ...

iphone sdk: Core Audio How to continue recording to file after user stops recording by leaving the application and then re-opens it?

The iPhone's AVAudioRecorder class will not allow you to open an existing file to continue a recording. Instead, it overwrites it. I'd like to know an approach that would allow me to continue recording to an existing file using Core Audio APIs. ...

Play an audio file using RemoteIO and Audio Unit

I am looking at Apple's 'aurioTouch' example for the iPhone and I would like to play an mp3 or wav instead of using the built in mic. I am very new to the audio portion of iPhone programming, but I think I need to modify the SetupRemoteIO(...) function and replace the AudioComponent named 'comp' with a custom AudioComponent that plays a ...

Using kAudioSessionProperty_OtherMixableAudioShouldDuck on iPhone

Hello, I'm trying to get consistant behavior out of the kAudioSessionProperty_OtherMixableAudioShouldDuck property on the iPhone to allow iPod music blending and I'm having trouble. At the start of my app I set an Ambient category like so: -(void) initialize { [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient...

AudioFileReadPackets to an array?

I'd like to read packets from an audio file, but I don't want to send them to a playback buffer. I just want to get an array of the packets, ideally as floats. I've prepped the audio and then want to call: OSStatus err = AudioFileReadPackets (audioFileID,FALSE,outBytes,NULL,0,numPackets,whatGoesHere?); But what goes in that last argum...

I just don't get AudioFileReadPackets

I've tried to write the smallest chunk of code to narrow down a problem. It's now just a few lines and it doesn't work, which makes it pretty clear that I have a fundamental misunderstanding of how to use AudioFileReadPackets. I've read the docs and other examples online, and apparently I'm just not getting. Could you explain it to me? ...

Objective-C - Adding sound on iPhone

I'm making a sound for the iPhone and I'm interested in adding background music and background sounds. Is CoreAudio right for the job? And if so, how do I use it? ...

Converting mp3 to caf file for iPhone

Hi, I am experimenting with the sampling rate of the mp3 file to convert it into caf format. afconvert -f caff -d LEI16@44100 ./fricatives_play_all.mp3 ./test.caf afconvert -f caff -d LEI16@22100 ./fricatives_play_all.mp3 ./test.caf afconvert -f caff -d LEI16@12000 ./fricatives_play_all.mp3 ./test.caf afconvert -f caff -d LEI16@2010...

Core-audio - constructing an AudioBufferList struct (Q about c struct definition)

The definition of AudioBufferList looks weird to me… i guess my C is not so good struct AudioBufferList { UInt32 mNumberBuffers; AudioBuffer mBuffers[kVariableLengthArray]; }; typedef struct AudioBufferList AudioBufferList; Why AudioBuffer mBuffers[kVariableLengthArray]; and not AudioBuffer *mBuffers; ? kVariable...

iPhone Audio Delay Line

I am looking into developing an audio delay line - external microphone to line out on the iPhone. Is there any sample code anyone could recommend? I have already been playing with SpeakHere and AurioTouch. AurioTouch is helpful although complex to sift through. ...

How to generate sound from a waveform Data

Hi All I have to make a project in ipad and my problem is that I have to play a sound generated from a wave form/wave form data. Can some one suggest me how to do that or any tutorial or reference for that. Thanks in advance. Regards Ajay Sharma ...