LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
DaqData Class Reference

Data coming from / going to DAQ. Non-interleaved format, which means data in buffer is ordered by channel: _ptr[frame+channel*nframes]. More...

#include <lasp_daqdata.h>

Collaboration diagram for DaqData:

Public Member Functions

 DaqData (const us nframes, const us nchannels, const DataTypeDescriptor::DataType dtype)
 Initialize an empty frame of data.
 
 DaqData (const DaqData &)
 Initialize using no allocation.
 
 DaqData (DaqData &&)
 
DaqDataoperator= (const DaqData &)=delete
 
 ~DaqData ()
 
byte_traw_ptr (const us frame=0, const us channel=0)
 Return pointer to the raw data corresponding to a certain sample (frame, channel combo).
 
const byte_traw_ptr (const us frame=0, const us channel=0) const
 
us size_bytes () const
 Return the total number of bytes.
 
void copyInFromRaw (const std::vector< byte_t * > &ptrs)
 Copy data from a set of raw pointers of uninterleaved data. Overwrites any existing available data.
 
void copyInFromRaw (const us channel, const byte_t *ptr)
 Copy data from a set of raw pointers of uninterleaved data. Overwrites any existing available data.
 
void copyToRaw (const us channel, byte_t *ptr)
 Copy contents of DaqData for a certain channel to a raw pointer.
 
arma::Mat< d > toFloat () const
 Convert samples to floating point values and return a nframes x nchannels array of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.
 
arma::Col< d > toFloat (const us channel_no) const
 Convert samples to floating point value; and return a nframes column vector of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.
 
toFloat (const us frame_no, const us channel_no) const
 Convert single sample to floating point value; and return a nframes column vector of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.
 
void fromFloat (const us frame_no, const us channel_no, const d data)
 Convert to channel data of native type from floating point values. Useful for 'changing' raw data in any way.
 
void fromFloat (const us channel, const arma::Col< d > &data)
 Convert to channel data of native type from floating point values. Useful for 'changing' raw data in any way.
 
template<typename T >
T & value (const us frame, const us channel)
 
template<typename T >
const T & value (const us frame, const us channel) const
 
void print () const
 For debugging purposes: prints some stats.
 
template<typename T >
vd toFloat (const us channel) const
 
template<typename T >
dmat toFloat () const
 

Public Attributes

us nframes
 The number of frames in this block of data.
 
us nchannels
 The number of channels.
 
DataTypeDescriptor::DataType dtype
 The data type corresponding to a sample.
 
DataTypeDescriptor dtype_descr
 The data type description corresponding to a sample.
 
us sw
 The number of bytes per sample (sample width, sw)
 

Protected Member Functions

template<typename T >
void check_type () const
 
template<typename T >
arma::Mat< d > toFloat () const
 
template<typename T >
arma::Col< d > toFloat (const us channel_no) const
 
template<typename T >
toFloat (const us frame_no, const us channel_no) const
 
template<typename T >
void fromFloat (const us channel_no, const arma::Col< d > &vals)
 
template<typename T >
void fromFloat (const us frame_no, const us channel_no, const d val)
 

Protected Attributes

byte_t_data
 Storage for the actual data.
 

Detailed Description

Data coming from / going to DAQ. Non-interleaved format, which means data in buffer is ordered by channel: _ptr[frame+channel*nframes].

Definition at line 22 of file lasp_daqdata.h.

Constructor & Destructor Documentation

◆ DaqData() [1/3]

DaqData::DaqData ( const us  nframes,
const us  nchannels,
const DataTypeDescriptor::DataType  dtype 
)

Initialize an empty frame of data.

Constructors and destructors.

Parameters
nframesThe number of frames
nchannelsThe number of channels
dtypeThe data type

Definition at line 19 of file lasp_daqdata.cpp.

◆ DaqData() [2/3]

DaqData::DaqData ( const DaqData o)

Initialize using no allocation.

Definition at line 36 of file lasp_daqdata.cpp.

◆ DaqData() [3/3]

DaqData::DaqData ( DaqData &&  o)

Steal from other one

Nullptrs do not get deleted

Definition at line 42 of file lasp_daqdata.cpp.

◆ ~DaqData()

DaqData::~DaqData ( )

Definition at line 54 of file lasp_daqdata.cpp.

Member Function Documentation

◆ check_type()

template<typename T >
void DaqData::check_type ( ) const
inlineprotected

Definition at line 196 of file lasp_daqdata.h.

◆ copyInFromRaw() [1/2]

void DaqData::copyInFromRaw ( const std::vector< byte_t * > &  ptrs)

Copy data from a set of raw pointers of uninterleaved data. Overwrites any existing available data.

Parameters
ptrsPointers to data from channels

Definition at line 60 of file lasp_daqdata.cpp.

◆ copyInFromRaw() [2/2]

void DaqData::copyInFromRaw ( const us  channel,
const byte_t ptr 
)

Copy data from a set of raw pointers of uninterleaved data. Overwrites any existing available data.

Parameters
channelThe channel to copy to
ptrPointers to data from channels

Definition at line 69 of file lasp_daqdata.cpp.

◆ copyToRaw()

void DaqData::copyToRaw ( const us  channel,
byte_t ptr 
)

