• 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: Threading Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading Question


  • Subject: Re: Threading Question
  • From: Richard Dobson <email@hidden>
  • Date: Mon, 30 Jan 2012 23:30:37 +0000

Yes. It almost always comes down to counting samples and reading a list of event messages. The Synthesis Toolkit (STK, also part of MoMu) has example code for all this (and more), in its ADSR class.

Richard Dobson



On 30/01/2012 22:37, Gregory Wieber wrote:
    Perhaps instead of having attack and decay as functions, maybe you
could do your ADSR using a switch/case statement that uses an integer to
indicate which portion of the envelope you're in, and a sampleCount that
is incremented and causes the envelope to go into the next boundary when
the right number of samples have elapsed.

Eg, (I wrote this hastily, meant to be taken as pseudo code)

int ADSRIndex = 0; // attacking

...

nextBoundary = SAMPLE_RATE * attackInSeconds;

...

switch (ADSRIndex)
{
   case:
    {
       if (++sampleCount > nextBoundary)
       {
          ADSRIndex+= 1; // now its decaying
       }
      else amplitude+= amplitudeIncrement;
   }

... etc

}

_______________________________________________
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


References: 
 >Threading Question (From: ben kamen <email@hidden>)
 >Re: Threading Question (From: Gregory Wieber <email@hidden>)

  • Prev by Date: Re: Threading Question
  • Next by Date: Re: Threading Question
  • Previous by thread: Re: Threading Question
  • Next by thread: Re: Threading Question
  • Index(es):
    • Date
    • Thread