This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
ofSoundBuffer.h
Go to the documentation of this file.
87 ofSoundBuffer(short * shortBuffer, std::size_t numFrames, std::size_t numChannels, unsigned int sampleRate);
93 static InterpolationAlgorithm defaultAlgorithm; //defaults to Linear for mobile, Hermite for desktop
143 void copyFrom(const short * shortBuffer, std::size_t numFrames, std::size_t numChannels, unsigned int sampleRate);
145 void copyFrom(const float * floatBuffer, std::size_t numFrames, std::size_t numChannels, unsigned int sampleRate);
147 void copyFrom(const std::vector<short> & shortBuffer, std::size_t numChannels, unsigned int sampleRate);
149 void copyFrom(const std::vector<float> & floatBuffer, std::size_t numChannels, unsigned int sampleRate);
158 void copyTo(ofSoundBuffer & outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop = false) const;
160 void addTo(ofSoundBuffer & outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop = false) const;
173 void copyTo(float * outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop = false) const;
175 void addTo(float * outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop = false) const;
179 void resampleTo(ofSoundBuffer & outBuffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop = false, InterpolationAlgorithm algorithm = defaultAlgorithm) const;
189 void linearResampleTo(ofSoundBuffer & buffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop) const;
190 void hermiteResampleTo(ofSoundBuffer & buffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop) const;
void resampleTo(ofSoundBuffer &outBuffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop=false, InterpolationAlgorithm algorithm=defaultAlgorithm) const
Definition ofSoundBuffer.cpp:481
void hermiteResampleTo(ofSoundBuffer &buffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop) const
Definition ofSoundBuffer.cpp:397
void getChannel(ofSoundBuffer &outBuffer, std::size_t sourceChannel) const
copy the requested channel of our data to outBuffer. resize outBuffer to fit.
Definition ofSoundBuffer.cpp:498
void fillWithNoise(float amplitude=1.0f)
fills the buffer with random noise between -amplitude and amplitude. useful for debugging.
Definition ofSoundBuffer.cpp:602
bool trimSilence(float threshold=0.0001f, bool trimStart=true, bool trimEnd=true)
removes initial / ending silence from the buffer
Definition ofSoundBuffer.cpp:568
static InterpolationAlgorithm defaultAlgorithm
Definition ofSoundBuffer.h:93
std::size_t getNumFrames() const
the number of frames, ie the number of sets of (getNumChannels()) samples
Definition ofSoundBuffer.h:107
int getDeviceID() const
return the ID of the device which generated this buffer
Definition ofSoundBuffer.h:119
void setNumChannels(int channels)
set the number of channels. does not change the underlying data, ie causes getNumFrames() to return a...
Definition ofSoundBuffer.cpp:98
void toShortPCM(std::vector< short > &dst) const
unsigned int getSampleRate() const
sample rate of the audio in this buffer
Definition ofSoundBuffer.h:98
void linearResampleTo(ofSoundBuffer &buffer, std::size_t fromFrame, std::size_t numFrames, float speed, bool loop) const
Definition ofSoundBuffer.cpp:333
std::size_t size() const
return the total number of samples in this buffer (==getNumFrames()*getNumChannels())
Definition ofSoundBuffer.h:205
void allocate(size_t numSamples, size_t numChannels)
Definition ofSoundBuffer.cpp:107
uint64_t getTickCount() const
return the tickCount that was assigned by ofSoundStream (if this buffer originated from an ofSoundStr...
Definition ofSoundBuffer.h:110
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 rig...
Definition ofSoundBuffer.cpp:176
void copyFrom(const short *shortBuffer, std::size_t numFrames, std::size_t numChannels, unsigned int sampleRate)
copy length samples from shortBuffer and interpret as interleaved with the given number of channels a...
Definition ofSoundBuffer.cpp:40
void setChannel(const ofSoundBuffer &inBuffer, std::size_t channel)
copy data from inBuffer to the given channel. resize ourselves to match inBuffer's getNumFrames().
Definition ofSoundBuffer.cpp:522
std::vector< float > & getBuffer()
return the underlying buffer. careful!
Definition ofSoundBuffer.cpp:78
bool checkSizeAndChannelsConsistency(const std::string &function="")
Definition ofSoundBuffer.cpp:126
void copyTo(ofSoundBuffer &outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop=false) const
Definition ofSoundBuffer.cpp:188
float & getSample(std::size_t frameIndex, std::size_t channel)
access the sample at frameIndex on a soecific channel
Definition ofSoundBuffer.cpp:147
uint64_t getDurationMS() const
return the duration of audio in this buffer in milliseconds (==(getNumFrames()/getSampleRate())*1000)
Definition ofSoundBuffer.cpp:86
void resize(std::size_t numSamples, float val=float())
resize this buffer to exactly this many samples. it's up to you make sure samples matches the channel...
Definition ofSoundBuffer.cpp:112
void copyFrom(const std::vector< short > &shortBuffer, std::size_t numChannels, unsigned int sampleRate)
float fillWithTone(float pitchHz=440.0f, float phase=0.0f)
fills the buffer with a sine wave. useful for debugging.
Definition ofSoundBuffer.cpp:608
std::size_t getNumChannels() const
the number of channels per frame
Definition ofSoundBuffer.h:103
float getRMSAmplitudeChannel(std::size_t channel) const
Definition ofSoundBuffer.cpp:544
void normalize(float level=1)
amplifies samples so that the maximum amplitude is equal to 'level'
Definition ofSoundBuffer.cpp:557
void clear()
remove all samples, preserving channel count and sample rate.
Definition ofSoundBuffer.cpp:117
void copyFrom(const std::vector< float > &floatBuffer, std::size_t numChannels, unsigned int sampleRate)
ofSoundBuffer & operator*=(float value)
multiply everything in this buffer by value, in-place.
Definition ofSoundBuffer.cpp:169
void resample(float speed, InterpolationAlgorithm algorithm=defaultAlgorithm)
resample by changing the playback speed, keeping the same sampleRate
Definition ofSoundBuffer.cpp:492
void addTo(ofSoundBuffer &outBuffer, std::size_t outNumFrames, std::size_t outNumChannels, std::size_t fromFrame, bool loop=false) const
as copyTo but mixes source audio with audio in outBuffer by adding samples together (+),...
Definition ofSoundBuffer.cpp:203
ofSoundBuffer operator*(float value)
return a new buffer containing the contents of this buffer multiplied by value.
Definition ofSoundBuffer.cpp:163
Definition ofPixels.h:1522
#define swap(a, i, j)