10 #ifndef CSL_SoundFileL_H
11 #define CSL_SoundFileL_H
30 #define MP3_TEMP_NAME(in_path, out_path, temp_dir) { \
31 sprintf(out_path, "%s%s", temp_dir, in_path); \
32 char * lastDot = strrchr(out_path, (int) '.'); \
33 if (lastDot) sprintf(lastDot, MP3_TEMP_EXT); \
34 char * pos = out_path; \
35 pos += strlen(temp_dir); \
36 pos = strchr(pos, (int) '/'); \
39 pos = strchr(pos, (int) '/'); \
45 #define AIFF_TEMP_NAME(in_path, out_path) { \
46 strcpy(out_path, in_path); \
47 if (strcasestr(in_path, ".mp3")) \
48 strcpy((out_path + strlen(out_path) - 4), ".aiff"); }
68 LSoundFile(std::string
path,
int start = -1,
int stop = -1,
bool doRead =
true,
float maxDurInSecs = 0.0);
69 LSoundFile(
float maxDurInSecs, std::string path);
84 unsigned rate = 44100,
SeekPosition
Enumeration for seek flags.
#define kSoundFileFormatAIFF
SF_INFO * mSFInfo
libsndfile sf-info struct
float mMaxDurInSecs
max size to read from file. In seconds so it can deal with varying sample rates.
void readBufferFromFile(unsigned numFrames)
read a buffer from the file (possibly all of it)
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Interleaver handles copying interleaved sample buffers (like sound files and inter-process sockets) t...
bool isCached()
answer if file has all of its samples in RAM
void nextBuffer(Buffer &outB)
UGen operations.
SoundFileFormat format()
get format
void openForWrite(SoundFileFormat format=kSoundFileFormatAIFF, unsigned channels=1, unsigned rate=44100, unsigned bitDepth=16)
Open a file for writing. Default values are some common format.
virtual void openForRead(bool load=true)
open file and get stats Open a file for write. Default values are some common format.
void close()
close file seek to some position
void writeBuffer(Buffer &inputBuffer)
write a buffer of data into the file
static LSoundFile * openSndfile(string path, int start=-1, int stop=-1, bool doRead=true)
Factory methods.
SNDFILE * sndFile()
libsndfile handle
Interleaver mInterleaver
File IO interleaver/deinterleaver.
void openForReadWrite()
open r/w
void initFromSndfile()
read SF header
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
LSoundFile(std::string path, int start=-1, int stop=-1, bool doRead=true, float maxDurInSecs=0.0)
Constructor with defaults.
unsigned seekTo(int position, SeekPosition whence=kPositionStart)
seek to some position relative to "whence"
Here's the abstract sound file reader/writer class, a sample player UGen. The concrete subclasses rep...
Here's the sound file reader/writer class; it assumes libSndFile and interleaved sample buffers...
SF_INFO * sfInfo()
libsndfile sf-info struct
SNDFILE * mSndfile
libsndfile handle
unsigned channels() const
accessors
Base class of CSL exceptions (written upper-case). Has a string message.