Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Oscillator.h
1 /*
2  Oscillator.cpp
3  Pd++
4 
5  Created by Robert Esler on 10/15/14.
6  Copyright (c) 2014 Robert Esler. All rights reserved.
7 
8  Some of the code in Pd++ is Copyright (c) 1997-1999 Miller Puckette.
9  For information on usage and redistribution, and for a DISCLAIMER OF ALL
10  WARRANTIES, see the file, "LICENSE.txt," in this distribution.
11  */
12 
13 #ifndef __Pd____Oscillator__
14 #define __Pd____Oscillator__
15 
16 #include <string>
17 #include "PdMaster.h"
18 #include "UnitGenerator.h"
19 
20 namespace pd {
21 
22 /*! \brief A sinewave oscillator.
23 
24  This is Pd's sinewave oscillator, though technically a cosine. It basically wraps the
25  phasor into the cosine function. It also uses a cosine lookup table.
26 
27  You can set the phase using the setPhase(double) function. It should be a number from 0-1.
28  Just make sure to update the phase outside of the runAlgorithm() routine.
29 
30 */
31 
32 class Oscillator : public PdMaster {
33 
34 private:
35  typedef struct _osc
36  {
37  double x_phase;
38  float x_conv;
39  float x_f; /* frequency if scalar */
40  } t_osc;
41 
42  float *cos_table_osc = nullptr;
43  void setConv();
44  double getConv();
45  void cos_maketable_osc();
46  void osc_new();
47  t_osc *x = new t_osc;
48 
49 public:
50 
51  Oscillator();
52  Oscillator(double);
53  ~Oscillator();
54 
55  double perform(double frequency);
56  void setPhase(double phase);
57 
58  std::string pdName = "osc~";
59 
60 };
61 
62 } // pd namespace
63 #endif /* defined(__Pd____Oscillator__) */
A sinewave oscillator.
Definition: Oscillator.h:32
The Pd++ namespace.
Definition: BandPass.cpp:14
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62