Help

From: Gerard Maurice Anthony ORourke (96414111@ugmail.eeng.dcu.ie)
Date: Tue Mar 21 2000 - 14:13:28 EST


Hi,
I'm doing my final year project in DCU (IRELAND) and I'm using saol.
What I have to do is code music so that it can be played using saol.
I'm using a program called SMS ot extract data (ie frequency components)
from audio file. Then using a matlab program I match the frequencies I
wish to play and then produce a sasl file like this

0.00000 vtone 0.0025 0.0627 0.0625
0.00251 vtone 0.0025 0.0625 0.0628
   : : : : :
   : : : : :
   : : : : :
   : : : : :
   : : : : :
   : : : : :
   : : : : :
   : : : : :
  
1.50 end

 The problem I am having is that I need to change the frequency being
played every 2.5ms. This causes a discontinuity problem in the output
wave. What I need to do is start the next instance of the instr using the
last values of the asig variables X and Y (used to create the sine wave).
I have tried to use global variables but no joy due to the fact that
global variables can not be asig. Here is the saol code that I have been
using. Can you PLEASE HELP ME.

Thanks
GERARD

global
  {
       srate 44100; // CD-quality
       krate 4410; // 417 us
  }

instr vtone (startfreq , endfreq)
     
{

  // declaration
  
  // envelope settings
  ivar atime;
  ivar rtime;

  // internal env state
  ivar attack;
  ivar release;
  ivar sustain;
 
  ivar a; // sets osc frequency
  ivar b;
  ivar c;

  ksig env; // env output

  asig x, y, z; // osc state
  asig init;
  
  // computing starts here

  a = startfreq; // Start frequency
  b = endfreq; // end frequency
  c = (b-a)/s_rate; // incremental value

  atime = 0.1; // attack time (s)
  rtime = 0.1; // decay time (s)

  // computes envelope state

  if ( dur > atime + rtime)
    {
        attack = atime;
        release = rtime;
        sustain = dur - atime - rtime;
    }
  else
    {
               attack = dur/2;
        release = dur/2;
        sustain = 0.2;
    }

 env = kline(0, attack, 1, sustain, 1, release, 0);

 // loop happens srate time per second
 // Therefor for interpolation increment (b-a)/44100 each loop cycle
 // to gain straigh line (frequency) interpolation.

  if (init == 0)
    {
              x = 0.25;
        init = 1;
    }

  z = z + c;

  x = x - (a+z)*y;
  y = y + (a+z)*x;
  
  output(y*env);

}



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