• 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: What sort of timer should I use for my sequencer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What sort of timer should I use for my sequencer?


  • Subject: Re: What sort of timer should I use for my sequencer?
  • From: Aran Mulholland <email@hidden>
  • Date: Tue, 18 Jan 2011 11:50:57 +1100

To clarify:

I actually have a sequencer that works by counting samples. However it has some dodgy components. (the next step is "loaded" from the render callback) I'm inquiring about the threading solutions that have been used in this situation.

On Tue, Jan 18, 2011 at 11:28 AM, Aran Mulholland <email@hidden> wrote:
*bump*

"...removing my audio generation code from the RemoteIO callback thread, I'm going to need some sort of timer to tell my audio generation code when it's time to create some more samples, right?"

I would be interested to the ways people have approached this.

Thanks
Aran

On Sun, Jan 16, 2011 at 9:20 AM, Morgan Packard <email@hidden> wrote:
Thanks Brian,
Now, if I'm following you all's advice, and removing my audio generation code from the RemoteIO callback thread, I'm going to need some sort of timer to tell my audio generation code when it's time to create some more samples, right? 
thanks,
-Morgan

On Sat, Jan 15, 2011 at 3:06 PM, Brian Willoughby <email@hidden> wrote:
Greg is right, Morgan.  However, I would add my comment that you're probably working too hard by calculating the time for each and every sample.  Instead, I would imagine that your sequencer deals with events that start at a particular time and end at a particular time.  You would then work in reverse, by calculating the starting sample offset based upon the starting time, and the ending sample number based on the end time.  Then, just iterate your processing on the samples in that range.  There should be no need to keep track of the time for every individual sample, unless you're executing a conditional on every sample - and that would certainly be a waste of CPU.

In other words, process in terms of sample ranges (buffers), not individual samples.  Then sequence in terms of event times, with start and end times converted to sample offsets.  If an offset lies outside of the current sample buffer, then just process to/from the edge of the buffer, or skip the processing entirely if nothing happens in a given buffer.

Brian Willoughby
Sound Consulting



On Jan 15, 2011, at 12:42, Gregory Wieber wrote:
This has been covered extensively in past discussions here. (Search for coreaudio mailing list entries on 'metronome', 'sequencer', etc.) Counting samples is the most accurate way to go.

On Sat, Jan 15, 2011 at 12:39 PM, Morgan Packard <email@hidden> wrote:
I've been calculating time by simply counting samples (each time I calculate a sample, I tick my time count forward) and dividing by sample rate. I suspect this isn't the best way. It seems to me that it would be better to have a sequencer running in in a separate thread from my audio generation code. NSTimer would be my first choice, but is not accurate enough for music. How can I set up a timer which is accurate enough for music?


_______________________________________________
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



--
================================
Web:
http://www.morganpackard.com

Music/Art:
Album Moment Again Elsewhere available Oct 11.
iOS app Thicket available on iTunes store.
================================


 _______________________________________________
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: What sort of timer should I use for my sequencer?
      • From: Morgan Packard <email@hidden>
References: 
 >What sort of timer should I use for my sequencer? (From: Morgan Packard <email@hidden>)
 >Re: What sort of timer should I use for my sequencer? (From: Gregory Wieber <email@hidden>)
 >Re: What sort of timer should I use for my sequencer? (From: Brian Willoughby <email@hidden>)
 >Re: What sort of timer should I use for my sequencer? (From: Morgan Packard <email@hidden>)
 >Re: What sort of timer should I use for my sequencer? (From: Aran Mulholland <email@hidden>)

  • Prev by Date: Re: What sort of timer should I use for my sequencer?
  • Next by Date: AC-3 decode in Leopard+
  • Previous by thread: Re: What sort of timer should I use for my sequencer?
  • Next by thread: Re: What sort of timer should I use for my sequencer?
  • Index(es):
    • Date
    • Thread