Logo Search packages:      
Sourcecode: libgdf version File versions  Download package

void gdf::Writer::blitFromSerialBufferPhys ( const double *  buf,
const std::vector< size_t > &  samples_per_channel 
)

Blit data from a serial buffer.

Instead of streaming samples as they come, the complete data is provided in an array of type double. In the buffer channels have to be arranged sequentially. I.e. all samples from channel 1 are followed by all samles from channel 2, and so on. This function attempts to keep memory overhead low by filling record by record whenever possible.

Parameters:
[in]bufBuffer
[in]samples_per_channelA vector containing the number of samples in each channel.

Definition at line 218 of file Writer.cpp.

References gdf::RecordBuffer::blitSamplesPhys(), and gdf::RecordBuffer::getNumFreeAlloc().

    {
        if( !m_file.is_open() )
            throw exception::file_not_open( "" );

        size_t M = samples_per_channel.size( );
        std::vector<size_t> samples_remaining = samples_per_channel;
        size_t total_samples_remaining = sum( samples_remaining );

        std::vector<size_t> readpos;
        readpos.resize( M );
        readpos[0] = 0;
        for( size_t i=1; i<M; i++ )
            readpos[i] = readpos[i-1] + samples_per_channel[i-1];

        while( total_samples_remaining > 0 )
        {
            for( size_t i=0; i<M; i++ )
            {
                size_t n = std::min( samples_remaining[i], m_recbuf.getNumFreeAlloc( i ) );
                m_recbuf.blitSamplesPhys( i, &buf[readpos[i]], n );
                total_samples_remaining -= n;
                samples_remaining[i] -= n;
                readpos[i] += n;
            }
        }
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index