iPhone Custom Audio Unit: why buzz?
iPhone Custom Audio Unit: why buzz?
- Subject: iPhone Custom Audio Unit: why buzz?
- From: Sung <email@hidden>
- Date: Fri, 5 Mar 2010 23:41:38 -0800
Hi all,
There was a thread about creating a custom AU to play a simple sine wave:
I did the same thing and use the DefaultOutputUnit example from Apple sample to construct sine tone in callback:
static OSStatus renderInput(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
{
double frequency = 440.0;
double j = 0.0;
double cycleLength = kGraphSampleRate / frequency;
SInt16 *toneBuffer = (SInt16 *)ioData->mBuffers[0].mData
for (UInt32 frame; frame<512; ++frame)
{
Float32 nextFloat = sin(j/cycleLength * (M_PI*2.0)) ;
toneBuffer[frame] = 32768.0*nextFloat;
j += 1.0;
if (j>cycleLength) {
j = j - cycleLength;
}
}
return noErr;
}
It works in iphone simulator, but :
- the sound that comes out is "buzz saw" noise instead of a pure sine tone.
- on a device, the sound only comes out of headphone, not through the speaker.
Does any of you have similar issues?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden