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

void gdf::Reader::getSignal ( uint16  channel_idx,
double *  buffer,
size_t  start = 0,
size_t  end = 0 
)

Read a single channel from file into buffer.

The buffer must be allocated by the user, who is also responsible that enough memory is allocated.

Parameters:
[in]channel_idxindex of channel to read
[out]bufferpointer to double array
[in]start_timesamples with n >= start are loaded.
[in]end_timesamples with n < end are loaded. end <= start loads the complete signal.

Definition at line 192 of file Reader.cpp.

References gdf::Channel::deblitSamplesPhys(), gdf::Record::getChannel(), and getRecordPtr().

    {
        using boost::numeric_cast;

        SignalHeader *sh = &m_header.getSignalHeader( channel_idx );

        if( end <= start )
            end = boost::numeric_cast<size_t>( sh->get_samples_per_record( ) * m_header.getMainHeader_readonly().get_num_datarecords( ) );

        size_t record = boost::numeric_cast<size_t>( floor( ((double)start)/((double)sh->get_samples_per_record()) ) );
        size_t readpos = start % sh->get_samples_per_record();
        size_t writepos = 0;
        size_t samples_to_go = end - start;

        while( samples_to_go > 0 )
        {
            Record *r = getRecordPtr( record );

            size_t n = std::min( (size_t)sh->get_samples_per_record( ) - readpos, samples_to_go );
            r->getChannel( channel_idx )->deblitSamplesPhys( &buffer[writepos], readpos, n );
            samples_to_go -= n;
            writepos += n;
            readpos = 0;

            record++;
        }
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index