• 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: How to delay AudioQueue playing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delay AudioQueue playing


  • Subject: Re: How to delay AudioQueue playing
  • From: Michael Becker <email@hidden>
  • Date: Thu, 1 Oct 2009 12:39:45 +0200

Thanks for the reply! The "lag" you are talking about should be fine for me, as long as I get the playback working. The user is not really supposed to switch samples on or off in realtime. But I will keep Audio Units in the back of my mind in case I will have to use them.

Here's my problem with what you suggest about the buffer: If the time has come to "play silence" for the duration of one sample, you say, I should either not enqueue the next buffer or play zeroes. But if I don't call AudioQueueEnqueueBuffer, the callback is never called again for that AudioQueue. In other words: how can I resume playback after the one-sample-pause? My idea was to user AudioQueueEnqueueBufferWithParameters and pass a certain AudioTimeStamp for its starttime, but I cannot wrap my head around how to set that timestamp. I think at that moment the "lag" you are talking about might become a problem - the AudioQueue's timestamp I can only get in real-time whereas the buffer playback will be sometime in the future.

I have the gut-feeling that my simple setup (all samples are same length and type) should make this all easier...

Regards,
Michael

Am 01.10.2009 um 02:07 schrieb Steven Winston:

AudioQueue unfortunately isn't the best way to go about doing this.
It inherently creates a queue that's buffered ahead of the PCM data
that's played.  You'll notice a "lag" on anything that you alter in
your buffering callback which is what you'd expect from that type of
application.  Might I recommend using AudioUnits?  They'll give you
quicker feedback.

That said, here's the trick that will solve your current question of
how to play silence:

in AudioQueueServices you have a buffer callback and somewhere a call
to AudioQueueEnqueueBuffer.  Don't call that when you don't want audio
from that AudioQueue to play.  That or you can pass it a buffer full
of 0.

On Wed, Sep 30, 2009 at 9:06 AM, Michael Becker <email@hidden > wrote:
Hello list, this is my first post!

I have been searching a lot on the web and in the list archives, but I have
not found anything that helped me, although I guess that my question has
been asked a zillion times before: I am trying to build an audio sequencer,
i.e. an 8 track sequencer that plays audio samples. The concept is fairly
easy: Every sample is exactly the same length, the user can only switch
samples on or off for a complete duration.


I am using the AudioQueue API and I think I understand that I should use one
Audio Queue for each track. So far I have managed to have two queues loop
two samples synchronously. I basically stuck to the Apple documentation
("Looping audio files"). It works great, they are perfectly in sync.


Now comes the problem: How do I omit individual samples during playback? I
think the solution either comes down to "playing silence" for the duration
of one or more samples, or delaying the playback of the next sample for a
time that is a multiple of a sample length.


On a sidenote: Is this the right way to go about this? Or should I somehow
create a "main clock" that ticks and only play samples according to this
"clock"? (Instead of rigorously looping the samples back to back).


Maybe I am phrasing my question the wrong way, but please bear with me as I
am really new to Core Audio and Sound programming in general.


Kind regards,
Michael
_______________________________________________
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
  • Follow-Ups:
    • Re: How to delay AudioQueue playing
      • From: Doug Wyatt <email@hidden>
  • Prev by Date: kAudioUnitSubType_AUiPodTime
  • Next by Date: AU, Obj-C and names
  • Previous by thread: Re: kAudioUnitSubType_AUiPodTime
  • Next by thread: Re: How to delay AudioQueue playing
  • Index(es):
    • Date
    • Thread