Nsound  0.9.4
Pulse.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: Pulse.h 875 2014-09-27 22:25:13Z 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) 2010-Present 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_PULSE_H_
34 #define _NSOUND_PULSE_H_
35 
36 #include <Nsound/Generator.h>
37 
38 namespace Nsound
39 {
40 
41 class Buffer;
42 
43 //-----------------------------------------------------------------------------
45 //
50 class Pulse : public Generator
51 {
52  public:
53 
55  {
57  PULSE_PERCENT, // percentage of wavelength
58  };
59 
61  //
66  Pulse(
67  const float64 & sample_rate,
68  const float64 & pulse_width,
69  const PulseUnits & units = PULSE_PERCENT);
70 
71  ~Pulse();
72 
74  //
77  void
78  setUnits(const PulseUnits & units)
79  {units_ = units;};
80 
82  //
86  float64
87  generate(const float64 & frequency);
88 
90  //
96  float64
97  generate2(
98  const float64 & frequency,
99  const float64 & pulse_width);
100 
101  using Generator::generate;
102 
103  Buffer
104  generate2(
105  const float64 & duration,
106  const float64 & frequency,
107  const float64 & pulse_width);
108 
110  Buffer
112  const float64 & duration,
113  const float64 & frequency,
114  const float64 & pulse_width){return Buffer();};
115 
117  Buffer
119  const float64 & duration,
120  const float64 & frequency,
121  const Buffer & pulse_widths){return Buffer();};
122 
124  Buffer
126  const float64 & duration,
127  const Buffer & frequencies,
128  const Buffer & pulse_widths){return Buffer();};
129 
131  Buffer
133  const float64 & duration,
134  const float64 & frequency,
135  const Buffer & pulse_width){return Buffer();};
136 
138  Buffer
140  const float64 & duration,
141  const Buffer & frequency,
142  const float64 & pulse_width){return Buffer();};
143 
145  Buffer
147  const float64 & duration,
148  const Buffer & frequency,
149  const Buffer & pulse_width){return Buffer();};
150 
151  void reset();
152 
154  {return rise_t_;};
155 
157  {return fall_t_;};
158 
159  protected:
160 
161  float64 rise_t_;
165 
166 };
167 
168 };
169 
170 #endif
171 
172 // :mode=c++: jEdit modeline
A Pulse Generator.
Definition: Pulse.h:50
PulseUnits units_
The default pulse width to use.
Definition: Pulse.h:164
Buffer generate2(const float64 &duration, const float64 &frequency, const Buffer &pulse_width)
This does nothing for now.
Definition: Pulse.h:132
float64 generate(const float64 &frequency)
This is a real-time method for the Pulse generator.
Definition: Pulse.cc:61
void setUnits(const PulseUnits &units)
Sets the PulseUnits to units for this Pulse Generator.
Definition: Pulse.h:78
float64 pulse_width_
The falling edge time for the pulse.
Definition: Pulse.h:163
float64 fallTime()
Definition: Pulse.h:156
Buffer generate(const float64 &duration, const float64 &frequency, const Buffer &pulse_widths)
This does nothing for now.
Definition: Pulse.h:118
Buffer generate2(const float64 &duration, const Buffer &frequency, const Buffer &pulse_width)
This does nothing for now.
Definition: Pulse.h:146
float64 riseTime()
Definition: Pulse.h:153
double float64
Definition: Nsound.h:146
void reset()
Resets the position pointer back to the begging of the waveform.
Definition: Pulse.cc:110
float64 fall_t_
The rising edge time for the pulse.
Definition: Pulse.h:162
Buffer generate(const float64 &duration, const float64 &frequency, const float64 &pulse_width)
This does nothing for now.
Definition: Pulse.h:111
virtual float64 generate(const float64 &frequency)
This is a real-time method for the wavetable oscillator.
Definition: Generator.cc:972
float64 generate2(const float64 &frequency, const float64 &pulse_width)
This is a real-time method for the Pulse generator.
Definition: Pulse.cc:68
Pulse(const float64 &sample_rate, const float64 &pulse_width, const PulseUnits &units=PULSE_PERCENT)
Creates a new Pulse Generator.
Definition: Pulse.cc:42
A Buffer for storing audio samples.
Definition: Buffer.h:60
float64 rise_t_
Definition: Pulse.h:157
Buffer generate(const float64 &duration, const Buffer &frequencies, const Buffer &pulse_widths)
This does nothing for now.
Definition: Pulse.h:125
Buffer generate2(const float64 &duration, const Buffer &frequency, const float64 &pulse_width)
This does nothing for now.
Definition: Pulse.h:139
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50