CSL  5.2
csl::Buffer Class Reference

Buffer – the multi-channel sample buffer class (passed around between generators and IO guys). More...

#include <CSL_Core.h>

+ Inheritance diagram for csl::Buffer:

List of all members.

Public Member Functions

 Buffer (unsigned numChannels=1, unsigned numFrames=CSL_mBlockSize)
 Constructors: default is mono and default-size.
virtual ~Buffer ()
 Destructor.
void setSize (unsigned numChannels, unsigned numFrames)
void setSizeOnly (unsigned numChannels, unsigned numFrames)
 this version doesn't even allocate the pointers
void checkBuffers () throw (MemoryError)
 allocate if not already there
void allocateBuffers () throw (MemoryError)
 fcn to malloc storage buffers
void freeBuffers ()
 fcn to free them
bool canStore (unsigned numFrames)
 answer whether the recevei can store numFrames more frames
void zeroBuffers ()
 fill all data with 0
void fillWith (sample value)
 fill data with the given value
void copyFrom (Buffer &src) throw (RunTimeError)
void copyHeaderFrom (Buffer &source) throw (RunTimeError)
 copy the "header" fields of a buffer
void copySamplesFrom (Buffer &src) throw (RunTimeError)
 import data from the given buffer
void copySamplesFromTo (Buffer &src, unsigned offset) throw (RunTimeError)
 same with write offset
void copyOnlySamplesFrom (Buffer &src) throw (RunTimeError)
 import data from the given buffer
csl::Status convertRate (int fromRate, int toRate)
 convert the sample rate using libSampleRate
virtual SampleBuffer samplePtrFor (unsigned channel, unsigned offset)
 answer a samp ptr with offset
virtual SampleBuffer samplePtrFor (unsigned channel, unsigned offset, unsigned maxFrame)
 answer a samp ptr tested for extent (offset + maxFrame)
virtual SampleBuffer monoBuffer (unsigned bufNum)
 convenience accessors for sample buffers
virtual SampleBuffer buffer (unsigned bufNum)
virtual SampleBufferbuffers ()
virtual void setBuffers (SampleBuffer *sPtr)
 Set the buffer pointer (rare; used in joiners)
virtual void setBuffer (unsigned bufNum, SampleBuffer sPtr)
virtual void setBuffer (unsigned bufNum, unsigned offset, sample samp)

Public Attributes

unsigned mNumChannels
 num channels in buffer (num mono buffers)
unsigned mNumFrames
 num frames used in each buffer
unsigned mNumAlloc
 num frames in each buffer
unsigned mMonoBufferByteSize
 size of each buffer in bytes
unsigned mSequence
 sequential serial number
Timestamp mTimestamp
 the buffer's most recent timestamp
bool mAreBuffersAllocated
 are the buffers allocated?
bool mDidIAllocateBuffers
 who allocated my data buffers?
bool mIsPopulated
 does the buffer have data?
bool mAreBuffersZero
 have the buffers been zeroed out?
BufferContentType mType
 Data type flag set the internal size variables (no buffer allocation takes place)

Protected Attributes

SampleBufferVector mBuffers
 Buffer Sample Processing (optional) One could also easily add Buffer operators, such as (Buffer + Buffer) or (Buffer * Buffer)

Detailed Description

Buffer – the multi-channel sample buffer class (passed around between generators and IO guys).

Buffers have an opaque pointer () to their data () and know their # channels and frames. They have Boolean aspects about their buffer allocation, and can allocate, free, zero, and check their data.

Note that this is a "record" class in that its members are all public and it has no accessor functions or complicated methods. It does handle sample buffer allocation and has Boolean members to determine what its pointer state is. Note also that Buffers are not thread-safe; they hand out pointers (sample*) that are assumed to be volatile.

Definition at line 88 of file CSL_Core.h.


Constructor & Destructor Documentation

Buffer::Buffer ( unsigned  numChannels = 1,
unsigned  numFrames = CSL_mBlockSize 
)

Constructors: default is mono and default-size.

Definition at line 29 of file CSL_Core.cpp.

References setSize().

Buffer::~Buffer ( )
virtual

Destructor.

Definition at line 46 of file CSL_Core.cpp.

References freeBuffers(), and mDidIAllocateBuffers.


Member Function Documentation

void Buffer::setSizeOnly ( unsigned  numChannels,
unsigned  numFrames 
)

this version doesn't even allocate the pointers

Definition at line 78 of file CSL_Core.cpp.

References mMonoBufferByteSize, mNumChannels, and mNumFrames.

Referenced by csl::CslRtpSession::OnRTPPacket().

void Buffer::checkBuffers ( ) throw (MemoryError)

allocate if not already there

Definition at line 86 of file CSL_Core.cpp.

References allocateBuffers(), and mAreBuffersAllocated.

Referenced by csl::VSTIO::processReplacing().

bool Buffer::canStore ( unsigned  numFrames)

answer whether the recevei can store numFrames more frames

Definition at line 166 of file CSL_Core.cpp.

References mNumAlloc, and mNumFrames.

