A Hopf, Skip and a Jump
Public Member Functions | Protected Attributes | List of all members
detectorcache::Producer Class Reference

Specialisation of the slidingbuffer::SegmentProducer class to create blocks of DetectorBank analysis channels and store them in a detectorcache::Segment. More...

#include <detectorcache.h>

Inheritance diagram for detectorcache::Producer:
Inheritance graph
[legend]
Collaboration diagram for detectorcache::Producer:
Collaboration graph
[legend]

Public Member Functions

 Producer (DetectorBank &db, std::istream *is=nullptr)
 Construct a Producer given a DetectorBank. More...
 
virtual std::size_t generate (result_t *seg[], const std::size_t idx, const std::size_t size)
 Generate a DetectorBank result block of the length specified by our associated DetectorCache after its construction. More...
 
virtual bool more (void)
 Establish wheter there is further data to be read from the DetectorBank associated with this cache. More...
 
void set_num_samps (std::size_t n)
 Set the block length (in samples) of each audio block which the Producer must generate. More...
 
void set_start_chan (std::size_t c)
 Set the startChan for getZ. More...
 
parameter_t getSR (void) const
 Get the sample rate associated with this DetectorBank. More...
 
std::size_t getChans (void)
 Enquire the number of channles for which data is produced. More...
 
std::size_t getBuflen (void)
 Enquire the length of the data stored in the Producer's associated DetectorBank. More...
 
parameter_t getW (std::size_t ch)
 Find the frequency of a given channel's detector. More...
 
parameter_t getFreqIn (std::size_t ch)
 Get the input frequency of a given channel's detector. More...
 
- Public Member Functions inherited from slidingbuffer::SegmentProducer< result_t *>
virtual ~SegmentProducer ()
 Destructor: to be provided by derived class.
 

Protected Attributes

DetectorBankdb
 The DetectorBank which produces the results.
 
std::size_t seg_len
 Block-length (number of audio samples) to request on each call to generate()
 
std::istream * audiostream
 In stream mode (datastream non-null), the istream from which inputSample_t samples are to be read.
 
std::size_t start_chan
 Channel in DetectorBank at which to start.
 

Detailed Description

Specialisation of the slidingbuffer::SegmentProducer class to create blocks of DetectorBank analysis channels and store them in a detectorcache::Segment.

The 2D nature of the storage means that the specialisation of SlidingBuffer is somewhat non-trivial. Refer to the detailed description of detectorcache::DetectorCache for a full explaination of the data structures involved.

Definition at line 19 of file detectorcache.h.

Constructor & Destructor Documentation

◆ Producer()

detectorcache::Producer::Producer ( DetectorBank db,
std::istream *  is = nullptr 
)
inline

Construct a Producer given a DetectorBank.

Since the Producer's final operating parameters (specifically, the number of time-samples per segment) is unknown until the associated DetectorCache is constructed, and because this must happen after the Producer's construction, no memory allocation can be usefully performed here.

The Producer can be operated in pre-buffered or stream mode. In the former, the DetectorBank will have been initialised with an array of audio samples, and each call to Producer::generate will progress through the DetectorBuffer's input buffer as normal. If an istream is supplied when the producer is constructed, every time Producer::generate is called, Producer::seg_len samples are read from the associated audio istream, used to set the DetectorBank's input buffer from which the analysis is generated

Parameters
dbThe previously created detetorbank which will perform the analysis
isIf stream mode is required, a pointer to the input stream from which samples (of inputSample_t) shall be read

Definition at line 47 of file detectorcache.h.

Member Function Documentation

◆ generate()

virtual std::size_t detectorcache::Producer::generate ( result_t *  seg[],
const std::size_t  idx,
const std::size_t  size 
)
virtual

Generate a DetectorBank result block of the length specified by our associated DetectorCache after its construction.

Parameters
segPointers to results for each channel to be populated by the Producer
idxSequence key for the first channel in this block. Refer to the extended documentation for detectorcache::DetectorCache for more details
sizeNumber of channels for which data is held (not used: this is read from the DetectorBank for security reasons).
Returns
The number of channels for which data is stored.

Implements slidingbuffer::SegmentProducer< result_t *>.

◆ getBuflen()

std::size_t detectorcache::Producer::getBuflen ( void  )
inline

Enquire the length of the data stored in the Producer's associated DetectorBank.

Returns
Length of the associated DetectorBank's input buffer in samples.

Definition at line 106 of file detectorcache.h.

◆ getChans()

std::size_t detectorcache::Producer::getChans ( void  )
inline

Enquire the number of channles for which data is produced.

Returns
The number of channels for which this Producer shall provide valid data.

Definition at line 99 of file detectorcache.h.

◆ getFreqIn()

parameter_t detectorcache::Producer::getFreqIn ( std::size_t  ch)
inline

Get the input frequency of a given channel's detector.

Returns 0 if the channel number is invalid.

Parameters
chChannel number
Returns
f_in for the specified channel

Definition at line 121 of file detectorcache.h.

◆ getSR()

parameter_t detectorcache::Producer::getSR ( void  ) const
inline

Get the sample rate associated with this DetectorBank.

Returns
The current sample rate

Definition at line 93 of file detectorcache.h.

◆ getW()

parameter_t detectorcache::Producer::getW ( std::size_t  ch)
inline

Find the frequency of a given channel's detector.

If the signal has been modulated and/or normalised, the adjusted frequency will be returned. Returns 0 if the channel number is invalid.

Parameters
chChannel number
Returns
w = 2pi.f for the specified channel

Definition at line 114 of file detectorcache.h.

◆ more()

virtual bool detectorcache::Producer::more ( void  )
inlinevirtual

Establish wheter there is further data to be read from the DetectorBank associated with this cache.

Returns
true if more data is available, otherwise false.

Implements slidingbuffer::SegmentProducer< result_t *>.

Definition at line 73 of file detectorcache.h.

◆ set_num_samps()

void detectorcache::Producer::set_num_samps ( std::size_t  n)
inline

Set the block length (in samples) of each audio block which the Producer must generate.

This is unknown until the Producer is constructed (which has to be before the DetectorCache object which determines this parameter).

Parameters
nNumber of audio samples to be generated for each channel

Definition at line 82 of file detectorcache.h.

◆ set_start_chan()

void detectorcache::Producer::set_start_chan ( std::size_t  c)
inline

Set the startChan for getZ.

Parameters
cChannel from which to calculate abs(z) values

Definition at line 86 of file detectorcache.h.


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