Re: Question on Oparray's

From: Robin Davies (rerdavies@hotmail.com)
Date: Mon Mar 19 2001 - 21:20:12 EST


>From: Michael J McGonagle <fndsnd@earthlink.net>
>To: saol-dev@media.mit.edu, saol-user@media.mit.edu
>Subject: Re: Question on Oparray's
>Date: Mon, 19 Mar 2001 17:31:22 +0600
>
>Well, part of the reason that I was hoping to use the built-in 'kline'
>opcode is so that I don't have to deal with handling tempo changes. I would
>like to be able to use the envelopes to control larger-scale structure
>(more
>than just instrument envelopes). These envelopes would be operating over a
>time frame of about ~10 seconds to about 10 minutes.

kline doesn't actually pay attention to tempo. Try something like this
(again, I'll leave you to work out the details of releases &c... I'm not
quite sure I follow where you're going.

(all code off the cuff... you'll have to debug it yourself..)

  // k-rate table-driven envelope.
  kopcode TableEnvelopeWithTempo(table t) {
   ksig kBeatsRemaining;
   ksig kDeltaValue;
   ksig kValue;
   ksig kLastTargetValue;
   ksig kTableIndex;
   ksig kSig;
   ksig kSegmentLength;
   ksig kTargetValue;
   ksig kBeatsThisKCycle;
   ... // initialization, trigger handling, &c.

   while (kBeatsRemaining <= 0) { // Next segment?
       if (kTableIndex >= ftlen(t)) return (0);
       kSegmentLength = tableread(kTableIndex);
       kTargetValue = tableread(kTableIndex+1);
       kTableIndex = kTableIndex + 2;

       if (kSegmentLength-kBeatsRemaining > 0) { // prevents divide-by-zero
           kDeltaValue =
              (kTargetValue-kLastTargetValue)
               / (kSegmentLength-kBeatsRemaining);
       }
       kBeatsRemaining = kBeatsRemaining + kSegmentLength;
       kValue = kLastTargetValue;
       kLastTargetValue = kTargetValue;
   }
   kBeatsThisKCycle
       = gettempo(kSig)*(1.0/(60.0*k_rate));
   kBeatsRemaining = kBeatsRemaining - kBeatsThisKCycle;
   kValue = kValue
     + kDeltaValue *kBeatsThisKCycle;
   return (kValue);
  };

That's the basic idea, anyway. If you keep the counter in beats, then
gettempo(kSig)/(60.0*k_rate) gives you the
number of beats in the current k-cycle.

You could do the same thing at a-rate, I suppose, but you will run into
precision problems if you are trying to ramp over 10 minutes. There are
about 24 bits of precision in a floating point number; and there are about
2^25 samples in 10 minutes. That's also not quite enough precision for a
10-minute k-rate envelope either. You might have to work a little harder to
get adequate precision to deal with this long a ramp (although it should be
said that kline and family will also suffer from the same problems with
precision on a ramp this long).

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 12:11:07 EST