void Buffer::fillWith ( sample  value)

fill data with the given value

Definition at line 172 of file CSL_Core.cpp.

References mAreBuffersZero, mBuffers, mNumChannels, and mNumFrames.

void Buffer::copyFrom ( Buffer src) throw (RunTimeError)

Definition at line 202 of file CSL_Core.cpp.

Referenced by csl::Abst_SoundFile::mergeToMono(), and csl::MP3File::openForRead().

void Buffer::copyHeaderFrom ( Buffer source) throw (RunTimeError)

copy the "header" fields of a buffer

Definition at line 187 of file CSL_Core.cpp.

References csl::logMsg().

void Buffer::copySamplesFrom ( Buffer src) throw (RunTimeError)

import data from the given buffer

Definition at line 222 of file CSL_Core.cpp.

References csl_min, csl::kLogError, csl::logMsg(), and memcpy().

Referenced by csl::DecodedFile::mergeBuffers().

void Buffer::copySamplesFromTo ( Buffer src,
unsigned  offset 
) throw (RunTimeError)

same with write offset

Definition at line 252 of file CSL_Core.cpp.

References csl_min, csl::kLogError, csl::logMsg(), and memcpy().

Referenced by csl::DecodedFile::mergeBuffers().

void Buffer::copyOnlySamplesFrom ( Buffer src) throw (RunTimeError)

import data from the given buffer

same with write offset

Definition at line 238 of file CSL_Core.cpp.

References csl_min, csl::kLogError, csl::logMsg(), and memcpy().

Referenced by csl::FanOut::nextBuffer().

csl::Status csl::Buffer::convertRate ( int  fromRate,
int  toRate 
)

convert the sample rate using libSampleRate

Referenced by csl::Abst_SoundFile::convertRate().

sample * Buffer::samplePtrFor ( unsigned  channel,
unsigned  offset 
)
virtual

answer a samp ptr with offset

answer a samp ptr tested for extent (offset + maxFrame)

Definition at line 152 of file CSL_Core.cpp.

References mBuffers.

sample * Buffer::samplePtrFor ( unsigned  channel,
unsigned  offset,
unsigned  maxFrame 
)
virtual

answer a samp ptr tested for extent (offset + maxFrame)

answer whether the receiver can store numFrames more frames

Definition at line 158 of file CSL_Core.cpp.

References mBuffers, and mNumAlloc.

virtual SampleBuffer* csl::Buffer::buffers ( )
inlinevirtual

Definition at line 135 of file CSL_Core.h.

References mBuffers.

Referenced by csl::WavetableOscillator::setWaveform().

virtual void csl::Buffer::setBuffers ( SampleBuffer sPtr)
inlinevirtual

Set the buffer pointer (rare; used in joiners)

Definition at line 137 of file CSL_Core.h.

References mBuffers.

Referenced by csl::WavetableOscillator::setWaveform().

virtual void csl::Buffer::setBuffer ( unsigned  bufNum,
unsigned  offset,
sample  samp 
)
inlinevirtual

Definition at line 139 of file CSL_Core.h.

References mBuffers.


Member Data Documentation

unsigned csl::Buffer::mNumAlloc
unsigned csl::Buffer::mMonoBufferByteSize

size of each buffer in bytes

Definition at line 97 of file CSL_Core.h.

Referenced by setSize(), setSizeOnly(), csl::WavetableOscillator::setWaveform(), csl::UnitGenerator::zeroBuffer(), and zeroBuffers().

unsigned csl::Buffer::mSequence

sequential serial number

Definition at line 98 of file CSL_Core.h.

Timestamp csl::Buffer::mTimestamp

the buffer's most recent timestamp

Definition at line 99 of file CSL_Core.h.

bool csl::Buffer::mDidIAllocateBuffers
bool csl::Buffer::mAreBuffersZero

have the buffers been zeroed out?

Definition at line 104 of file CSL_Core.h.

Referenced by fillWith(), csl::WavetableOscillator::setWaveform(), and zeroBuffers().

BufferContentType csl::Buffer::mType

Data type flag set the internal size variables (no buffer allocation takes place)

Definition at line 105 of file CSL_Core.h.

Referenced by csl::BinauralPanner::BinauralPanner(), csl::AmbisonicRotator::nextBuffer(), csl::AmbisonicEncoder::nextBuffer(), csl::AmbisonicDecoder::nextBuffer(), and csl::Controllable::pullInput().

SampleBufferVector csl::Buffer::mBuffers
protected

Buffer Sample Processing (optional) One could also easily add Buffer operators, such as (Buffer + Buffer) or (Buffer * Buffer)

the storage vector – pointers to (SampleBuffer) buffers

Definition at line 139 of file CSL_Core.h.

Referenced by allocateBuffers(), buffer(), buffers(), fillWith(), freeBuffers(), csl::WaveShaper::mono_next_buffer(), monoBuffer(), csl::BufferCMap::monoBuffer(), RenderCallback(), samplePtrFor(), setBuffer(), setBuffers(), setSize(), and zeroBuffers().


The documentation for this class was generated from the following files: