CSL  6.0
SoundFileCA.h
Go to the documentation of this file.
1 ///
2 /// SoundFileCA.h -- CSL's concrete sound file class for CoreAudio files
3 /// Note: this is experimental and incomplete as of CSL 5.0
4 ///
5 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
6 ///
7 
8 #ifndef CSL_SoundFileCA_H
9 #define CSL_SoundFileCA_H
10 
11 #include "SoundFile.h"
12 #import <AudioToolbox/ExtendedAudioFile.h>
13 
14 namespace csl {
15 
16 ///
17 /// CoreAudio sound file
18 ///
19 
20 class CASoundFile : public Abst_SoundFile {
21 public:
22  CASoundFile(CFURLRef path, bool load = true);
23  CASoundFile(string path, int start = -1, int stop = -1, bool load = true);
24  CASoundFile(CASoundFile & otherSndFile); ///< Copy constructor -- shares sample buffer
25  ~CASoundFile();
26 
27  SoundFileFormat format(); ///< get format
28  void dump(); ///< log snd file props
29  ///< open file and get stats; read it if "load"
30  void openForRead(bool load = true) throw (CException);
31  /// Open a file for write.
32  /// Default values are some common format.
34  unsigned channels = 1,
35  unsigned rate = 44100,
36  unsigned bitDepth = 16) throw (CException);
37  void openForReadWrite() throw (CException); ///< open r/w
38  void close(); ///< close file
39  /// seek to some position
40  unsigned seekTo(int position, SeekPosition whence) throw(CException);
41  void readBufferFromFile(unsigned numFrames); ///< read a buffer from the file (possibly all of it)
42 
43  void writeBuffer(Buffer &inputBuffer) throw (CException); ///< write a buffer of data into the file
44 
45 protected:
46  void initFromSndfile(); ///< read SF header
47 // void convertFormat(unsigned num, unsigned start);
48 
49  CFURLRef mURL; ///< the full URL of the file
50  AudioFileID mSoundID; ///< the CS audio file ID
51  bool mBigEndian; ///< flag for endian-ness of sound file (varies byformat)
52 };
53 
54 }
55 
56 #endif
SeekPosition
Enumeration for seek flags.
Definition: CSL_Core.h:560
#define kSoundFileFormatAIFF
Definition: SoundFile.h:60
AudioFileID mSoundID
the CS audio file ID
Definition: SoundFileCA.h:50
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void writeBuffer(Buffer &inputBuffer)
write a buffer of data into the file
void openForRead(bool load=true)
void initFromSndfile()
read SF header
Definition: SoundFileCA.cpp:91
int SoundFileFormat
Definition: SoundFile.h:65
string path()
file name
Definition: SoundFile.h:158
CASoundFile(CFURLRef path, bool load=true)
Definition: SoundFileCA.cpp:64
CFURLRef mURL
the full URL of the file
Definition: SoundFileCA.h:49
bool mBigEndian
flag for endian-ness of sound file (varies byformat)
Definition: SoundFileCA.h:51
void readBufferFromFile(unsigned numFrames)
read a buffer from the file (possibly all of it)
SoundFileFormat format()
get format
Definition: SoundFileCA.cpp:85
unsigned seekTo(int position, SeekPosition whence)
seek to some position relative to "whence"
void close()
close file seek to some position
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
void dump()
log snd file props < open file and get stats; read it if "load"
void openForReadWrite()
open r/w
Here's the abstract sound file reader/writer class, a sample player UGen. The concrete subclasses rep...
Definition: SoundFile.h:101
unsigned channels() const
accessors
Definition: SoundFile.cpp:157
void openForWrite(SoundFileFormat format=kSoundFileFormatAIFF, unsigned channels=1, unsigned rate=44100, unsigned bitDepth=16)
Open a file for write. Default values are some common format.
Base class of CSL exceptions (written upper-case). Has a string message.
CoreAudio sound file.
Definition: SoundFileCA.h:20