libpsynth 0.2.1
Public Types | Public Member Functions | Public Attributes
psynth::sound::ring_buffer_range_base< Range > Class Template Reference

#include <ring_buffer_range.hpp>

Inheritance diagram for psynth::sound::ring_buffer_range_base< Range >:
Inheritance graph
[legend]
Collaboration diagram for psynth::sound::ring_buffer_range_base< Range >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Range range
typedef Range::size_type size_type
typedef Range::difference_type difference_type
typedef
detail::unsafe_ring_position
< ring_buffer_range_base
unsafe_position
typedef detail::ring_position
< ring_buffer_range_base
position

Public Member Functions

 ring_buffer_range_base ()
 Constructor.
 ring_buffer_range_base (const ring_buffer_range_base &range)
 Copy constructor.
 ring_buffer_range_base (const Range &range)
template<class Range2 >
 ring_buffer_range_base (const ring_buffer_range_base< Range2 > &range)
 Copy constructor.
ring_buffer_range_baseoperator= (const ring_buffer_range_base &range)
 Assignment operator.
size_type size () const
 Returns the size of the buffer.
unsafe_position begin_unsafe_pos () const
 Returns a read pointer to the beginning of the available data.
unsafe_position end_unsafe_pos () const
 Returns a read pointer to the end of the available data.
position begin_pos () const
 Returns a read pointer to the beginning of the available data.
position end_pos () const
 Returns a read pointer to the end of the available data.
size_type available (const position &r) const
 Returns the number of available data from a read pointer.
size_type available (const unsafe_position &r) const
 Returns the number of available data from a read pointer.
size_type available () const
 Returns the number of available data from a read pointer.
int check_position (const position &reader) const
 Checks a iterator for error states.
template<class Position >
buffer_range_type< Range >::type sub_buffer_one (const Position &p, size_type slice) const
template<class Position >
buffer_range_type< Range >::type sub_buffer_two (const Position &p, size_type slice) const
template<class Position , class Range2 >
size_t read (Position &r, const Range2 &range) const
 Fills a sample_buffer with data from the ring buffer.
template<class Position , class Range2 >
size_type read (Position &r, const Range2 &range, size_type samples) const
 Fills a sample_buffer with data from the ring buffer.
template<class Position , class Range2 , class CC = default_channel_converter>
size_t read_and_convert (Position &r, const Range2 &range, CC cc=CC()) const
 Fills a sample_buffer with data from the ring buffer.
template<class Position , class Range2 , class CC = default_channel_converter>
size_type read_and_convert (Position &r, const Range2 &range, size_type samples, CC cc=CC()) const
 Fills a sample_buffer with data from the ring buffer.
template<class Range2 >
void write (const Range2 &range)
 Write all the data in a sample_buffer to the ring buffer.
template<class Range2 >
void write (const Range2 &range, size_type samples)
 Write some data in a sample_buffer to the ring buffer.
template<class Range2 , class CC = default_channel_converter>
void write_and_convert (const Range2 &range, CC cc=CC())
 Write all the data in a sample_buffer to the ring buffer.
template<class Range2 , class CC = default_channel_converter>
void write_and_convert (const Range2 &range, size_type samples, CC cc=CC())
 Write some data in a sample_buffer to the ring buffer.
void zero ()
 Sets to zero all the contents of the buffer.
bool is_backwards () const
 Returns wether this buffer is being written backwards.
void set_backwards ()
 Changes the reading direction of the current pointer write pointer.
void advance (difference_type n)
 Advances the write pointer of the buffer a given number of elements.
template<typename Position >
void advance (Position &r, difference_type n) const
 Advances a read pointer a given number of elements.
difference_type distance (const unsafe_position &ra, const unsafe_position &rb) const
difference_type distance (const position &ra, const position &rb) const
template<typename Position >
void increment (Position &r) const
template<typename Position >
void decrement (Position &r) const
difference_type count () const
position sync (const position &r) const
 Returns a new iterator in the same position but with the read count calculated from the read position to the write position.

Public Attributes

bool _backwards
 true if we are reading and writting the ringbuffer backwards.
size_type _startpos
 The new starting position of the ring buffer.
position _writepos
Range _range

Detailed Description

template<typename Range>
class psynth::sound::ring_buffer_range_base< Range >

Note:
There is no const counterpart?

Member Typedef Documentation

