Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Load wav file into ofSoundBuffer

$
0
0

There is a copyFrom() method which takes a raw float * and asks you to set the channel count & sample rate metadata:

void copyFrom(const float * floatBuffer, std::size_t numFrames, std::size_t numChannels, unsigned int sampleRate)

..Or you could access the underlying buffer if you'd like to use std::vector methods like assign() or begin() / end()

std::vector<float>& getBuffer()

If you get the raw buffer like this, you should set the sample rate and channel count later, or things like resampling or playback won't work correctly.

For reading the buffer, you can use operator[] to access the underlying std::vector<float> directly, or use getSample() to handle the (frameIndex * channels) + channel calculation for you.

ofSoundBuffer doesn't include any file I/O at the moment


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>