ofSoundBuffer
addTo( ... )
void addTo(ofSoundBuffer &outBuffer, size_t fromFrame, bool loop=false)as addTo above but reads outNumFrames and outNumChannels from outBuffer
addTo( ... )
void addTo(ofSoundBuffer &outBuffer, size_t outNumFrames, size_t outNumChannels, size_t fromFrame, bool loop=false)as copyTo but mixes source audio with audio in outBuffer by adding samples together (+), instead of overwriting.
addTo( ... )
void addTo(float *outBuffer, size_t outNumFrames, size_t outNumChannels, size_t fromFrame, bool loop=false)as copyTo but mixes source audio with audio in out by adding samples together (+), instead of overwriting
allocate( ... )
void allocate(size_t numSamples, size_t numChannels)append( ... )
void append(ofSoundBuffer &other)checkSizeAndChannelsConsistency( ... )
bool checkSizeAndChannelsConsistency(const string &function)clear( )
void clear()remove all samples, preserving channel count and sample rate.
copyFrom( ... )
void copyFrom(const float *floatBuffer, size_t numFrames, size_t numChannels, unsigned int sampleRate)copyFrom( ... )
void copyFrom(const short *shortBuffer, size_t numFrames, size_t numChannels, unsigned int sampleRate)copy length samples from shortBuffer and interpret as interleaved with the given number of channels at the given samplerate
copyTo( ... )
void copyTo(ofSoundBuffer &outBuffer, size_t frameFrame, bool loop=false)as copyTo above but reads outNumFrames and outNumChannels from outBuffer
copyTo( ... )
void copyTo(ofSoundBuffer &outBuffer, size_t outNumFrames, size_t outNumChannels, size_t fromFrame, bool loop=false)resize outBuffer to outNumFrames with outNumChannels, and then copy outNumFrames of data from us to outBuffer. fromFrame is a frame offset. if we don't have enough source data, loop with fromFrame=0 until we have filled outBuffer. if outBuffer has fewer channels than our buffer, just copy the first outNumChannels of our data and skip the rest. if outBuffer has more channels than our buffer, loop through our channels repeatedly until done.
copyTo( ... )
void copyTo(float *outBuffer, size_t outNumFrames, size_t outNumChannels, size_t fromFrame, bool loop=false)copy sample data to out, where out is already allocated to match outNumFrames and outNumChannels (ie outNumFrames*outNumChannels samples). fromFrame is a frame offset. if we don't have enough source data, loop with fromFrame=0 until we have filled the out buffer. if out has fewer channels than our buffer, just copy the first outNumChannels of our data and skip the rest. if out has more channels than our buffer, loop through our channels repeatedly until done.
fillWithNoise( ... )
void fillWithNoise(float amplitude=1.0f)fills the buffer with random noise between -amplitude and amplitude. useful for debugging.
fillWithTone( ... )
float fillWithTone(float pitchHz=440.0f, float phase=0.0f)fills the buffer with a sine wave. useful for debugging.
getChannel( ... )
void getChannel(ofSoundBuffer &outBuffer, size_t sourceChannel)copy the requested channel of our data to outBuffer. resize outBuffer to fit.
getDeviceID( )
int getDeviceID()return the ID of the device which generated this buffer
getDurationMS( )
uint64_t getDurationMS()return the duration of audio in this buffer in milliseconds (==(getNumFrames()/getSampleRate())*1000)
getDurationMicros( )
uint64_t getDurationMicros()getDurationNanos( )
uint64_t getDurationNanos()getNumChannels( )
size_t getNumChannels()the number of channels per frame
getNumFrames( )
size_t getNumFrames()the number of frames, ie the number of sets of (getNumChannels()) samples
getRMSAmplitude( )
float getRMSAmplitude()getRMSAmplitudeChannel( ... )
float getRMSAmplitudeChannel(size_t channel)getSample( ... )
float & getSample(size_t frameIndex, size_t channel)access the sample at frameIndex on a soecific channel
getSample( ... )
const float & getSample(size_t frameIndex, size_t channel)getSampleRate( )
unsigned int getSampleRate()sample rate of the audio in this buffer
getTickCount( )
uint64_t getTickCount()return the tickCount that was assigned by ofSoundStream (if this buffer originated from an ofSoundStream).
hermiteResampleTo( ... )
void hermiteResampleTo(ofSoundBuffer &buffer, size_t fromFrame, size_t numFrames, float speed, bool loop)linearResampleTo( ... )
void linearResampleTo(ofSoundBuffer &buffer, size_t fromFrame, size_t numFrames, float speed, bool loop)normalize( ... )
void normalize(float level)amplifies samples so that the maximum amplitude is equal to 'level'
ofSoundBuffer( )
ofSoundBuffer()ofSoundBuffer( ... )
ofSoundBuffer(short *shortBuffer, size_t numFrames, size_t numChannels, unsigned int sampleRate)operator*( ... )
ofSoundBuffer operator*(float value)return a new buffer containing the contents of this buffer multiplied by value.
operator*=( ... )
ofSoundBuffer & operator*=(float value)multiply everything in this buffer by value, in-place.
operator[]( ... )
float & operator[](size_t samplePos)access the sample at the given position in the buffer. to retrieve the sample for channel channelIndex of frame frameIndex, do the following: ofSoundBuffer myBuffer; ... float sample = myBuffer[(frameIndex*myBuffer.getNumChannels()) + channelIndex];
operator[]( ... )
const float & operator[](size_t samplePos)resample( ... )
void resample(float speed, ofSoundBuffer::InterpolationAlgorithm algorithm)resample by changing the playback speed, keeping the same sampleRate
resampleTo( ... )
void resampleTo(ofSoundBuffer &outBuffer, size_t fromFrame, size_t numFrames, float speed, bool loop=false, ofSoundBuffer::InterpolationAlgorithm algorithm)resample our data to outBuffer at the given target speed, starting at fromFrame and copying numFrames of data. resize outBuffer to fit. speed is relative to current speed (ie 1.0f == no change). lower speeds will give a larger outBuffer, higher speeds a smaller outBuffer.
resize( ... )
void resize(size_t numSamples, float val)resize this buffer to exactly this many samples. it's up to you make sure samples matches the channel count.
set( ... )
void set(float value)set everything in this buffer to value, preserving size, channel count and sample rate.
setChannel( ... )
void setChannel(const ofSoundBuffer &inBuffer, size_t channel)copy data from inBuffer to the given channel. resize ourselves to match inBuffer's getNumFrames().
setDeviceID( ... )
void setDeviceID(int id)setNumChannels( ... )
void setNumChannels(int channels)set the number of channels. does not change the underlying data, ie causes getNumFrames() to return a different result.
setSampleRate( ... )
void setSampleRate(unsigned int rate)setTickCount( ... )
void setTickCount(uint64_t tick)size( )
size_t size()return the total number of samples in this buffer (==getNumFrames()*getNumChannels())
stereoPan( ... )
void stereoPan(float left, float right)assuming a 2-channel buffer, apply a stereo pan by multiplying channel 0 by left and channel 1 by right.
swap( ... )
void swap(ofSoundBuffer &otherBuffer)swap the contents of this buffer with otherBuffer
toShortPCM( ... )
void toShortPCM(short *dst)trimSilence( ... )
bool trimSilence(float threshold=0.0001f, bool trimStart=true, bool trimEnd=true)removes initial / ending silence from the buffer