Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Snd Class Reference

#include <Snd.h>

List of all members.

Public Slots

void orchUpdate (double val)
void go ()
void stop ()

Public Member Functions

 Snd (int chans, int srate, int buffsize)
virtual ~Snd ()
void addInstrument (Jukebox *i)
double * tickFrame (double *in)
double * tickOrch (double *tmp)

Public Attributes

int _chans
int _srate
int _buffsize
double * out
double * in
int ctr
int tick_ctr
QWaitCondition nexttick
bool running
double bufTime
double timeInc
QPtrList< Jukeboxorch


Detailed Description

Definition at line 12 of file Snd.h.


Constructor & Destructor Documentation

Snd::Snd int  chans,
int  srate,
int  buffsize
 

Definition at line 14 of file Snd.cpp.

References _buffsize, _chans, _srate, ctr, in, orch, out, running, tick_ctr, and timeInc.

00014                                            :
00015 _chans(chans),
00016 _srate(srate),
00017 _buffsize(buffsize)
00018 {
00019         orch.setAutoDelete (true);      // will delete all instruments in orchestra list
00020         Stk::setSampleRate ((double) _srate);
00021 //      Stk::setRawwavePath ("/home/cc/220a/system/stk-4.2.1/rawwaves/");
00022         out = new double[_chans];
00023         in = new double[_chans];
00024         running = false;
00025         ctr = 0;
00026         timeInc = ((double) (_buffsize)) / Stk::sampleRate ();
00027         tick_ctr = 0;
00028 }

Snd::~Snd  )  [virtual]
 

Definition at line 30 of file Snd.cpp.

References in, and out.

00031 {
00032         delete[]out;
00033         delete[]in;
00034 }


Member Function Documentation

void Snd::addInstrument Jukebox i  ) 
 

Definition at line 112 of file Snd.cpp.

References orch.

Referenced by MainDialog::MainDialog().

00114 {
00115         orch.append (i);
00116         int tmp = orch.count ();
00117         // cout << tmp << endl;
00118 }

void Snd::go  )  [slot]
 

Definition at line 78 of file Snd.cpp.

References bufTime, ctr, running, and tick_ctr.

00079 {
00080         ctr = 0;
00081         bufTime = 0.0;
00082         running = true;
00083         tick_ctr = 0;
00084 }

void Snd::orchUpdate double  val  )  [slot]
 

Definition at line 121 of file Snd.cpp.

References orch.

00123 {
00124         Jukebox *i = orch.first ();
00125         while (i)
00126         {
00127 //              i->update (val);
00128                 i = orch.next ();
00129         }
00130 }

void Snd::stop  )  [slot]
 

Definition at line 87 of file Snd.cpp.

References running.

00088 {
00089         running = false;
00090 }

double * Snd::tickFrame double *  in  ) 
 

Definition at line 38 of file Snd.cpp.

References _buffsize, _chans, bufTime, ctr, GAIN, nexttick, out, running, tick_ctr, tickOrch(), and timeInc.

Referenced by xx_global_process_xx().

00040 {
00041         bool overflow = false;
00042         if (running)
00043         {
00044                 /* ------ this is where the real work happens ------ */
00045                 ctr++;
00046                 out = tickOrch (in);    // process orchestra objects
00047         for (int ch = 0; ch < _chans; ch++)
00048                 out[ch] *= GAIN;
00049                 if ((fabs (out[0]) > 1.0) || (fabs (out[0]) > 1.0))
00050                         overflow = true;
00051 //  out[0] = out[1] = sin(6.28*0.001*(double)ctr);
00052         }
00053         else // muted
00054         {
00055         for (int ch = 0; ch < _chans; ch++)
00056                 out[ch] = 0.0;
00057         }
00058         if (running)
00059         {
00060                 /* ------ wake any per buffer processes ------ */
00061                 tick_ctr++;
00062                 if (tick_ctr == _buffsize)
00063                 {
00064                         bufTime += timeInc;
00065                         nexttick.wakeAll ();
00066                         tick_ctr = 0;
00067                 }
00068         }
00069         if (overflow)
00070         {
00071                 printf ("overflow\n");
00072         }
00073         return out;
00074 }

Here is the call graph for this function:

double * Snd::tickOrch double *  tmp  ) 
 

Definition at line 93 of file Snd.cpp.

References _chans, Jukebox::getOut(), orch, and Jukebox::tick().

Referenced by tickFrame().

00095 {
00096         for (int i = 0; i < _chans; i++)
00097                 tmp[i] = 0.0;
00098         Jukebox *i = orch.first ();
00099         while (i)
00100         {                       
00101                 // assign outputs by mod if more objects than channels
00102                 i->tick();
00103         for (int ch = 0; ch < _chans; ch++)
00104         tmp[ch] += i->getOut (ch);
00105                 i = orch.next ();
00106         }
00107                 tmp[1] = tmp[0];
00108         return tmp;
00109 }

Here is the call graph for this function:


Member Data Documentation

int Snd::_buffsize
 

Definition at line 18 of file Snd.h.

Referenced by Snd(), and tickFrame().

int Snd::_chans
 

Definition at line 16 of file Snd.h.

Referenced by Snd(), tickFrame(), and tickOrch().

int Snd::_srate
 

Definition at line 17 of file Snd.h.

Referenced by Snd().

double Snd::bufTime
 

Definition at line 26 of file Snd.h.

Referenced by go(), and tickFrame().

int Snd::ctr
 

Definition at line 22 of file Snd.h.

Referenced by go(), Snd(), and tickFrame().

double* Snd::in
 

Definition at line 21 of file Snd.h.

Referenced by Snd(), and ~Snd().

QWaitCondition Snd::nexttick
 

Definition at line 24 of file Snd.h.

Referenced by tickFrame().

QPtrList< Jukebox > Snd::orch
 

Definition at line 29 of file Snd.h.

Referenced by addInstrument(), orchUpdate(), Snd(), and tickOrch().

double* Snd::out
 

Definition at line 20 of file Snd.h.

Referenced by Snd(), tickFrame(), and ~Snd().

bool Snd::running
 

Definition at line 25 of file Snd.h.

Referenced by go(), Snd(), stop(), and tickFrame().

int Snd::tick_ctr
 

Definition at line 23 of file Snd.h.

Referenced by go(), Snd(), and tickFrame().

double Snd::timeInc
 

Definition at line 27 of file Snd.h.

Referenced by Snd(), and tickFrame().


The documentation for this class was generated from the following files:
Generated on Thu Aug 3 16:14:54 2006 by  doxygen 1.4.4