Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
PdMaster.h
1 /*
2  PdMaster.cpp
3  Pd++
4 
5  Created by Robert Esler on 9/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 
13 /*! \namespace pd
14  \brief The Pd++ namespace
15  */
16 namespace pd {;}
17 
18 /*! \namespace rwe
19  \brief Personal namespace. Use intials for your own classes.
20  */
21 namespace rwe {;}
22 
23 #ifndef Pd___PdMaster_h
24 #define Pd___PdMaster_h
25 #define BLOCKSIZE 64
26 #define PD_FLOATUINTTYPE unsigned int
27 #include <cstdio>
28 #include <limits>
29 #include <cstring>
30 #include <errno.h>
31 
32 #ifdef _WIN32
33  #include <process.h>
34  #include <io.h>
35 #else
36  #include <libproc.h>
37  #include <unistd.h>
38 #endif
39 
40 #include <string>
41 #include <cmath>
42 #include "UnitGenerator.h"
43 #include <cstdlib>
44 
45 /*! \brief Input and output struct for PdAlgorithm. */
46 typedef struct {
47 
48  float inbuf1;
49  float inbuf2;
50  float outbufL; //stereo output
51  float outbufR;
52 } Buffer;
53 
54 /*! \brief A struct returned by complex filters. */
55 struct complexOutput {
56  double real;
57  double imaginary;
58 };
59 
60 
61 /*! \brief A super class inherited by all Pd++ objects*/
62 class PdMaster {
63 
64  friend class paRender;
65 
66 private:
67  unsigned long samplerate = 44100;
68  int blocksize = BLOCKSIZE;
69  double timeInSampleTicks; // 1/SR
70  double timeInMilliSeconds; //(T/1000 * SR)
71  int fftWindowSize = 64;
72  std::string pdName = "PdMaster";
73 
74 public:
75 
76  /*Not sure if I need these unions any more...*/
77  typedef union _sampleint_union {
78  float f;
79  PD_FLOATUINTTYPE i;
81 
82  union tabfudge
83  {
84  double tf_d;
85  int32_t tf_i[2];
86  };
87 
88  int cosTableSize = COSTABSIZE;
89  float *cos_table; //not sure I need this anymore
90  void *getbytes(size_t nbytes);
91  void *resizebytes(void *old, size_t oldsize, size_t newsize);
92  void freebytes(void *fatso, size_t nbytes);
93  /*This returns the path of your executable. Unix-based OS only.*/
94  std::string getPath();
95 
96  void setSampleRate(unsigned long);
97  unsigned long getSampleRate();
98  void setBlockSize(int);
99  int getBlockSize();
100 
101  /*Converts samples into ms.*/
102  double getTimeInSampleTicks();
103  /*Converts milliseconds into samples/ms*/
104  long getTimeInMilliSeconds(double time);
105 
106  /* A denormaling routine using C++'s numerics.*/
107  int pdBigOrSmall(double f);
108 
109  /*Not sure I need this anymore*/
110  void cos_maketable();
111 
112  /* Pure Data's denormaling routine*/
113  int PD_BIGORSMALL(float f);
114 
115  void setFFTWindow(int);
116  int getFFTWindow();
117 
118  /*acoustic conversions live here*/
119  double mtof(double); // MIDI note number to frequency
120  double ftom(double); // Frequency to MIDI note number
121  double powtodb(double);
122  double dbtopow(double);
123  double rmstodb(double); // RMS (e.g 0-1) to dB (0-100)
124  double dbtorms(double);
125 
126 
127 };
128 
129 
130 #endif
int pdBigOrSmall(double f)
Definition: PdMaster.cpp:86
The Pd++ namespace.
Definition: BandPass.cpp:14
double getTimeInSampleTicks()
Definition: PdMaster.cpp:69
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
double rmstodb(double)
Definition: PdMaster.cpp:238
double dbtorms(double)
Definition: PdMaster.cpp:252
void * getbytes(size_t nbytes)
Definition: PdMaster.cpp:96
Input and output struct for PdAlgorithm.
Definition: PdMaster.h:46
double ftom(double)
Definition: PdMaster.cpp:203
Definition: PdMaster.h:82
int PD_BIGORSMALL(float f)
Definition: PdMaster.cpp:147
long getTimeInMilliSeconds(double time)
Definition: PdMaster.cpp:77
Personal namespace. Use intials for your own classes.
Definition: CosineWave.cpp:18
void * resizebytes(void *old, size_t oldsize, size_t newsize)
Definition: PdMaster.cpp:113
void cos_maketable()
Definition: PdMaster.cpp:154
void freebytes(void *fatso, size_t nbytes)
Definition: PdMaster.cpp:133
Definition: PdMaster.h:77
double mtof(double)
Definition: PdMaster.cpp:189
A portaudio wrapper class, based on portaudio's example.
Definition: paRender++.h:52
double dbtopow(double)
Definition: PdMaster.cpp:223
A struct returned by complex filters.
Definition: PdMaster.h:55
std::string getPath()
Definition: PdMaster.cpp:26
double powtodb(double)
Definition: PdMaster.cpp:209