1

I just started learning Core Audio and faced with an issue.

I have a simple iOS sound app with one button which plays some sound when pressed.
For sound playback I am using AudioUnits.
Everything is OK when the button is tapped with low frequency
But when I start to press it faster, so previous playback is interrupted on high amplitude - I hear clicking noise.
Here is the code samples:

Assigning file region:

AudioUnitSetProperty(audioUnit, kAudioUnitProperty_ScheduledFileRegion, kAudioUnitScope_Global, 0, &region, sizeof(region))

region is instance of ScheduledAudioFileRegion based on AudioFileID.

Starting playback:

AudioUnitSetProperty(audioUnit, kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0, &startTime, sizeof(startTime))

startTime is instance of AudioTimeStamp, which configured to play right away with mSampleTime = -1

Is there some useful technique to handle this issue? How can I fade out previous playback to remove this click sound?

jangofett
  • 59
  • 1
  • 12
  • What audio file format are you using? If raw samples, you can manually taper the first and last audio buffer of each sound, and configure the taper buffers to be very short (5 to 6 mS). – hotpaw2 Jun 09 '16 at 17:03
  • @hotpaw2, yes it's raw samples in PCM format. Can you please help me with render callback function. I am trying this code: `AURenderCallbackStruct input; input.inputProc = MyCallback; AudioUnitSetProperty(pad.audioUnitPlayer.audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &input, sizeof(input));` And I get **kAudioUnitErr_InvalidElement** error – jangofett Jun 11 '16 at 20:19
  • That looks like something that should be asked as a completely separate and new question. – hotpaw2 Jun 11 '16 at 20:24
  • @hotpaw2, Thanks for response. Here I created new question http://stackoverflow.com/questions/37773506/core-audio-file-playback-render-callback-function – jangofett Jun 12 '16 at 11:12
  • @hotpaw2 I am having the same exact problem. I have tapered the audio PCM buffer on with a fade OUT and a fade IN... It still seems to click and it seems to be stemming from the player somehow and not the audio file.... – KorinW Jan 21 '17 at 09:02

0 Answers0