Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Envelope.h
1 //
2 // Envelope.hpp
3 // Pd++
4 //
5 // Created by Robert Esler on 11/8/16.
6 // Copyright © 2016 Robert Esler. All rights reserved.
7 //
8 
9 #ifndef Envelope_h
10 #define Envelope_h
11 
12 #define MAXOVERLAP 32
13 #define INITVSTAKEN 64
14 
15 #include <iostream>
16 #include <string.h>
17 #include <math.h>
18 #include "PdMaster.h"
19 
20 namespace pd {
21 
22 /*! \brief A simple envelope follower with Hanning window.
23  Use setWindowSize() and setPeriod() the window size and period. The
24  period should be a multipe of the window size.
25 */
26 
27 class Envelope : public PdMaster {
28 
29 private:
30 
31  //I'm going to keep most of the struct as is from Pd's code.
32  typedef struct sigenv
33  {
34  double *x_buf; /* a Hanning window */
35  int x_phase; /* number of points since last output */
36  int x_period; /* requested period of output */
37  int x_realperiod; /* period rounded up to vecsize multiple */
38  int x_npoints; /* analysis window size in samples */
39  double x_result; /* result to output */
40  double x_sumbuf[MAXOVERLAP]; /* summing buffer */
41  double x_f;
42  int x_allocforvs; /* extra buffer for DSP vector size */
43  } t_sigenv;
44 
45  int windowSize = 1024;
46  int period = windowSize/2;
47  t_sigenv *x;
48 
49 public:
50  Envelope();
51  ~Envelope();
52  Envelope(int ws, int p);
53  double perform(double input);
54  //setters
55  void setWindowSize(int ws);
56  void setPeriod(int p);
57  //getters
58  int getWindowSize() {return windowSize;};
59  int getPeriod() {return period;};
60  std::string pdName = "env~";
61 };
62 
63 }//namespace pd
64 #endif /* Envelope_hpp */
The Pd++ namespace.
Definition: BandPass.cpp:14
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
A simple envelope follower with Hanning window. Use setWindowSize() and setPeriod() the window size a...
Definition: Envelope.h:27
void setWindowSize(int ws)
Definition: Envelope.cpp:112
void setPeriod(int p)
Definition: Envelope.cpp:126