Nsound  0.9.4
AudioStreamSelection.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: AudioStreamSelection.cc 912 2015-07-26 00:50:29Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2004-2007 Nick Hilton
11 //
12 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 //-----------------------------------------------------------------------------
15 
16 //-----------------------------------------------------------------------------
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 //-----------------------------------------------------------------------------
33 
34 #include <Nsound/AudioStream.h>
35 #include <Nsound/Buffer.h>
36 
37 using namespace Nsound;
38 
42  :
43  target_as_(&as),
44  bv_(bv)
45 {
46 }
47 
51  :
52  target_as_(copy.target_as_),
53  bv_(copy.bv_)
54 {
55 }
56 
61 {
62  if(this == & rhs)
63  {
64  return *this;
65  }
66 
67  target_as_ = rhs.target_as_;
68  bv_ = rhs.bv_;
69  return *this;
70 }
71 
72 
76 operator+=(const float64 & rhs)
77 {
78  uint32 n_channels = target_as_->getNChannels();
79  uint32 n_bv = static_cast<uint32>(bv_.size());
80 
81  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
82  {
83  (*target_as_)[i](bv_[i]) += rhs;
84  }
85 
86  return *this;
87 }
88 
92 operator-=(const float64 & rhs)
93 {
94  uint32 n_channels = target_as_->getNChannels();
95  uint32 n_bv = static_cast<uint32>(bv_.size());
96 
97  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
98  {
99  (*target_as_)[i](bv_[i]) -= rhs;
100  }
101 
102  return *this;
103 }
104 
106 Nsound::
108 operator*=(const float64 & rhs)
109 {
110  uint32 n_channels = target_as_->getNChannels();
111  uint32 n_bv = static_cast<uint32>(bv_.size());
112 
113  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
114  {
115  (*target_as_)[i](bv_[i]) *= rhs;
116  }
117 
118  return *this;
119 }
120 
122 Nsound::
124 operator/=(const float64 & rhs)
125 {
126  uint32 n_channels = target_as_->getNChannels();
127  uint32 n_bv = static_cast<uint32>(bv_.size());
128 
129  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
130  {
131  (*target_as_)[i](bv_[i]) /= rhs;
132  }
133 
134  return *this;
135 }
136 
138 Nsound::
140 operator^=(const float64 & rhs)
141 {
142  uint32 n_channels = target_as_->getNChannels();
143  uint32 n_bv = static_cast<uint32>(bv_.size());
144 
145  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
146  {
147  (*target_as_)[i](bv_[i]) ^= rhs;
148  }
149 
150  return *this;
151 }
152 
154 Nsound::
156 operator=(const float64 & rhs)
157 {
158  uint32 n_channels = target_as_->getNChannels();
159  uint32 n_bv = static_cast<uint32>(bv_.size());
160 
161  for(uint32 i = 0; i < n_channels && i < n_bv; ++i)
162  {
163  (*target_as_)[i](bv_[i]) = rhs;
164  }
165 
166  return *this;
167 }
168 
unsigned int uint32
Definition: Nsound.h:153
AudioStreamSelection & operator*=(const float64 &rhs)
AudioStreamSelection & operator^=(const float64 &rhs)
double float64
Definition: Nsound.h:146
AudioStreamSelection(AudioStream &as, const BooleanVectorVector &bv)
std::vector< std::vector< boolean > > BooleanVectorVector
AudioStreamSelection & operator-=(const float64 &rhs)
AudioStreamSelection & operator/=(const float64 &rhs)
AudioStreamSelection & operator+=(const float64 &rhs)
AudioStreamSelection & operator=(const AudioStreamSelection &rhs)
A helper class for advance operators.