Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
VoltageControlFilter.h
1 /*
2  VoltageControlFilter.cpp
3  Pd++
4 
5  Created by Robert Esler on 10/16/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 #ifndef __Pd____VoltageControlFilter__
13 #define __Pd____VoltageControlFilter__
14 
15 #include <string>
16 #include "PdMaster.h"
17 
18 namespace pd {
19 
20 /*! \brief A struct returned by VoltageControlFilter. */
21 
22 struct vcfOutput {
23  double real;
24  double imaginary;
25 };
26 
27 /*! \brief Voltage-controlled filter.
28 
29  This is a voltage controlled filter which is basically a bandpass filter that can
30  use a signal generator such as an oscillator or a phasor to control the center
31  frequency. The Q can be set using the setQ() method. Since we are not using the
32  same scheduling routine as Pd the Q can also technically use a signal as an input.
33 
34  The other major difference between this and bandpass is that vcf uses the same cosine table lookup
35  as the unit generators to calculate the real and imaginary coefficients.
36 
37  Also, notice that the perform() function returns a struct which is a pair of doubles
38  that correspond to the real and imaginary part. You'll have handle this in your run() function.
39  Normally, I either sum the two or ignore the imaginary part (I don't really believe in imaginary
40  numbers.)
41 
42 */
43 
44 
45 
47 
48 private:
49 
50  typedef struct vcfctl
51  {
52  float c_re;
53  float c_im;
54  float c_q;
55  float c_isr;
56  } t_vcfctl;
57 
58  typedef struct sigvcf
59  {
60  t_vcfctl x_cspace;
61  t_vcfctl *x_ctl;
62  float x_f;
63  } t_sigvcf;
64 
65  float *cos_table_vcf = nullptr;
66  void cos_maketable_vcf();
67  t_sigvcf *x = new t_sigvcf;
68 
69 public:
70 
72  VoltageControlFilter(double q);
74  vcfOutput perform(double input, double centerFrequency);
75  void setQ(double f);
76 
77 
78  std::string pdName = "vcf~";
79 };
80 
81 } // pd namespace
82 #endif /* defined(__Pd____VoltageControlFilter__) */
The Pd++ namespace.
Definition: BandPass.cpp:14
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
Voltage-controlled filter.
Definition: VoltageControlFilter.h:46
A struct returned by VoltageControlFilter.
Definition: VoltageControlFilter.h:22