Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Cosine.h
1 /*
2  Cosine.cpp
3  Pd++
4 
5  Created by Robert Esler on 9/27/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____Cosine2__
14 #define __Pd____Cosine2__
15 
16 #include "PdMaster.h"
17 #include "UnitGenerator.h"
18 #include <string>
19 
20 namespace pd {
21 
22 /*!
23  \class Cosine
24  \brief A cosine waveshaper.
25 
26  Cosine outputs the cosine of two pi times the input. Use this with Phasor
27  and you will get a cosine wave.
28 
29 */
30 
31 
32 
33 
34 class Cosine : public PdMaster {
35 
36 private:
37  float *cos_table = nullptr;
38  int globalCounter = 0;
39  int sawtooth = 0;
40 
41  union tabfudge
42  {
43  double tf_d;
44  int32_t tf_i[2];
45  };
46 
47  typedef struct _cos
48  {
49  float x_f;
50  } t_cos;
51 
52  t_cos *x = new t_cos;
53  void cos_new(); //This is just borrowed straight from the Pd code,
54  // it could be wrapped into the constructor.
55 
56 public:
57 
58  Cosine();
59  ~Cosine();
60 
61  double perform(double );
62  void cos_maketable();
63 
64  const std::string pdName = "cos~";
65 
66 };
67 
68 } // pd namespace
69 #endif /* defined(__Pd____Cosine2__) */
The Pd++ namespace.
Definition: BandPass.cpp:14
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
A cosine waveshaper.
Definition: Cosine.h:34