CSL  6.0
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 #include "../JuceLibraryCode/JuceHeader.h"
12 
13 namespace csl {
14 
15 ///
16 /// JUCE sound file
17 ///
18 
19 class JSoundFile : public Abst_SoundFile {
20 public: /// C'tors
21  JSoundFile(string path, int start = -1, int stop = -1);
22 // JSoundFile(string path, juce::MemoryInputStream * strm);
23  JSoundFile(JSoundFile & otherSndFile); ///< Copy constructor -- shares sample buffer
24  ~JSoundFile();
25 
26  /// Factory methods
27  static JSoundFile * openSndfile(string path, int start = -1, int stop = -1, bool doRead = true);
28 // static JSoundFile * openSndfile(string path, juce::MemoryInputStream * strm);
29 // static JSoundFile * openSndfile(float maxDurInSecs, string path);
30 
31  unsigned duration() const; ///< number of frames in the sound file
32  SoundFileFormat format(); ///< get format
33  /// open file and get stats
34  void openForRead(bool load = true) throw (CException);
35  void openForRead(juce::MemoryInputStream * strm) throw (CException);
36  /// Open a file for write. Default values are some common format.
38  unsigned channels = 1,
39  unsigned rate = 44100,
40  unsigned bitDepth = 16) throw (CException);
41  void openForReadWrite() throw (CException); ///< open r/w
42  void close(); ///< close file
43  /// seek to some position
44  unsigned seekTo(int position, SeekPosition whence) throw(CException);
45  void readBufferFromFile(unsigned numFrames); ///< read a buffer from the file (possibly all of it)
46 
47  void writeBuffer(Buffer &inputBuffer) throw (CException); ///< write a buffer of data into the file
48  void writeBuffer(Buffer &inB, unsigned fromFrame, unsigned toFrame)
49  throw (CException);
50 
51  juce::AudioFormatReader * mAFReader; ///< my reader
52  juce::AudioFormatWriter * mAFWriter; ///< and my writer
53  juce::File * mIOFile; ///< my JUCE file
54  juce::FileOutputStream * mOutStream;
55 
56 protected:
57  void initFromSndfile(); ///< read SF header
58 // void convertFormat(unsigned num, unsigned start);
59 
60 };
61 
62 }
63 
64 #endif
void writeBuffer(Buffer &inputBuffer)
write a buffer of data into the file
Definition: SoundFileJ.cpp:317
juce::AudioFormatReader * mAFReader
my reader
Definition: SoundFileJ.h:51
SeekPosition
Enumeration for seek flags.
Definition: CSL_Core.h:560
#define kSoundFileFormatAIFF
Definition: SoundFile.h:60
JSoundFile(string path, int start=-1, int stop=-1)
C'tors.
Definition: SoundFileJ.cpp:30
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
int SoundFileFormat
Definition: SoundFile.h:65
string path()
file name
Definition: SoundFile.h:158
unsigned duration() const
number of frames in the sound file
Definition: SoundFileJ.cpp:94
juce::File * mIOFile
my JUCE file
Definition: SoundFileJ.h:53
void readBufferFromFile(unsigned numFrames)
read a buffer from the file (possibly all of it)
Definition: SoundFileJ.cpp:226
void openForRead(bool load=true)
Definition: SoundFileJ.cpp:134
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.
Definition: SoundFileJ.cpp:193
JUCE sound file.
Definition: SoundFileJ.h:19
void initFromSndfile()
read SF header
Definition: SoundFileJ.cpp:109
juce::AudioFormatWriter * mAFWriter
and my writer
Definition: SoundFileJ.h:52
void close()
close file seek to some position
Definition: SoundFileJ.cpp:218
juce::FileOutputStream * mOutStream
Definition: SoundFileJ.h:54
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
SoundFileFormat format()
get format open file and get stats
Definition: SoundFileJ.cpp:98
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
static JSoundFile * openSndfile(string path, int start=-1, int stop=-1, bool doRead=true)
Factory methods.
Definition: SoundFileJ.cpp:17
void openForReadWrite()
open r/w
Base class of CSL exceptions (written upper-case). Has a string message.
unsigned seekTo(int position, SeekPosition whence)
sampleBufferPtr = mWavetable.buffer(channelIndex) + start;
Definition: SoundFileJ.cpp:289