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

A helper class for advance operators. More...

#include <Nsound/BufferSelection.h>

Public Member Functions

 BufferSelection (Buffer &buffer, const BooleanVector &bv)
 
 BufferSelection (const BufferSelection &copy)
 
BufferSelectionoperator= (const BufferSelection &rhs)
 
 ~BufferSelection ()
 
BufferSelectionoperator+= (const float64 &rhs)
 
BufferSelectionoperator-= (const float64 &rhs)
 
BufferSelectionoperator*= (const float64 &rhs)
 
BufferSelectionoperator/= (const float64 &rhs)
 
BufferSelectionoperator^= (const float64 &rhs)
 
BufferSelectionoperator= (const float64 &rhs)
 
void set (const float64 &rhs)
 

Protected Attributes

Buffertarget_buffer_
 
BooleanVector bv_
 

Detailed Description

A helper class for advance operators.

The intent for this class is to allow some "Matlab" like expressions.

Example:
// C++
Buffer b1;
b1 << "california.wav";
// limit anthing outsize of +/- 0.3
b1(b1 > 0.3) = 0.3;
b1(b1 < -0.3) = -0.3;
// Python
b1 = Buffer()
b1 << "california.wav"
b1(b1 > 0.3).set(0.3)
b1(b1 < -0.3).set(-0.3)

Definition at line 69 of file BufferSelection.h.

Constructor & Destructor Documentation

Nsound::BufferSelection::BufferSelection ( Buffer buffer,
const BooleanVector bv 
)

Definition at line 40 of file BufferSelection.cc.

41  :
42  target_buffer_(&buffer),
43  bv_(bv)
44 {
45 };
Nsound::BufferSelection::BufferSelection ( const BufferSelection copy)

Definition at line 49 of file BufferSelection.cc.

50  :
52  bv_(copy.bv_)
53 {
54 };
Nsound::BufferSelection::~BufferSelection ( )
inline

Definition at line 77 of file BufferSelection.h.

77 {};

Member Function Documentation

BufferSelection & Nsound::BufferSelection::operator= ( const BufferSelection rhs)

Definition at line 59 of file BufferSelection.cc.

References bv_, and target_buffer_.

60 {
61  if(this == & rhs)
62  {
63  return *this;
64  }
65 
67  bv_ = rhs.bv_;
68  return *this;
69 };
BufferSelection & Nsound::BufferSelection::operator+= ( const float64 rhs)

Definition at line 74 of file BufferSelection.cc.

75 {
78 
79  BooleanVector::iterator bv = bv_.begin();
80  BooleanVector::iterator bv_end = bv_.end();
81 
82  while(b != b_end && bv != bv_end)
83  {
84  if(*bv) *b += rhs;
85  ++b;
86  ++bv;
87  }
88 
89  return *this;
90 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
BufferSelection & Nsound::BufferSelection::operator-= ( const float64 rhs)

Definition at line 95 of file BufferSelection.cc.

96 {
99 
100  BooleanVector::iterator bv = bv_.begin();
101  BooleanVector::iterator bv_end = bv_.end();
102 
103  while(b != b_end && bv != bv_end)
104  {
105  if(*bv) *b -= rhs;
106  ++b;
107  ++bv;
108  }
109 
110  return *this;
111 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
BufferSelection & Nsound::BufferSelection::operator*= ( const float64 rhs)

Definition at line 116 of file BufferSelection.cc.

117 {
119  Buffer::iterator b_end = this->target_buffer_->end();
120 
121  BooleanVector::iterator bv = this->bv_.begin();
122  BooleanVector::iterator bv_end = this->bv_.end();
123 
124  while(b != b_end && bv != bv_end)
125  {
126  if(*bv) *b *= rhs;
127  ++b;
128  ++bv;
129  }
130 
131  return *this;
132 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
BufferSelection & Nsound::BufferSelection::operator/= ( const float64 rhs)

Definition at line 137 of file BufferSelection.cc.

138 {
140  Buffer::iterator b_end = this->target_buffer_->end();
141 
142  BooleanVector::iterator bv = this->bv_.begin();
143  BooleanVector::iterator bv_end = this->bv_.end();
144 
145  while(b != b_end && bv != bv_end)
146  {
147  if(*bv) *b /= rhs;
148  ++b;
149  ++bv;
150  }
151 
152  return *this;
153 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
BufferSelection & Nsound::BufferSelection::operator^= ( const float64 rhs)

Definition at line 158 of file BufferSelection.cc.

159 {
161  Buffer::iterator b_end = this->target_buffer_->end();
162 
163  BooleanVector::iterator bv = this->bv_.begin();
164  BooleanVector::iterator bv_end = this->bv_.end();
165 
166  while(b != b_end && bv != bv_end)
167  {
168  if(*bv) std::pow(*b, rhs);
169  ++b;
170  ++bv;
171  }
172 
173  return *this;
174 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
BufferSelection & Nsound::BufferSelection::operator= ( const float64 rhs)

Definition at line 179 of file BufferSelection.cc.

180 {
182  Buffer::iterator b_end = this->target_buffer_->end();
183 
184  BooleanVector::iterator bv = this->bv_.begin();
185  BooleanVector::iterator bv_end = this->bv_.end();
186 
187  while(b != b_end && bv != bv_end)
188  {
189  if(*bv) *b = rhs;
190  ++b;
191  ++bv;
192  }
193 
194  return *this;
195 }
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
FloatVector::iterator iterator
Definition: Buffer.h:69
void Nsound::BufferSelection::set ( const float64 rhs)
inline

Definition at line 87 of file BufferSelection.h.

87 {this->operator=(rhs);};
BufferSelection & operator=(const BufferSelection &rhs)

Member Data Documentation

Buffer* Nsound::BufferSelection::target_buffer_
protected

Definition at line 87 of file BufferSelection.h.

Referenced by operator=().

BooleanVector Nsound::BufferSelection::bv_
protected

Definition at line 92 of file BufferSelection.h.

Referenced by operator=().


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