Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C, CoreAudio: Possible reasons for which played sound has additional noise, hiss and pops?
    primarykey
    data
    text
    <p>I'm using CoreAudio to play some continuous sound. I managed to get it work, however I have a problem now that I can't overcome. The sound it's playing, more that that it's the actual sound I need, not just noise, but together with it I get noise, hiss, pops as well. </p> <p>I verified the sample rate, zero-ed out all the silence buffers, checked the channels (I'm positive I only have 1) and double checked the algorithm that feeds the playback method.(but I'll add it here just to be sure). My experience with sound it's slim, so probably I'm doing something very terrible wrong. I would like to know if there are other things to check or what's the best approach on this, where to look first?</p> <pre><code>//init playedBufferSize=audioFilesSize[audioFilesIndex]; startPointForPlayedBuffer=0; //feed the audio static OSStatus playbackCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { AudioBuffer buffer = ioData-&gt;mBuffers[0]; if (playedBufferSize&gt;=buffer.mDataByteSize) { memcpy(buffer.mData , audioFiles[audioFilesIndex]+startPointForPlayedBuffer, buffer.mDataByteSize); playedBufferSize-=buffer.mDataByteSize; startPointForPlayedBuffer+=buffer.mDataByteSize; }else { memcpy(buffer.mData , audioFiles[audioFilesIndex]+startPointForPlayedBuffer, playedBufferSize); nextAudioFileIndex(); memcpy(buffer.mData+playedBufferSize, audioFiles[audioFilesIndex], playedBufferSize); playedBufferSize = audioFilesSize[audioFilesIndex]-(buffer.mDataByteSize-playedBufferSize); startPointForPlayedBuffer = (buffer.mDataByteSize-playedBufferSize); } return noErr; } </code></pre> <p>EDIT: I know that this code above won't play the sound continously because it fills the buffer with a bunch of 0's at some point, however, I get many strange sounds along with that, if the sound would play and stop for a short while and start again I would be happy, a good start :)</p> <p>EDIT2: I edited the code so that it won't output silence anymore, still I get the hiss and pops unfortunately...</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload