CSL  5.2
SoundFileJ.h
Go to the documentation of this file.
1 ///
2 /// SoundFileJ.h -- CSL's concrete sound file class using JUCE
3 ///
4 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 ///
6 
7 #ifndef CSL_SoundFileJ_H
8 #define CSL_SoundFileJ_H
9 
10 #include "SoundFile.h"
11 
12 #include "../JuceLibraryCode/JuceHeader.h"
13 #include "src/audio/audio_file_formats/juce_AudioFormatReader.h"
14 #include "src/audio/audio_file_formats/juce_AudioFormatWriter.h"
15 
16 namespace csl {
17 
18 ///
19 /// JUCE sound file
20 ///
21 
22 class JSoundFile : public Abst_SoundFile {
23 public:
24  JSoundFile(string path, int start = -1, int stop = -1);
25 // JSoundFile(string folder, string path, int start = -1, int stop = -1);
26  JSoundFile(JSoundFile & otherSndFile); ///< Copy constructor -- shares sample buffer
27  ~JSoundFile();
28 
29  unsigned duration() const; ///< number of frames in the sound file
30  SoundFileFormat format(); ///< get format
31  // open file and get stats
32  void openForRead(bool load = true) throw (CException);
33  /// Open a file for write. Default values are some common format.
35  unsigned channels = 1,
36  unsigned rate = 44100,
37  unsigned bitDepth = 16) throw (CException);
38  void openForReadWrite() throw (CException); ///< open r/w
39  void close(); ///< close file
40  /// seek to some position
41  unsigned seekTo(int position, SeekPosition whence) throw(CException);
42  void readBufferFromFile(unsigned numFrames); ///< read a buffer from the file (possibly all of it)
43 
44  void writeBuffer(Buffer &inputBuffer) throw (CException); ///< write a buffer of data into the file
45 
46  AudioFormatReader * mAFReader; ///< my reader
47  AudioFormatWriter * mAFWriter; ///< and my writer
48  File * mIOFile; ///< my JUCE file
49  FileOutputStream * mOutStream;
50 
51 protected:
52  void initFromSndfile(); ///< read SF header
53 // void convertFormat(unsigned num, unsigned start);
54 
55 };
56 
57 }
58 
59 #endif