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

Jukebox Class Reference

#include <Jukebox.h>

Collaboration diagram for Jukebox:

Collaboration graph
[legend]
List of all members.

Public Slots

void stopPlay ()
void ambiOn ()
void talkOn (int n)
void maskOn (int n)
void playA ()
void playB ()

Signals

void updateProgress (int)
void quitAll ()

Public Member Functions

 Jukebox ()
 ~Jukebox ()
int getNumTalkFiles ()
int getNumMaskFiles ()
int openFiles (int b, QString dir, QString ch1String, QString type, bool loop=false, double gain=10.0)
void setNumTrials (int n)
void setTrial (int n, int ct, int cm, bool silenceOnA)
void tick ()
double getOut (int ch)

Public Attributes

double * out
FileWvInsndFile [MAXFILES]
FileWvInambi [CH]
FileWvIntalk [CH]
FileWvInmask [CH]
int ambiBase
int talkBase
int maskBase
int ambiFiles
int talkFiles
int at
int bt
int am
int bm
int maskFiles
int nTrials
int nowTrial

Detailed Description

Definition at line 14 of file Jukebox.h.


Constructor & Destructor Documentation

Jukebox::Jukebox  ) 
 

Definition at line 8 of file Jukebox.cpp.

References ambi, ambiBase, ambiFiles, ambiOn(), CH, mask, maskBase, maskFiles, MAXFILES, nowTrial, openFiles(), out, talk, talkBase, and talkFiles.

00009 {
00010         out = new double[CH];
00011         nowTrial = 0;
00012         ambi[0] = NULL;
00013         talk[0] = NULL;
00014         mask[0] = NULL;
00015 
00016         //LINK to SOURCE Directory==============
00017         //======================================
00018         //QString rootDir ("/usr/ccrma/snd/jcaceres/yamaha/recordings/experiments/experiment01/TEST/");
00019         //QString rootDir ("/usr/ccrma/snd/jcaceres/yamaha/recordings/experiments/experiment01/");
00020 
00021         QString rootDir ("/user/j/jcaceres/yamaha/recordings/experiments/beta_test/");
00022         //======================================
00023         //======================================
00024 
00025         ambiBase = 0;
00026 
00027         ambiFiles = openFiles (ambiBase, QString (rootDir + "ambient/"),
00028                            NULL,QString ("ambient"), true, 1.0); // all, ambient, loop 'em
00029         //cout << " opened " << ambiFiles << " files for ambi file group" << endl;
00030         talkBase = ambiBase + ambiFiles;
00031         talkFiles =
00032                 openFiles (talkBase,
00033                            QString (rootDir + "CONVconversations/"),
00034                            QString ("adj_"), // adj_, pzm
00035                    QString ("dir1"), true, 1.0); //dir1
00036         //cout << " opened " << talkFiles << " files for talk file group" << endl;
00037                            
00038         maskBase = talkBase + talkFiles;
00039         maskFiles = openFiles (maskBase, QString (rootDir + "CONVnoises/"),
00040                            QString ("adj_"), // adj_, pzm
00041                    QString ("dir1"), true, 10.0);
00042         //cout << " opened " << maskFiles << " files for mask file group" << endl;
00043 
00044         int total = maskBase + maskFiles;
00045         //cout << "jukebox opened " << total << " total files" << endl;
00046         if (total > MAXFILES)
00047                 qWarning ("too many soundfiles for current limit ");
00048         else
00049                 ambiOn ();
00050 }

Here is the call graph for this function:

Jukebox::~Jukebox  ) 
 

Definition at line 52 of file Jukebox.cpp.

00053 {
00054   //cout << "~Jukebox ()" << endl;
00055 }


Member Function Documentation

void Jukebox::ambiOn  )  [slot]
 

Definition at line 124 of file Jukebox.cpp.

References ambi, ambiBase, CH, FileWvIn::go(), and sndFile.

Referenced by Jukebox().

00125 {
00126         int x = ambiBase;
00127         for (int ch = 0; ch < CH; ch++)
00128         {
00129                 ambi[ch] = sndFile[x + ch];
00130         }
00131         for (int ch = 0; ch < CH; ch++)
00132         {
00133                 ambi[ch]->go ();
00134         }
00135         //cout << "ambi[" << 0 << "] = " << " --> snd " << x << endl;
00136 }

int Jukebox::getNumMaskFiles  )  [inline]
 

Definition at line 37 of file Jukebox.h.

References maskFiles.

Referenced by MainDialog::MainDialog().

00037 {return maskFiles;};

int Jukebox::getNumTalkFiles  )  [inline]
 

Definition at line 35 of file Jukebox.h.

Referenced by MainDialog::MainDialog().

00035 {return talkFiles;};

double Jukebox::getOut int  ch  ) 
 

Definition at line 209 of file Jukebox.cpp.

References out.

Referenced by Snd::tickOrch().

00210 {
00211         return out[ch];
00212 }

void Jukebox::maskOn int  n  )  [slot]
 

