Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
VariableDelay.h
1 /*
2  VariableDelay.h
3  Pd++
4 
5  Adapted from d_delay.c
6 
7  Created by Robert Esler on 10/27/14.
8 
9  Some of the code in Pd++ is Copyright (c) 1997-1999 Miller Puckette.
10  For information on usage and redistribution, and for a DISCLAIMER OF ALL
11  WARRANTIES, see the file, "LICENSE.txt," in this distribution.
12  */
13 
14 #ifndef __Pd____VariableDelay__
15 #define __Pd____VariableDelay__
16 
17 #include <stdio.h>
18 #include <string>
19 #include "PdMaster.h"
20 
21 #define XTRASAMPS 4
22 #define SAMPBLK 4
23 #define DEFDELVS 1 /* LATER get this from canvas at DSP time */
24 //static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
25 
26 namespace pd {
27 
28 /*! \brief Reads from a table at a variable delay rate.
29 
30  This is our variable delay class. You can use any signal to control the delay time,
31  or you can just use a number. This particular delay uses four point polynomial
32  interpolation which removes those pesky artefacts.
33 
34  This class also has a delayRead() function, comparable to the delread~ object. Check
35  the caution warning.
36 
37 */
38 
39 class VariableDelay : public PdMaster {
40 
41 private:
42 
43  /*for delwrite~*/
44  typedef struct delwritectl
45  {
46  int c_n;
47  double *c_vec;
48  int c_phase;
49  } t_delwritectl;
50 
51  typedef struct _sigdelwrite
52  {
53  double x_deltime; /* delay in msec (added by Mathieu Bouchard) */
54  t_delwritectl x_cspace;
55  int x_vecsize; /* vector size for vd~ to use */
56  double x_f;
57  } t_sigdelwrite;
58 
59  /*for delread~*/
60  typedef struct _sigdelread
61  {
62  double x_deltime; /* delay in msec */
63  int x_delsamps; /* delay in samples */
64  double x_sr; /* samples per msec */
65  double x_n; /* vector size */
66  int x_zerodel; /* 0 or vecsize depending on read/write order */
67  } t_sigdelread;
68 
69 
70  /*for vd~*/
71  typedef struct _sigvd
72  {
73  double x_sr; /* samples per msec */
74  int x_zerodel; /* 0 or vecsize depending on read/write order */
75  } t_sigvd;
76 
77  t_sigdelwrite *x = new t_sigdelwrite;
78  t_sigdelread *r = new t_sigdelread;
79  t_delwritectl *ctl = new t_delwritectl;
80  t_delwritectl *c = new t_delwritectl;
81  t_sigvd *vd = new t_sigvd;
82 
83  /*delwrite~ functions*/
84  void sigdelwrite_updatesr (double sr);
85  void sigdelwrite_new(double msec);
86 
87 
88 public:
89  VariableDelay();
90  VariableDelay(double); /*this sets the initial max delay, default is 1000 msecs*/
91  ~VariableDelay();
92 
93  /*write to the delay first*/
94  void delayWrite(double input);
95  double delayRead(double delayTime);
96 
97  /*vd perform function*/
98  double perform(double delayTime);
99 
100  std::string pdName = "vd~";
101 };
102 
103 
104 } // pd namespace
105 #endif /* defined(__Pd____VariableDelay__) */
The Pd++ namespace.
Definition: BandPass.cpp:14
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
double delayRead(double delayTime)
Definition: VariableDelay.cpp:122
Reads from a table at a variable delay rate.
Definition: VariableDelay.h:39