• 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
TPCircularBuffer Usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TPCircularBuffer Usage


  • Subject: TPCircularBuffer Usage
  • From: Pier <email@hidden>
  • Date: Sat, 17 Nov 2012 13:03:44 +0800

Hi, 

I'm using Michael Tyson's famous TCCircularBuffer from this page. 
http://atastypixel.com/blog/a-simple-fast-circular-buffer-implementation-for-audio-processing/

I'm trying to use it in a way where I keep the pointer to the start of my audio data. 

    SInt16 *buffer = TPCircularBufferTail(&THIS->buffer, &availableBytes);
    memcpy(targetBuffer, buffer, MIN(bytesToCopy, availableBytes)); // targetBuffer is playback buffer
    TPCircularBufferConsume(&THIS->buffer, sampleCount);

The first time I go into the above code, I keep a copy of *buffer and name it *startPtr, so that I can use it in my audio code for playback manually. I know that the data has been "consumed" by TPCircularBufferConsume, but it seems to be still there. 

I'm able to play it back from *startPtr by looping this

    memcpy(targetBuffer, startPtr, MIN(bytesToCopy, availableBytes));
    startPtr += (bytesToCopy / sizeof(SInt16));  // startPtr is SInt16 pointer

but once I stop the playback - and go on to do other things within the application, and then return back to activate the playback again, it doesn't work anymore. (plays back silence) 

Why is this so, and am I making a terrible mistake by doing the above? 

Thanks. 

-- 
Pier.

 _______________________________________________
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

  • Follow-Ups:
    • Re: TPCircularBuffer Usage
      • From: Daniel Vollmer <email@hidden>
  • Prev by Date: Multi-input audio unit - inBuffer.mNumberBuffers is always 2?
  • Next by Date: Re: TPCircularBuffer Usage
  • Previous by thread: Multi-input audio unit - inBuffer.mNumberBuffers is always 2?
  • Next by thread: Re: TPCircularBuffer Usage
  • Index(es):
    • Date
    • Thread