CSL  6.0
FileIO.h
Go to the documentation of this file.
1 //
2 // FileIO.h -- IO using a sound file for writing data to sound files
3 //
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 //
6 
7 #ifndef CSL_FileIO_H
8 #define CSL_FileIO_H
9 
10 #include "CSL_Includes.h"
11 #include "ThreadUtilities.h" // PThread utilities
12 
13 namespace csl {
14 
15 ///
16 /// FileIO.h -- IO using a sound file for storing output sample data
17 ///
18 
19 class FileIO : public IO {
20 public:
21  ///< the path name determines the file type, e.g., xx.aiff, zz.snd, or yy.wav
22  FileIO(char *path = NULL);
23  ~FileIO();
24 
25  bool mIsPlaying; ///< whether or not it's playing
26  bool mIsThreadRunning; ///< is the background thread running?
27  unsigned mDuration; ///< the file's buffer rate;
28  void open() throw(CException);
29  /// seconds is optional. If not passed, starts a background thread,
30  /// playing and writing, otherwise run for x seconds
31  /// (so it doesn't return until done).
32  void start(float seconds = 0) throw(CException);
33  void stop() throw(CException);
34  void close() throw(CException);
35  void test() throw(CException) { }; ///< test the IO's graph
36  ///< Get the current input from the sound card
37  Buffer & getInput() throw(CException) { return mInBuffer; };
38  Buffer & getInput(unsigned numFrames, unsigned numChannels) throw(CException) { return mInBuffer; };
39 
40 protected:
41  string mPath; // the output file name
42  SoundFile * mFile; // the output sound file
43  CThread * mThread; // the background thread
44  static void *threadFunction(void *); // the background thread function
45 
46  Buffer mInBuffer; // buffer we use for input
47  Buffer mOutBuffer; // buffer we use for output
48  void writeNextBuffer();
49 };
50 
51 }
52 
53 #endif
void test()
Definition: FileIO.h:35
The PThreads CSL Thread class.
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
bool mIsPlaying
whether or not it's playing
Definition: FileIO.h:25
CThread * mThread
Definition: FileIO.h:43
Buffer mOutBuffer
Definition: FileIO.h:47
Buffer & getInput()
test the IO's graph < Get the current input from the sound card
Definition: FileIO.h:37
unsigned mDuration
the file's buffer rate;
Definition: FileIO.h:27
void writeNextBuffer()
Definition: FileIO.cpp:95
string mPath
Definition: FileIO.h:38
virtual void start()
Definition: CSL_Core.h:761
void open()
Definition: FileIO.cpp:27
IO – the abstract I/O scheduling class; subclasses interface to specific I/O APIs.
Definition: CSL_Core.h:752
void close()
open/close start/stop methods
Definition: FileIO.cpp:85
Buffer mInBuffer
Definition: FileIO.h:46
void stop()
Definition: FileIO.cpp:77
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
FileIO(char *path=NULL)
< the path name determines the file type, e.g., xx.aiff, zz.snd, or yy.wav
Definition: FileIO.cpp:10
SoundFile * mFile
Definition: FileIO.h:42
static void * threadFunction(void *)
Definition: FileIO.cpp:106
bool mIsThreadRunning
is the background thread running?
Definition: FileIO.h:26
Base class of CSL exceptions (written upper-case). Has a string message.
FileIO.h – IO using a sound file for storing output sample data.
Definition: FileIO.h:19