OpenWareLaboratory
PolyBlepOscillator.h
Go to the documentation of this file.
1 #ifndef __PolyBlepOscillator_h__
2 #define __PolyBlepOscillator_h__
3 
4 #include "FloatArray.h"
5 #include "polyblep/dsp/oscillator.h"
6 #include "Oscillator.h"
7 
8 class PolyBlepOscillator : public Oscillator {
9 private:
10  float mul;
11  stmlib::Oscillator osc;
12  float nfreq, shape, pw;
13 public:
14  PolyBlepOscillator(float sr=48000);
15  PolyBlepOscillator(float freq, float sr);
16  void setSampleRate(float sr);
17  float getSampleRate();
18  void setFrequency(float freq);
19  float getFrequency();
21  void setShape(float value);
22  float getShape();
24  void setPulseWidth(float value);
25  float getPulseWidth();
26  void setPhase(float phase);
27  float getPhase();
28  void reset(){
29  setPhase(0);
30  }
31  float generate();
32  float generate(float fm);
33  /* put a block of output samples into @param output */
34  void generate(FloatArray output);
35  /* put a block of output samples into @param output, frequency modulated by @param fm */
36  void generate(FloatArray output, FloatArray fm);
37  /* put a block of output samples into @param samples,
38  with frequency determined by samples in @param frequency */
39  void getSamples(FloatArray output, FloatArray freq);
40  static PolyBlepOscillator* create(float sr);
41  static PolyBlepOscillator* create(float freq, float sr);
42  static void destroy(PolyBlepOscillator* osc);
43 };
44 
45 #endif /* __PolyBlepOscillator_h__ */
This class contains useful methods for manipulating arrays of floats.
Definition: FloatArray.h:12
An Oscillator is a SignalGenerator that operates at a given frequency and that can be frequency modul...
Definition: Oscillator.h:12
static PolyBlepOscillator * create(float sr)
void setFrequency(float freq)
Set oscillator frequency in Hertz.
void reset()
Reset oscillator (typically resets phase)
void getSamples(FloatArray output, FloatArray freq)
float generate()
Produce the next consecutive sample.
PolyBlepOscillator(float sr=48000)
float getPhase()
Get current oscillator phase in radians.
static void destroy(PolyBlepOscillator *osc)
void setSampleRate(float sr)
Set oscillator sample rate.
float getFrequency()
Get oscillator frequency in Hertz.
void setPhase(float phase)
Set current oscillator phase in radians.
void setShape(float value)
set waveform shape: 0.0 for saw, 1.0 for square wave
void setPulseWidth(float value)
set square wave pulse width: 0.0 to 1.0 for 0% to 100%