37 Interleaver(
int rate,
const std::vector<AudioStream *> &streams,
bool disposeAfterUse);
58 bool disposeAfterUse) :
59 _rate(rate), _channels(0), _disposeAfterUse(disposeAfterUse) {
62 for (std::vector<AudioStream *>::const_iterator s = streams.begin();
63 s != streams.end(); ++s) {
74 for (std::vector<AudioStream *>::iterator s =
_streams.begin(); s !=
_streams.end(); ++s)
79 size_t maxSamples = numSamples;
82 for (; samples < maxSamples; ) {
87 for (std::vector<AudioStream *>::iterator s =
_streams.begin();
90 const size_t channels = (*s)->getChannels();
91 const size_t nRead = (*s)->readBuffer(buffer, channels);
95 if (nRead != channels)
96 std::memset(buffer, 0, 2 * channels);
99 samples += (*s)->getChannels();
117 for (std::vector<AudioStream *>::const_iterator s =
_streams.begin();
119 if ((*s)->endOfData())
128 for (std::vector<AudioStream *>::const_iterator s =
_streams.begin();
130 if (!(*s)->endOfStream())
138 bool disposeAfterUse) {
143 return new Interleaver(rate, streams, disposeAfterUse);
Exception that provides a stack of explanations.
AudioStream * makeInterleaver(int rate, const std::vector< AudioStream *> &streams, bool disposeAfterUse)
Takes several input audio streams and interleaves the sample data to create an audio stream with x ch...
Basic exceptions to throw.
static const size_t kSizeInvalid
An audio stream interleaving several other audio streams.
bool endOfStream() const
End of stream reached? If this returns true, it means that all data in this stream is used up and no ...
int getChannels() const
Return the number channels in this stream.
Generic audio input stream.
std::vector< AudioStream * > _streams
Interleaver(int rate, const std::vector< AudioStream *> &streams, bool disposeAfterUse)
bool endOfData() const
End of data reached? If this returns true, it means that at this time there is no data available in t...
int getRate() const
Sample rate of the stream.
size_t readBuffer(int16 *buffer, const size_t numSamples)
Fill the given buffer with up to numSamples samples.