Nsound  0.9.4
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nsound::CircularBuffer Class Reference

#include <Nsound/CircularBuffer.h>

Public Member Functions

 CircularBuffer (uint32 n_samples)
 
 ~CircularBuffer ()
 
Buffer read () const
 
void write (float64 d)
 
void write (const AudioStream &as)
 
void write (const Buffer &b)
 

Protected Attributes

Bufferbuffer_
 
Buffer::circular_iteratoritor_
 

Private Member Functions

 CircularBuffer (const CircularBuffer &copy)
 
CircularBufferoperator= (const CircularBuffer &rhs)
 

Detailed Description

Definition at line 41 of file CircularBuffer.h.

Constructor & Destructor Documentation

CircularBuffer::CircularBuffer ( uint32  n_samples)

Definition at line 39 of file CircularBuffer.cc.

40  :
41  buffer_(new Buffer(Buffer::zeros(n_samples))),
43 {
44 }
static Buffer zeros(const uint32 n_samples)
Returns a Buffer full of zeros of length n_samples.
Definition: Buffer.cc:2265
A circulator iterator for class Buffer.
circular_iterator cbegin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:318
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer::circular_iterator * itor_
CircularBuffer::~CircularBuffer ( )

Definition at line 47 of file CircularBuffer.cc.

References buffer_, and itor_.

48 {
49  delete buffer_;
50  delete itor_;
51 };
Buffer::circular_iterator * itor_
Nsound::CircularBuffer::CircularBuffer ( const CircularBuffer copy)
private

Member Function Documentation

Buffer CircularBuffer::read ( ) const

Definition at line 55 of file CircularBuffer.cc.

References buffer_, Nsound::Buffer::getLength(), and itor_.

56 {
57  const uint32 N = buffer_->getLength();
58 
60 
61  Buffer b(N);
62 
63  for(uint32 i = 0; i < N; ++i)
64  {
65  b << *ci;
66  ++ci;
67  }
68 
69  return b;
70 }
unsigned int uint32
Definition: Nsound.h:153
A circulator iterator for class Buffer.
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer::circular_iterator * itor_
void CircularBuffer::write ( float64  d)

Definition at line 74 of file CircularBuffer.cc.

Referenced by write().

75 {
76  *(*itor_) = d;
77  ++(*itor_);
78 }
void CircularBuffer::write ( const AudioStream as)

Definition at line 82 of file CircularBuffer.cc.

References Nsound::AudioStream::getMono(), and write().

83 {
84  write(as.getMono()[0]);
85 }
void write(float64 d)
AudioStream getMono() const
Collapses all channels into one Buffer making it mono.
Definition: AudioStream.cc:265
void CircularBuffer::write ( const Buffer b)

Definition at line 89 of file CircularBuffer.cc.

References Nsound::Buffer::getLength().

90 {
91  const uint32 M = src.getLength();
92 
93  for(uint32 i = 0; i < M; ++i)
94  {
95  *(*itor_) = src[i];
96  ++(*itor_);
97  }
98 }
unsigned int uint32
Definition: Nsound.h:153
CircularBuffer& Nsound::CircularBuffer::operator= ( const CircularBuffer rhs)
private

Member Data Documentation

Buffer* Nsound::CircularBuffer::buffer_
protected

Definition at line 56 of file CircularBuffer.h.

Referenced by read(), and ~CircularBuffer().

Buffer::circular_iterator* Nsound::CircularBuffer::itor_
protected

Definition at line 57 of file CircularBuffer.h.

Referenced by read(), and ~CircularBuffer().


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