Nsound  0.9.4
Nsound.h
Go to the documentation of this file.
1 //
3 // $Id: Nsound.h.in 875 2014-09-27 22:25:13Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2004, 2005 Nick Hilton
11 //
12 // weegreenblobbie_at_yahoo_com
13 //
15 
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
33 #ifndef _NSOUND_H_
34 #define _NSOUND_H_
35 
36 #define PACKAGE_NAME "Nsound"
37 
38 #define NSOUND_AUTHORS "Nick Hilton"
39 #define NSOUND_COPYRIGHT "Copyright 2004 - Present, Nick Hilton et al."
40 
41 #define NSOUND_VERSION_A 0
42 #define NSOUND_VERSION_B 9
43 #define NSOUND_VERSION_C 4
44 
45 #define PACKAGE_VERSION "0.9.4"
46 #define PACKAGE_RELEASE "Nsound-0.9.4"
47 
48 // endianess
49 #define NSOUND_LITTLE_ENDIAN
50 
51 // Platform
52 #define NSOUND_PLATFORM_OS_LINUX
53 
54 // Build python module?
55 #define NSOUND_IN_PYTHON_MODULE 1
56 
57 // 64 bit floats enabled?
58 #define NSOUND_64_BIT 1
59 
60 // Sample size
61 #define NSOUND_SAMPLE_SIZE sizeof(float64)
62 
63 // M_PI macro
64 // M_PI is defined in math.h
65 
66 // Define if we have lib portaudio available
67 #define NSOUND_LIBPORTAUDIO 1
68 
69 // Define if we have lib ao available
70 #define NSOUND_LIBAO 1
71 
72 // Define if we have Python module pylab (matplotlib) C API
73 #define NSOUND_C_PYLAB 1
74 
75 // Ensure Python.h is included before anything else.
76 #if defined(NSOUND_C_PYLAB) || defined(NSOUND_IN_PYTHON_MODULE)
77 
78  #ifdef __clang__
79  #pragma clang diagnostic push
80  #pragma clang diagnostic ignored "-Wdeprecated"
81  #pragma clang diagnostic ignored "-Wdeprecated-register"
82  #endif
83 
84  #include <Python.h>
85 
86  #ifdef __clang__
87  #pragma clang diagnostic pop
88  #endif
89 
90 #endif
91 
92 // OpenMP usage
93 #undef NSOUND_OPENMP // disabled
94 
95 #ifdef NSOUND_OPENMP
96  #include <omp.h>
97 #endif
98 
99 // C++11
100 #define NSOUND_CPP11 1
101 
102 // Cuda usage
103 #undef NSOUND_CUDA // disabled
104 
105 #ifdef NSOUND_CUDA
106  #include <cuda.h>
107 #endif
108 
109 // C++ headers
110 #include <exception>
111 #include <iostream>
112 #include <sstream>
113 #include <string>
114 #include <vector>
115 #include <set>
116 
117 // C header
118 #include <math.h>
119 
120 #ifndef M_PI
121  #define M_PI 3.141592653589793
122 #endif
123 
124 //#ifndef SWIG
125 // extern "C++" {
126 //#endif
127 
129 // Basic types
130 
131 namespace Nsound
132 {
133 
134 // setup boolean type
135 typedef bool boolean;
136 
137 // Signed types
138 
139 typedef signed char byte;
140 typedef signed char int8;
141 typedef signed short int16;
142 typedef signed int int32;
143 typedef signed long long int64;
144 
145 typedef float float32;
146 typedef double float64;
147 
148 // unsigned types
149 
150 typedef unsigned char ubyte;
151 typedef unsigned char uint8;
152 typedef unsigned short uint16;
153 typedef unsigned int uint32;
154 typedef unsigned long long uint64;
155 
156 // Always declare these 64 bit types for use with Wavefiles
157 typedef signed long long raw_int64;
158 typedef unsigned long long raw_uint64;
159 typedef double raw_float64;
160 
161 
162 // A C++ exception class so our routines can raise exceptions.
163 struct Exception : public std::exception
164 {
165  Exception(const std::string & message) : _message(message){};
166 
167  ~Exception() throw() {};
168 
169  const char * what() const throw(){ return _message.c_str(); };
170 
171  private:
172 
173  std::string _message;
174 };
175 
176 }; // namespace
177 
178 
180 // Macros
181 
182 // FIXME need to move these to Macros.h and prefix with M_
183 
184 #define LINE_PREFIX __FILE__ << ":" << __LINE__ << ": "
185 #define ERROR_HEADER __FILE__ << ":" << __LINE__ << ": ***ERROR: "
186 #define WARNING_HEADER __FILE__ << ":" << __LINE__ << ": ***WARNING: "
187 
188 #include <Nsound/Macros.h>
189 
190 //#ifndef SWIG
191 // }; //extern "C++" {
192 //#endif
193 
194 #endif
195 
196 // :mode=c++: jEdit modeline
unsigned int uint32
Definition: Nsound.h:153
bool boolean
Definition: Nsound.h:135
unsigned char uint8
Definition: Nsound.h:151
unsigned char ubyte
Definition: Nsound.h:150
signed char byte
Definition: Nsound.h:139
double float64
Definition: Nsound.h:146
Exception(const std::string &message)
Definition: Nsound.h:165
const char * what() const
Definition: Nsound.h:169
signed char int8
Definition: Nsound.h:140
signed short int16
Definition: Nsound.h:141
signed long long raw_int64
Definition: Nsound.h:157
unsigned long long uint64
Definition: Nsound.h:154
unsigned long long raw_uint64
Definition: Nsound.h:158
signed int int32
Definition: Nsound.h:142
std::string _message
Definition: Nsound.h:169
double raw_float64
Definition: Nsound.h:159
float float32
Definition: Nsound.h:145
signed long long int64
Definition: Nsound.h:143
unsigned short uint16
Definition: Nsound.h:152