Definition at line 153 of file Jukebox.cpp.

References CH, FileWvIn::go(), mask, maskBase, maskFiles, and sndFile.

Referenced by playA(), and playB().

00154 {
00155         int x = maskBase + ((n * 4) % maskFiles);
00156         for (int ch = 0; ch < CH; ch++)
00157         {
00158                 mask[ch] =
00159                         sndFile[x + ch];
00160         }
00161         for (int ch = 0; ch < CH; ch++)
00162         {
00163                 mask[ch]->go ();
00164         }
00165         //cout << "mask[" << n << "] = " << " --> snd " << x << endl;
00166 }

int Jukebox::openFiles int  b,
QString  dir,
QString  ch1String,
QString  type,
bool  loop = false,
double  gain = 10.0
 

Definition at line 58 of file Jukebox.cpp.

References CH, FileWvIn::setGain(), FileWvIn::setLoop(), and sndFile.

Referenced by Jukebox().

00060 {
00061         int total = 0;
00062         QDir d (dir);
00063         if (!d.exists ())
00064                 qWarning ("Cannot find the soundfile directory " + *dir);
00065         else
00066                 d.cd (d.dirName ());
00067         QStringList ls_chan1 = d.entryList ("*.wav; *.aiff");   // all files
00068 
00069         ls_chan1 = ls_chan1.grep (ch1String);   // find a group with this token, NULL returns all
00070                                 
00071         // loop through group of chan1's finding their stubs e.g., CONV_2people_e_adj_
00072         for (QStringList::Iterator f = ls_chan1.begin ();
00073              (f != ls_chan1.end ()); ++f)
00074         {
00075                 QFileInfo fi (dir + *f);
00076                 QString base = fi.baseName ();
00077                 QString stub = base.remove ("01pzm1");
00078  //             cout << "file[] " << dir + *f << " " << stub << endl;
00079 // ok, got a stub so now open all of it's channels
00080                 QStringList chans = d.entryList ("*.wav; *.aiff");      // all files
00081                 chans = chans.grep (stub);      // stub's chans
00082                 int ch = 0;
00083                 for (QStringList::Iterator y = chans.begin ();
00084                      ((y != chans.end ()) && (ch < CH)); ++y, ch++)
00085                 {
00086                         QString s = *y;
00087                         if (s.contains (type))
00088                         {
00089                                 int ind = (b + total);
00090                                 sndFile[ind] = new FileWvIn (dir + *y);
00091                                 sndFile[ind]->setLoop(loop);
00092                                 sndFile[ind]->setGain(gain);
00093 //                              cout << "sndFile[" << ind << "] = " << dir +
00094 //                                      *y << " --> ch " << ind << endl;
00095                                 total++;
00096                         }
00097                 }
00098         }
00099         return (total);
00100 }

Here is the call graph for this function:

void Jukebox::playA  )  [slot]
 

Definition at line 169 of file Jukebox.cpp.

References am, at, maskOn(), stopPlay(), and talkOn().

00170 {
00171 stopPlay ();
00172         talkOn(at);
00173         maskOn(am);
00174 }

void Jukebox::playB  )  [slot]
 

Definition at line 178 of file Jukebox.cpp.

References bm, bt, maskOn(), stopPlay(), and talkOn().

00179 {
00180 stopPlay ();
00181         talkOn(bt);
00182         maskOn(bm);
00183 }

void Jukebox::quitAll  )  [signal]
 

Definition at line 113 of file moc_Jukebox.cpp.

Referenced by setTrial().

00114 {
00115     activate_signal( staticMetaObject()->signalOffset() + 1 );
00116 }

void Jukebox::setNumTrials int  n  )  [inline]
 

Definition at line 41 of file Jukebox.h.

References nTrials.

Referenced by MainDialog::MainDialog().

00041 {nTrials = n;};

void Jukebox::setTrial int  n,
int  ct,
int  cm,
bool  silenceOnA
 

Definition at line 186 of file Jukebox.cpp.

References am, at, bm, bt, NO_TALK_FILE_BASE, nowTrial, nTrials, quitAll(), and updateProgress().

Referenced by MainDialog::trialTick().

00187 {
00188   nowTrial = n;
00189   if (nowTrial == nTrials) {
00190     //JPa************************************************************
00191     //cout << "BEFORE QUIT" << endl;
00192     //**************************************************************
00193     emit quitAll ();
00194   }
00195   double p = (double) n / (double) (nTrials - 1);
00196   emit updateProgress ((int) (p * 100.0));
00197   if (silenceOnA)
00198     {
00199       at = NO_TALK_FILE_BASE;
00200       bt = ct;
00201     }   else {
00202     bt = NO_TALK_FILE_BASE;
00203     at = ct;
00204   }
00205   am = bm = cm;
00206 }

void Jukebox::stopPlay  )  [slot]
 

Definition at line 103 of file Jukebox.cpp.

References CH, mask, FileWvIn::stop(), and talk.

