|
CSL
5.2
|
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys). More...
#include <CSL_Core.h>
Inheritance diagram for csl::Buffer: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 SampleBuffer * | buffers () |
| 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) | |
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.
| 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().
|
virtual |
Destructor.
Definition at line 46 of file CSL_Core.cpp.
References freeBuffers(), and mDidIAllocateBuffers.
| void Buffer::setSize | ( | unsigned | numChannels, |
| unsigned | numFrames | ||
| ) |
Definition at line 54 of file CSL_Core.cpp.
References freeBuffers(), mAreBuffersAllocated, mBuffers, mDidIAllocateBuffers, mIsPopulated, mMonoBufferByteSize, mNumAlloc, mNumChannels, and mNumFrames.
Referenced by csl::Mixer::allocateOpBuffer(), csl::BlockResizer::BlockResizer(), Buffer(), csl::Abst_SoundFile::checkBuffer(), csl::Port::checkBuffer(), csl::DelayLine::DelayLine(), csl::WavetableOscillator::fillSine(), csl::KarplusString::initDelayLine(), csl::PAIO::initialize(), csl::WaveShaper::initWaveTable(), csl::DecodedFile::mergeBuffers(), csl::FileIO::open(), csl::VSTIO::processReplacing(), csl::Window::setSize(), csl::SpatialPanner::SpatialPanner(), and csl::WavetableOscillator::WavetableOscillator().
| 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().
| void Buffer::allocateBuffers | ( | ) | throw (MemoryError) |
fcn to malloc storage buffers
Definition at line 95 of file CSL_Core.cpp.
References csl::logMsg(), mAreBuffersAllocated, mBuffers, mDidIAllocateBuffers, mNumAlloc, mNumChannels, mNumFrames, and SAFE_MALLOC.
Referenced by csl::DecodedFile::addBuffer(), csl::UnitGenerator::addOutput(), csl::Mixer::allocateOpBuffer(), csl::BinauralPanner::BinauralPanner(), csl::BlockResizer::BlockResizer(), csl::Abst_SoundFile::checkBuffer(), csl::Port::checkBuffer(), checkBuffers(), csl::CompOrCacheOscillator::createCache(), csl::MP3File::decodeMP3(), csl::FFT::FFT(), csl::WavetableOscillator::fillSine(), csl::Filter::init(), csl::RemoteIO::init_io(), csl::KarplusString::initDelayLine(), csl::AmbisonicMixer::initialize(), csl::WaveShaper::initWaveTable(), csl::DecodedFile::mergeBuffers(), csl::Abst_SoundFile::mergeToMono(), csl::FileIO::open(), csl::PAIO::open(), csl::Port::Port(), csl::RingBuffer::RingBuffer(), csl::Window::setSize(), csl::SpatialPanner::SpatialPanner(), and csl::PAIO::test().
| void Buffer::freeBuffers | ( | ) |
fcn to free them
Definition at line 112 of file CSL_Core.cpp.
References csl::kLogError, csl::logMsg(), mAreBuffersAllocated, mBuffers, mDidIAllocateBuffers, mNumAlloc, mNumChannels, and mNumFrames.
Referenced by csl::Abst_SoundFile::checkBuffer(), csl::Port::checkBuffer(), csl::PAIO::close(), csl::FileIO::close(), csl::Abst_SoundFile::freeBuffer(), csl::DecodedFile::mergeBuffers(), csl::FileIO::open(), csl::PAIO::open(), csl::Window::setSize(), setSize(), csl::WavetableOscillator::setWaveform(), csl::BlockResizer::~BlockResizer(), ~Buffer(), csl::Mixer::~Mixer(), csl::SpatialPanner::~SpatialPanner(), csl::WavetableOscillator::~WavetableOscillator(), and csl::Window::~Window().
| 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::zeroBuffers | ( | ) |
fill all data with 0
Definition at line 142 of file CSL_Core.cpp.
References mAreBuffersAllocated, mAreBuffersZero, mBuffers, mMonoBufferByteSize, and mNumChannels.
Referenced by csl::Filter::clear(), csl::AmbisonicEncoder::nextBuffer(), csl::Controllable::pullInput(), and csl::FileIO::writeNextBuffer().
| 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().
|
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.
|
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.
|
inlinevirtual |
convenience accessors for sample buffers
Reimplemented in csl::BufferCMap.
Definition at line 133 of file CSL_Core.h.
References mBuffers.
Referenced by csl::CompOrCacheOscillator::createCache(), csl::WavetableOscillator::fillSine(), csl::WaveShaper::initWaveTable(), csl::RtpSender::nextBuffer(), csl::Splitter::nextBuffer(), csl::Port::Port(), csl::CASoundFile::readBufferFromFile(), csl::JSoundFile::readBufferFromFile(), csl::LSoundFile::readBufferFromFile(), csl::Port::resetPtr(), and csl::UnitGenerator::zeroBuffer().
|
inlinevirtual |
Definition at line 134 of file CSL_Core.h.
References mBuffers.
Referenced by csl::Abst_SoundFile::buffer(), csl::Window::fillWindow(), csl::RectangularWindow::fillWindow(), csl::TriangularWindow::fillWindow(), csl::HammingWindow::fillWindow(), csl::HannWindow::fillWindow(), csl::BlackmanWindow::fillWindow(), csl::BlackmanHarrisWindow::fillWindow(), csl::WelchWindow::fillWindow(), csl::Abst_SoundFile::mergeToMono(), csl::InOut::nextBuffer(), csl::AmbisonicRotator::nextBuffer(), csl::AmbisonicEncoder::nextBuffer(), csl::AmbisonicDecoder::nextBuffer(), csl::Port::nextFrame(), csl::IntensityAttenuationCue::process(), csl::AirAbsorptionCue::process(), csl::VSTIO::processReplacing(), csl::Effect::pullInput(), csl::CASoundFile::readBufferFromFile(), RenderCallback(), csl::WavetableOscillator::setWaveform(), csl::Window::window(), and csl::DecodedFile::writeBuffer().
|
inlinevirtual |
Definition at line 135 of file CSL_Core.h.
References mBuffers.
Referenced by csl::WavetableOscillator::setWaveform().
|
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().
|
inlinevirtual |
Definition at line 138 of file CSL_Core.h.
References mBuffers.
Referenced by csl::JUCEIO::audioDeviceIOCallback(), csl::WavetableOscillator::fillSine(), csl::HRTF::HRTF(), csl::Abst_SoundFile::mergeToMono(), csl::Joiner::nextBuffer(), csl::VSTIO::processReplacing(), csl::WavetableOscillator::setWaveform(), testWaveTableFromFile(), and testWavetableInterpolation().
|
inlinevirtual |
Definition at line 139 of file CSL_Core.h.
References mBuffers.
| unsigned csl::Buffer::mNumChannels |
num channels in buffer (num mono buffers)
Definition at line 94 of file CSL_Core.h.
Referenced by allocateBuffers(), csl::Port::checkBuffer(), fillWith(), freeBuffers(), csl::AUIO::getInput(), csl::IO::getInput(), JackCallback(), csl::DecodedFile::mergeBuffers(), csl::Port::nextFrame(), RenderCallback(), setSize(), setSizeOnly(), csl::WavetableOscillator::setWaveform(), and zeroBuffers().
| unsigned csl::Buffer::mNumFrames |
num frames used in each buffer
Definition at line 95 of file CSL_Core.h.
Referenced by csl::DecodedFile::addBuffer(), allocateBuffers(), csl::JUCEIO::audioDeviceIOCallback(), canStore(), csl::Abst_SoundFile::checkBuffer(), csl::Port::checkBuffer(), csl::DecodedFile::checkBufferStack(), csl::Abst_SoundFile::convertRate(), csl::CompOrCacheOscillator::createCache(), csl::MP3File::decodeMP3(), csl::RingBufferTap::duration(), csl::BufferStream::duration(), fillWith(), freeBuffers(), csl::AUIO::getInput(), csl::IO::getInput(), csl::LSoundFile::isCached(), csl::Abst_SoundFile::isCached(), JackCallback(), csl::DecodedFile::mergeBuffers(), csl::Abst_SoundFile::mergeToMono(), csl::WaveShaper::mono_next_buffer(), csl::AmbisonicRotator::nextBuffer(), csl::AmbisonicEncoder::nextBuffer(), csl::AmbisonicDecoder::nextBuffer(), pa_callback(), csl::IntensityAttenuationCue::process(), csl::AirAbsorptionCue::process(), csl::Controllable::pullInput(), RenderCallback(), csl::RingBufferTap::setOffset(), setSize(), setSizeOnly(), csl::WavetableOscillator::setWaveform(), csl::WavetableOscillator::WavetableOscillator(), csl::DecodedFile::writeBuffer(), and csl::FileIO::writeNextBuffer().
| unsigned csl::Buffer::mNumAlloc |
num frames in each buffer
Definition at line 96 of file CSL_Core.h.
Referenced by allocateBuffers(), csl::Abst_SoundFile::cacheSize(), canStore(), csl::DecodedFile::checkBufferStack(), freeBuffers(), samplePtrFor(), and setSize().
| 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::mAreBuffersAllocated |
are the buffers allocated?
Definition at line 101 of file CSL_Core.h.
Referenced by allocateBuffers(), csl::Abst_SoundFile::checkBuffer(), checkBuffers(), csl::PAIO::close(), csl::FileIO::close(), csl::WavetableOscillator::fillSine(), csl::Abst_SoundFile::freeBuffer(), freeBuffers(), csl::Abst_SoundFile::mergeToMono(), csl::FileIO::open(), csl::PAIO::open(), RenderCallback(), setSize(), csl::WavetableOscillator::setWaveform(), testWavetableInterpolation(), and zeroBuffers().
| bool csl::Buffer::mDidIAllocateBuffers |
who allocated my data buffers?
Definition at line 102 of file CSL_Core.h.
Referenced by allocateBuffers(), csl::WavetableOscillator::fillSine(), freeBuffers(), csl::Abst_SoundFile::mergeToMono(), RenderCallback(), setSize(), csl::WavetableOscillator::setWaveform(), and ~Buffer().
| bool csl::Buffer::mIsPopulated |
does the buffer have data?
Definition at line 103 of file CSL_Core.h.
Referenced by csl::AmbisonicRotator::nextBuffer(), csl::AmbisonicEncoder::nextBuffer(), csl::AmbisonicDecoder::nextBuffer(), csl::Controllable::pullInput(), RenderCallback(), setSize(), and csl::WavetableOscillator::setWaveform().
| 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().
|
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().