CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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);
23 CASoundFile(string path, int start = -1, int stop = -1);
24 CASoundFile(string folder, string path, int start = -1, int stop = -1);
25 CASoundFile(CASoundFile & otherSndFile); ///< Copy constructor -- shares sample buffer
26 ~CASoundFile();
27
28 SoundFileFormat format(); ///< get format
29 void dump(); ///< log snd file props
30 void openForRead() throw (CException); ///< open file and get stats
31 /// Open a file for write.
32 /// Default values are some common format.
33 void openForWrite(SoundFileFormat format = kSoundFileFormatAIFF,
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