Referenced by playA(), playB(), and MainDialog::trialTick().

00104 {
00105         if (talk[0] != NULL)
00106         {
00107                 for (int ch = 0; ch < CH; ch++)
00108                 {
00109                         talk[ch]->stop ();
00110                 }
00111                 talk[0] = NULL;
00112         }
00113         if (mask[0] != NULL)
00114         {
00115                 for (int ch = 0; ch < CH; ch++)
00116                 {
00117                         mask[ch]->stop ();
00118                 }
00119                 mask[0] = NULL;
00120         }
00121 }

void Jukebox::talkOn int  n  )  [slot]
 

Definition at line 138 of file Jukebox.cpp.

References CH, FileWvIn::go(), sndFile, talk, talkBase, and talkFiles.

Referenced by playA(), and playB().

00139 {
00140         int x = talkBase  + ((n * 4) % talkFiles);
00141         for (int ch = 0; ch < CH; ch++)
00142         {
00143                 talk[ch] =
00144                         sndFile[x + ch];
00145         }
00146         for (int ch = 0; ch < CH; ch++)
00147         {
00148                 talk[ch]->go ();
00149         }
00150         //cout << "talk[" << n << "] = " << " --> snd " << x << endl;
00151 }

void Jukebox::tick  ) 
 

Definition at line 215 of file Jukebox.cpp.

References ambi, CH, FCH, mask, out, and talk.

Referenced by Snd::tickOrch().

00216 {
00217         for (int ch = 0; ch < CH; ch++)
00218                 out[ch] = 0.0;
00219         StkFrames f (0.0, 1, FCH);
00220         if (ambi[0] != NULL)
00221                 for (int ch = 0; ch < CH; ch++)
00222                 {
00223                         ambi[ch]->tickFrame (f);
00224                         out[ch] += f[0];
00225                 }
00226         if (talk[0] != NULL)
00227                 for (int ch = 0; ch < CH; ch++)
00228                 {
00229                         talk[ch]->tickFrame (f);
00230                         out[ch] += f[0];
00231                 }
00232         if (mask[0] != NULL)
00233                 for (int ch = 0; ch < CH; ch++)
00234                 {
00235                         mask[ch]->tickFrame (f);
00236                         out[ch] += f[0];
00237                 }
00238         return;
00239 }

void Jukebox::updateProgress int   )  [signal]
 

Definition at line 107 of file moc_Jukebox.cpp.

Referenced by setTrial().

00108 {
00109     activate_signal( staticMetaObject()->signalOffset() + 0, t0 );
00110 }


Member Data Documentation

int Jukebox::am
 

Definition at line 33 of file Jukebox.h.

Referenced by playA(), and setTrial().

FileWvIn* Jukebox::ambi[CH]
 

Definition at line 23 of file Jukebox.h.

Referenced by ambiOn(), Jukebox(), and tick().

int Jukebox::ambiBase
 

Definition at line 26 of file Jukebox.h.

Referenced by ambiOn(), and Jukebox().

int Jukebox::ambiFiles
 

Definition at line 29 of file Jukebox.h.

Referenced by Jukebox().

int Jukebox::at
 

Definition at line 31 of file Jukebox.h.

Referenced by playA(), and setTrial().

int Jukebox::bm
 

Definition at line 34 of file Jukebox.h.

Referenced by playB(), and setTrial().

int Jukebox::bt
 

Definition at line 32 of file Jukebox.h.

Referenced by playB(), and setTrial().

FileWvIn* Jukebox::mask[CH]
 

Definition at line 25 of file Jukebox.h.

Referenced by Jukebox(), maskOn(), stopPlay(), and tick().

int Jukebox::maskBase
 

Definition at line 28 of file Jukebox.h.

Referenced by Jukebox(), and maskOn().

int Jukebox::maskFiles
 

Definition at line 35 of file Jukebox.h.

Referenced by getNumMaskFiles(), Jukebox(), and maskOn().

int Jukebox::nowTrial
 

Definition at line 43 of file Jukebox.h.

Referenced by Jukebox(), and setTrial().

int Jukebox::nTrials
 

Definition at line 40 of file Jukebox.h.

Referenced by setNumTrials(), and setTrial().

double* Jukebox::out
 

Definition at line 19 of file Jukebox.h.

Referenced by getOut(), Jukebox(), and tick().

FileWvIn* Jukebox::sndFile[MAXFILES]
 

Definition at line 22 of file Jukebox.h.

Referenced by ambiOn(), maskOn(), openFiles(), and talkOn().

FileWvIn* Jukebox::talk[CH]
 

Definition at line 24 of file Jukebox.h.

Referenced by Jukebox(), stopPlay(), talkOn(), and tick().

int Jukebox::talkBase
 

Definition at line 27 of file Jukebox.h.

Referenced by Jukebox(), and talkOn().

int Jukebox::talkFiles
 

Definition at line 30 of file Jukebox.h.

Referenced by Jukebox(), and talkOn().


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