Nsound  0.9.4
DelayLine.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: DelayLine.h 908 2015-07-08 02:04:41Z 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) 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 #ifndef _NSOUND_DELAY_LINE_H_
34 #define _NSOUND_DELAY_LINE_H_
35 
36 #include <Nsound/Nsound.h>
37 
38 #include <vector>
39 
40 namespace Nsound
41 {
42 
43 
44 class AudioStream;
45 class Buffer;
46 
47 
48 class DelayLine
49 {
50 
51 public:
52 
53  DelayLine(float64 sample_rate, float64 max_delay_in_seconds);
54 
55  void setRealtime(bool flag) {is_realtime_ = flag;}
56 
57  Buffer delay(const Buffer & x, const Buffer & delay_time);
58 
59  float64 delay(float64 x, float64 delay_time);
60 
61  float64 read();
63 
64  void write(float64 x);
65 
66  void reset(); // flushes internal state
67 
68 protected:
69 
73 
74  std::vector<float64> buffer_;
75 
77 
79 
80 private:
81 
82  DelayLine(const DelayLine & copy);
83  DelayLine & operator=(const DelayLine & rhs);
84 };
85 
86 
87 } // namespace
88 
89 
90 #endif
unsigned int uint32
Definition: Nsound.h:153
void setRealtime(bool flag)
Definition: DelayLine.h:55
float64 delay_time_
Definition: DelayLine.h:72
double float64
Definition: Nsound.h:146
float64 sample_rate_
Definition: DelayLine.h:70
std::vector< float64 > buffer_
Definition: DelayLine.h:74
DelayLine(float64 sample_rate, float64 max_delay_in_seconds)
Definition: DelayLine.cc:41
DelayLine & operator=(const DelayLine &rhs)
float64 read()
Definition: DelayLine.cc:97
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer delay(const Buffer &x, const Buffer &delay_time)
Definition: DelayLine.cc:58
float64 max_delay_time_
Definition: DelayLine.h:71
void write(float64 x)
Definition: DelayLine.cc:133