Ejemplo n.º 1
0
//////////////////////////////////////////
///\brief
///Append another buffer to this one
//////////////////////////////////////////
bool Buffer::Append(BufferPtr appendBuffer){
    if(this->SampleRate()==appendBuffer->SampleRate() && this->Channels()==appendBuffer->Channels()){
        long newBufferSize      = (this->Samples()+appendBuffer->Samples())*this->channels;

        if(newBufferSize>this->internalBufferSize){
            // Internal buffer too small. We need to make a new buffer
            // Create a new buffer
            float *newBuffer    = new float[newBufferSize];

            CopyFloat(newBuffer,this->buffer,this->sampleSize*this->channels);

            float *dst  = &newBuffer[this->sampleSize*this->channels];
            float *src  = appendBuffer->BufferPointer();
            long si     = appendBuffer->Samples()*this->channels;
            CopyFloat(dst,src,si);

            if(this->buffer){
                // Delete old buffer
                delete this->buffer;
            }
            // Set the new buffer
            this->buffer                = newBuffer;
            this->internalBufferSize    = newBufferSize;
        }else{
            // append the appendBuffer
            float *dst  = &this->buffer[this->sampleSize*this->channels];
            float *src  = appendBuffer->BufferPointer();
            long si     = appendBuffer->Samples()*this->channels;
//            CopyFloat( this->buffer + this->sampleSize*this->channels*sizeof(float),appendBuffer->BufferPointer(),appendBuffer->Samples()*this->channels);
            CopyFloat( dst,src,si);
        }

        this->sampleSize    = newBufferSize/this->channels;
        return true;

    }
    return false;
}
Ejemplo n.º 2
0
//////////////////////////////////////////
///\brief
///Copies all the formats from one buffer to another
//////////////////////////////////////////
void Buffer::CopyFormat(BufferPtr fromBuffer){
    this->sampleSize    = fromBuffer->Samples();
    this->channels      = fromBuffer->Channels();
    this->sampleRate    = fromBuffer->SampleRate();
    this->ResizeBuffer();
}