template<typename Range>
typedef Range::difference_type psynth::sound::ring_buffer_range_base< Range >::difference_type
template<typename Range>
typedef Range psynth::sound::ring_buffer_range_base< Range >::range
template<typename Range>
typedef Range::size_type psynth::sound::ring_buffer_range_base< Range >::size_type

Constructor & Destructor Documentation

template<typename Range>
psynth::sound::ring_buffer_range_base< Range >::ring_buffer_range_base ( ) [inline]

Constructor.

Parameters:
sizeThe size of the buffer, defaults to zero.
template<typename Range>
psynth::sound::ring_buffer_range_base< Range >::ring_buffer_range_base ( const ring_buffer_range_base< Range > &  range) [inline]

Copy constructor.

template<typename Range>
psynth::sound::ring_buffer_range_base< Range >::ring_buffer_range_base ( const Range &  range) [inline, explicit]
template<typename Range>
template<class Range2 >
psynth::sound::ring_buffer_range_base< Range >::ring_buffer_range_base ( const ring_buffer_range_base< Range2 > &  range) [inline]

Copy constructor.


Member Function Documentation

template<typename Range>
void psynth::sound::ring_buffer_range_base< Range >::advance ( difference_type  n) [inline]

Advances the write pointer of the buffer a given number of elements.

Parameters:
nThe number of elements to advance.
template<typename Range>
template<typename Position >
void psynth::sound::ring_buffer_range_base< Range >::advance ( Position &  r,
difference_type  n 
) const [inline]

Advances a read pointer a given number of elements.

Parameters:
rThe iterator to advance.
nThe number of elements to advance.
template<typename Range>
size_type psynth::sound::ring_buffer_range_base< Range >::available ( const unsafe_position r) const [inline]

Returns the number of available data from a read pointer.

Parameters:
rThe read pointer to test for available data.
template<typename Range>
size_type psynth::sound::ring_buffer_range_base< Range >::available ( ) const [inline]

Returns the number of available data from a read pointer.

Parameters:
rThe read pointer to test for available data.
template<typename Range>
size_type psynth::sound::ring_buffer_range_base< Range >::available ( const position r) const [inline]

Returns the number of available data from a read pointer.

Parameters:
rThe read pointer to test for available data.
template<typename Range>
position psynth::sound::ring_buffer_range_base< Range >::begin_pos ( ) const [inline]

Returns a read pointer to the beginning of the available data.

template<typename Range>
unsafe_position psynth::sound::ring_buffer_range_base< Range >::begin_unsafe_pos ( ) const [inline]

Returns a read pointer to the beginning of the available data.

template<typename Range>
int psynth::sound::ring_buffer_range_base< Range >::check_position ( const position reader) const [inline]

Checks a iterator for error states.

template<typename Range>
difference_type psynth::sound::ring_buffer_range_base< Range >::count ( ) const [inline]
template<typename Range>
template<typename Position >
void psynth::sound::ring_buffer_range_base< Range >::decrement ( Position &  r) const [inline]
template<typename Range>
difference_type psynth::sound::ring_buffer_range_base< Range >::distance ( const unsafe_position ra,
const unsafe_position rb 
) const [inline]
template<typename Range>
difference_type psynth::sound::ring_buffer_range_base< Range >::distance ( const position ra,
const position rb 
) const [inline]
template<typename Range>
position psynth::sound::ring_buffer_range_base< Range >::end_pos ( ) const [inline]

Returns a read pointer to the end of the available data.

template<typename Range>
unsafe_position psynth::sound::ring_buffer_range_base< Range >::end_unsafe_pos ( ) const [inline]

Returns a read pointer to the end of the available data.

template<typename Range>
template<typename Position >
void psynth::sound::ring_buffer_range_base< Range >::increment ( Position &  r) const [inline]
template<typename Range>
bool psynth::sound::ring_buffer_range_base< Range >::is_backwards ( ) const [inline]

Returns wether this buffer is being written backwards.

template<typename Range>
ring_buffer_range_base& psynth::sound::ring_buffer_range_base< Range >::operator= ( const ring_buffer_range_base< Range > &  range) [inline]

Assignment operator.

template<typename Range>
template<class Position , class Range2 >
size_t psynth::sound::ring_buffer_range_base< Range >::read ( Position &  r,
const Range2 &  range 
) const [inline]

Fills a sample_buffer with data from the ring buffer.