Copy contents of DaqData for a certain channel to a raw pointer.

Parameters
channelThe channel to copy.
ptrThe pointer where data is copied to.

Definition at line 75 of file lasp_daqdata.cpp.

◆ fromFloat() [1/4]

void DaqData::fromFloat ( const us  channel,
const arma::Col< d > &  data 
)

Convert to channel data of native type from floating point values. Useful for 'changing' raw data in any way.

Parameters
channelThe channel to convert
dataData to convert from float values

Definition at line 250 of file lasp_daqdata.cpp.

◆ fromFloat() [2/4]

template<typename T >
void DaqData::fromFloat ( const us  channel_no,
const arma::Col< d > &  vals 
)
protected

◆ fromFloat() [3/4]

void DaqData::fromFloat ( const us  frame_no,
const us  channel_no,
const d  data 
)

Convert to channel data of native type from floating point values. Useful for 'changing' raw data in any way.

Parameters
frame_noThe frame
channel_noThe channel
dataThe value

Definition at line 226 of file lasp_daqdata.cpp.

◆ fromFloat() [4/4]

template<typename T >
void DaqData::fromFloat ( const us  frame_no,
const us  channel_no,
const d  val 
)
protected

Definition at line 213 of file lasp_daqdata.cpp.

◆ operator=()

DaqData & DaqData::operator= ( const DaqData )
delete

◆ print()

void DaqData::print ( ) const

For debugging purposes: prints some stats.

Definition at line 286 of file lasp_daqdata.cpp.

◆ raw_ptr() [1/2]

byte_t * DaqData::raw_ptr ( const us  frame = 0,
const us  channel = 0 
)
inline

Return pointer to the raw data corresponding to a certain sample (frame, channel combo).

Parameters
frameThe frame number
channelThe channel number
Returns
Pointer to sample, not casted to final type

Definition at line 81 of file lasp_daqdata.h.

◆ raw_ptr() [2/2]

const byte_t * DaqData::raw_ptr ( const us  frame = 0,
const us  channel = 0 
) const
inline

Definition at line 86 of file lasp_daqdata.h.

◆ size_bytes()

us DaqData::size_bytes ( ) const
inline

Return the total number of bytes.

Returns
Number of bytes of data.

Definition at line 97 of file lasp_daqdata.h.

◆ toFloat() [1/8]

template<typename T >
dmat DaqData::toFloat ( ) const

Definition at line 104 of file lasp_daqdata.cpp.

◆ toFloat() [2/8]

dmat DaqData::toFloat ( ) const

Convert samples to floating point values and return a nframes x nchannels array of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.

Returns
Array of floats

Definition at line 175 of file lasp_daqdata.cpp.

◆ toFloat() [3/8]

template<typename T >
arma::Mat< d > DaqData::toFloat ( ) const
protected

◆ toFloat() [4/8]

template<typename T >
vd DaqData::toFloat ( const us  channel) const

Definition at line 93 of file lasp_daqdata.cpp.

◆ toFloat() [5/8]

vd DaqData::toFloat ( const us  channel_no) const

Convert samples to floating point value; and return a nframes column vector of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.

Parameters
channel_noThe channel number to convert
Returns
Array of floats

Definition at line 147 of file lasp_daqdata.cpp.

◆ toFloat() [6/8]

template<typename T >
arma::Col< d > DaqData::toFloat ( const us  channel_no) const
protected

◆ toFloat() [7/8]

d DaqData::toFloat ( const us  frame_no,
const us  channel_no 
) const

Convert single sample to floating point value; and return a nframes column vector of floats. For data that is not already floating-point, the data is scaled back from MAX_INT to +1.0.

Parameters
frame_noThe frame number to convert
channel_noThe channel number to convert
Returns
Float value

Definition at line 120 of file lasp_daqdata.cpp.

◆ toFloat() [8/8]

template<typename T >
d DaqData::toFloat ( const us  frame_no,
const us  channel_no 
) const
protected

Definition at line 83 of file lasp_daqdata.cpp.

◆ value() [1/2]

template<typename T >
T & DaqData::value ( const us  frame,
const us  channel 
)
inline

Definition at line 177 of file lasp_daqdata.h.

◆ value() [2/2]

template<typename T >
const T & DaqData::value ( const us  frame,
const us  channel 
) const
inline

Definition at line 183 of file lasp_daqdata.h.

Member Data Documentation

◆ _data

byte_t* DaqData::_data
protected

Storage for the actual data.

Definition at line 27 of file lasp_daqdata.h.

◆ dtype

The data type corresponding to a sample.

Definition at line 43 of file lasp_daqdata.h.

◆ dtype_descr

DataTypeDescriptor DaqData::dtype_descr

The data type description corresponding to a sample.

Definition at line 48 of file lasp_daqdata.h.

◆ nchannels

us DaqData::nchannels

The number of channels.

Definition at line 38 of file lasp_daqdata.h.

◆ nframes

us DaqData::nframes

The number of frames in this block of data.

Definition at line 33 of file lasp_daqdata.h.

◆ sw

us DaqData::sw

The number of bytes per sample (sample width, sw)

Definition at line 53 of file lasp_daqdata.h.


The documentation for this class was generated from the following files: