Audio Processing Framework (APF)  version 0.3.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
apf::BlockDelayLine< T, Container > Class Template Reference

Block-based delay line. More...

#include <apf/blockdelayline.h>

Inheritance diagram for apf::BlockDelayLine< T, Container >:
Inheritance graph
[legend]

Public Types

using size_type = typename Container::size_type
 
using difference_type = typename Container::difference_type
 
using pointer = typename Container::pointer
 
using circulator = apf::circular_iterator< typename Container::iterator >
 

Public Member Functions

 BlockDelayLine (size_type block_size, size_type max_delay)
 Constructor. More...
 
bool delay_is_valid (size_type delay, size_type &corrected) const
 Check if a given delay is valid. More...
 
bool delay_is_valid (size_type delay) const
 Return true if delay is valid. More...
 
void advance ()
 Advance the internal iterators/pointers to the next block. More...
 
template<typename Iterator >
void write_block (Iterator source)
 Write a block of data to the delay line. More...
 
template<typename Iterator >
bool read_block (Iterator destination, size_type delay) const
 Read a block of data from the delay line. More...
 
template<typename Iterator >
bool read_block (Iterator destination, size_type delay, T weight) const
 Read from the delay line and multiply each element by a given factor. More...
 
pointer get_write_pointer () const
 Get the write pointer. More...
 
circulator get_read_circulator (size_type delay=0) const
 Get the read circulator. More...
 

Protected Member Functions

circulator _get_data_circulator () const
 Get a circular iterator to the sample with time 0. More...
 

Protected Attributes

const size_type _block_size
 Size of read/write blocks. More...
 

Detailed Description

template<typename T, typename Container = std::vector<T>>
class apf::BlockDelayLine< T, Container >

Block-based delay line.

This is a "write once, read many times" delay line. The write operation is simple and fast. The desired delay is specified at the more flexible read operation.

Definition at line 47 of file blockdelayline.h.

Constructor & Destructor Documentation

template<typename T , typename Container >
apf::BlockDelayLine< T, Container >::BlockDelayLine ( size_type  block_size,
size_type  max_delay 
)

Constructor.

Parameters
block_sizeBlock size
max_delayMaximum delay in samples

Definition at line 121 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::_block_size.

Member Function Documentation

template<typename T, typename Container = std::vector<T>>
bool apf::BlockDelayLine< T, Container >::delay_is_valid ( size_type  delay,
size_type &  corrected 
) const
inline

Check if a given delay is valid.

Parameters
delayDesired delay
[out]correctedIf valid, the same as delay, if not, the maximum possible delay.
Returns
true if delay is valid.

Definition at line 62 of file blockdelayline.h.

Referenced by apf::BlockDelayLine< T, Container >::delay_is_valid(), apf::NonCausalBlockDelayLine< T, Container >::delay_is_valid(), and apf::BlockDelayLine< T, Container >::read_block().

template<typename T, typename Container = std::vector<T>>
bool apf::BlockDelayLine< T, Container >::delay_is_valid ( size_type  delay) const
inline

Return true if delay is valid.

See also
delay_is_valid()

Definition at line 70 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::delay_is_valid().

template<typename T, typename Container = std::vector<T>>
void apf::BlockDelayLine< T, Container >::advance ( )
inline
template<typename T , typename Container >
template<typename Iterator >
void apf::BlockDelayLine< T, Container >::write_block ( Iterator  source)

Write a block of data to the delay line.

Before writing, the read and write pointers are advanced to the next block. If you don't want to use this function, you can also call advance(), get the write pointer with get_write_pointer() and write directly to it.

Parameters
sourcePointer/iterator where the block of data shall be read from.
Attention
In source there must be enough data to read from!
Note
source must be a random access iterator. If you want to use another iterator, you'll have to do it on your own (as written above).

Definition at line 152 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::_block_size, apf::BlockDelayLine< T, Container >::advance(), and apf::BlockDelayLine< T, Container >::get_write_pointer().

Referenced by apf::BlockDelayLine< T, Container >::advance(), and apf::NonCausalBlockDelayLine< T, Container >::NonCausalBlockDelayLine().

template<typename T , typename Container >
template<typename Iterator >
bool apf::BlockDelayLine< T, Container >::read_block ( Iterator  destination,
size_type  delay 
) const

Read a block of data from the delay line.

Parameters
destinationIterator to destination
delayDelay in samples
Returns
true on success

Definition at line 167 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::_block_size, apf::BlockDelayLine< T, Container >::delay_is_valid(), and apf::BlockDelayLine< T, Container >::get_read_circulator().

Referenced by apf::BlockDelayLine< T, Container >::advance().

template<typename T , typename Container >
template<typename Iterator >
bool apf::BlockDelayLine< T, Container >::read_block ( Iterator  destination,
size_type  delay,
weight 
) const

Read from the delay line and multiply each element by a given factor.

Definition at line 183 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::_block_size, apf::BlockDelayLine< T, Container >::delay_is_valid(), and apf::BlockDelayLine< T, Container >::get_read_circulator().

template<typename T , typename Container >
BlockDelayLine< T, Container >::pointer apf::BlockDelayLine< T, Container >::get_write_pointer ( ) const

Get the write pointer.

Attention
Before the write operation, advance() must be called to update read and write pointers.
You must not write more than one block with this pointer! For the next block, you have to get a new pointer.

Definition at line 201 of file blockdelayline.h.

Referenced by apf::BlockDelayLine< T, Container >::advance(), apf::NonCausalBlockDelayLine< T, Container >::NonCausalBlockDelayLine(), and apf::BlockDelayLine< T, Container >::write_block().

template<typename T , typename Container >
BlockDelayLine< T, Container >::circulator apf::BlockDelayLine< T, Container >::get_read_circulator ( size_type  delay = 0) const

Get the read circulator.

Parameters
delayDelay in samples
Attention
There is no check if the delay is in the valid range between 0 and max_delay. You are responsible for checking that!

Definition at line 213 of file blockdelayline.h.

References apf::BlockDelayLine< T, Container >::_get_data_circulator().

Referenced by apf::BlockDelayLine< T, Container >::advance(), and apf::BlockDelayLine< T, Container >::read_block().

template<typename T, typename Container = std::vector<T>>
circulator apf::BlockDelayLine< T, Container >::_get_data_circulator ( ) const
inlineprotected

Get a circular iterator to the sample with time 0.

Definition at line 98 of file blockdelayline.h.

Referenced by apf::BlockDelayLine< T, Container >::get_read_circulator().

Member Data Documentation

template<typename T, typename Container = std::vector<T>>
const size_type apf::BlockDelayLine< T, Container >::_block_size
protected

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