• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone Custom Audio Unit: why buzz?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone Custom Audio Unit: why buzz?


  • Subject: Re: iPhone Custom Audio Unit: why buzz?
  • From: Sung <email@hidden>
  • Date: Sat, 6 Mar 2010 06:39:25 -0800

I just used Apple sample set up (iPhoneMixerEQGraphTest):

// 5ms preferred buffer size
Float32 bufferDuration = .005;
        XThrowIfError(AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(bufferDuration), &bufferDuration), "couldn't set i/o buffer duration");
        
// 44.1kHz preferred hardware sample rate
Float64 hwSampleRate = 44100.0; XThrowIfError(AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareSampleRate, sizeof(hwSampleRate), &hwSampleRate), "couldn't set hw sample rate");
        


On Sat, Mar 6, 2010 at 2:45 AM, Doug McCoy <email@hidden> wrote:
Be sure to check the buffer length of the audio session. The simulator will be different than the actual device.


---
Check out my new iPhone app, FlipTalk. Once featured on the iTunes App Store "What's Hot" list!
http://fliptalkapp.com
http://itunes.com/apps/FlipTalk/
http://tinyurl.com/FlipTalkYoutube





On Sat, Mar 6, 2010 at 2:03 AM, tahome izwah <email@hidden> wrote:
Of course it buzzes if your cycle length doesn't coincide with
inNumberFrames. You need to remember your "j" across calls (make it
static to see if it solves your problem).

Also, why are you using 512 instead of inNumberFrames in your loop?
That doesn't make much sense to me as there is no reason to believe
that inNumberFrames will always be 512 frames.

In addition, your sine wave will cause digital clipping (wrapping)
when you multiply the result of the sin() call by 32768. Make sure you
limit your output to the range -32768...32767 to be on the safe side.

HTH
--th


2010/3/6 Sung <email@hidden>:
> Hi all,
> There was a thread about creating a custom AU to play a simple sine wave:
> http://lists.apple.com/archives/coreaudio-api/2008/nov/msg00292.html
> 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


 _______________________________________________
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

References: 
 >iPhone Custom Audio Unit: why buzz? (From: Sung <email@hidden>)
 >Re: iPhone Custom Audio Unit: why buzz? (From: tahome izwah <email@hidden>)
 >Re: iPhone Custom Audio Unit: why buzz? (From: Doug McCoy <email@hidden>)

  • Prev by Date: Re: iPhone Custom Audio Unit: why buzz?
  • Next by Date: Re: iPhone Custom Audio Unit: why buzz?
  • Previous by thread: Re: iPhone Custom Audio Unit: why buzz?
  • Next by thread: Re: iPhone Custom Audio Unit: why buzz?
  • Index(es):
    • Date
    • Thread