Parameters:
rThe reader posize_ter.
bufThe buffer to fill with the data.
template<typename Range>
template<class Position , class Range2 >
size_type psynth::sound::ring_buffer_range_base< Range >::read ( Position &  r,
const Range2 &  range,
size_type  samples 
) const

Fills a sample_buffer with data from the ring buffer.

Parameters:
rThe reader pointer.
bufThe buffer to fill with the data.
samplesThe number of samples to read.
template<typename Range>
template<class Position , class Range2 , class CC = default_channel_converter>
size_type psynth::sound::ring_buffer_range_base< Range >::read_and_convert ( Position &  r,
const Range2 &  range,
size_type  samples,
CC  cc = CC() 
) const

Fills a sample_buffer with data from the ring buffer.

Parameters:
rThe reader pointer.
bufThe buffer to fill with the data.
samplesThe number of samples to read.
template<typename Range>
template<class Position , class Range2 , class CC = default_channel_converter>
size_t psynth::sound::ring_buffer_range_base< Range >::read_and_convert ( Position &  r,
const Range2 &  range,
CC  cc = CC () 
) const [inline]

Fills a sample_buffer with data from the ring buffer.

Parameters:
rThe reader posize_ter.
bufThe buffer to fill with the data.
template<typename Range>
void psynth::sound::ring_buffer_range_base< Range >::set_backwards ( ) [inline]

Changes the reading direction of the current pointer write pointer.

If you are using this buffer as an intermediate buffer from another medium and your where reading that medium forwards, this allows you to not to lose the already read data remaining in the buffer if you change the reading direction.

See also:
sync ()
Note:
Returna new range instead of modifying the current?
Todo:

This seems to be fixed.

caching_file_input_impl::set_backwards seems to compensate the reading backwards bug. Check old implementation.

template<typename Range>
size_type psynth::sound::ring_buffer_range_base< Range >::size ( ) const [inline]

Returns the size of the buffer.

template<typename Range>
template<class Position >
buffer_range_type<Range>::type psynth::sound::ring_buffer_range_base< Range >::sub_buffer_one ( const Position &  p,
size_type  slice 
) const
template<typename Range>
template<class Position >
buffer_range_type<Range>::type psynth::sound::ring_buffer_range_base< Range >::sub_buffer_two ( const Position &  p,
size_type  slice 
) const
template<typename Range>
position psynth::sound::ring_buffer_range_base< Range >::sync ( const position r) const [inline]

Returns a new iterator in the same position but with the read count calculated from the read position to the write position.

This function may be called to get back from an erratic iterator and must be called whenever the write direction is changed using the backwards () function.

template<typename Range>
template<class Range2 >
void psynth::sound::ring_buffer_range_base< Range >::write ( const Range2 &  range) [inline]

Write all the data in a sample_buffer to the ring buffer.

Parameters:
bufThe buffer to write.
template<typename Range>
template<class Range2 >
void psynth::sound::ring_buffer_range_base< Range >::write ( const Range2 &  range,
size_type  samples 
)

Write some data in a sample_buffer to the ring buffer.

Parameters:
bufThe buffer to write.
samplesThe number of samples to write.
template<typename Range>
template<class Range2 , class CC = default_channel_converter>
void psynth::sound::ring_buffer_range_base< Range >::write_and_convert ( const Range2 &  range,
size_type  samples,
CC  cc = CC() 
)

Write some data in a sample_buffer to the ring buffer.

Parameters:
bufThe buffer to write.
samplesThe number of samples to write.
template<typename Range>
template<class Range2 , class CC = default_channel_converter>
void psynth::sound::ring_buffer_range_base< Range >::write_and_convert ( const Range2 &  range,
CC  cc = CC () 
) [inline]

Write all the data in a sample_buffer to the ring buffer.

Parameters:
bufThe buffer to write.
template<typename Range>
void psynth::sound::ring_buffer_range_base< Range >::zero ( ) [inline]

Sets to zero all the contents of the buffer.


Member Data Documentation

template<typename Range>
bool psynth::sound::ring_buffer_range_base< Range >::_backwards

true if we are reading and writting the ringbuffer backwards.

template<typename Range>
Range psynth::sound::ring_buffer_range_base< Range >::_range
template<typename Range>
size_type psynth::sound::ring_buffer_range_base< Range >::_startpos

The new starting position of the ring buffer.

template<typename Range>
position psynth::sound::ring_buffer_range_base< Range >::_writepos

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