/usr/include/SndObj/SndObj.h is in libsndobj-dev 2.6.6.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
////////////////////////////////////////////////////////////////////////
// This file is part of the SndObj library
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Copyright (c)Victor Lazzarini, 1997-2004
// See License.txt for a disclaimer of all warranties
// and licensing information
//************************************************************//
// SndObj.h: Interface of the SndObj base class //
// //
// //
// //
//************************************************************//
#ifndef _SNDOBJ_H
#define _SNDOBJ_H
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#ifndef WIN
#include <unistd.h>
#endif
using namespace std;
class SndIO;
const double PI = 4.*atan(1.);
const int DEF_FFTSIZE = 1024;
const int DEF_VECSIZE = 256;
const float DEF_SR = 44100.f;
struct msg_link {
string msg;
int ID;
msg_link *previous;
};
class SndObj {
protected:
float* m_output; // output samples
SndObj* m_input; // input object
float m_sr; // sampling rate
int m_vecsize; //vector size
int m_vecpos; // vector pos counter
int m_vecsize_max; // for limiting operation
int m_altvecpos; // secondary counter
int m_error; // error code
short m_enable; // enable object
msg_link *m_msgtable;
inline int FindMsg(char* mess);
void AddMsg(const char* mess, int ID);
#if defined (WIN) && !defined(GCC)
int Ftoi(float x){
union {
float f;
int i;
} u;
unsigned int tmp;
unsigned char tmp2;
u.f = x;
tmp2 = (unsigned char) 158 - (unsigned char) (((int) u.i & 0x7F800000) >> 23);
if (tmp2 & (unsigned char) 0xE0)
return (unsigned int) 0;
tmp = (unsigned int) u.i | (unsigned int) 0xFF800000UL;
tmp = (tmp << 8) >> tmp2;
return (u.i < (int) 0 ? -((int) tmp) : (int) tmp);
}
int Ftoi(double fval){
int temp;
short oldcw;
short tempcw;
_asm {
fnstcw oldcw /*save current control reg*/
wait
mov ax,oldcw
or ah,0Ch /*set truncation mode */
mov tempcw,ax
fldcw tempcw
fld fval /*do the conversion... */
fistp temp
fldcw oldcw /*restore register */
mov eax,temp /* = "return temp;" */
}
return temp;
}
#else
int Ftoi(float fval) { return (int) fval; }
int Ftoi(double fval) { return (int) fval; }
#endif
public:
bool IsProcessing() {
if(m_vecpos && m_vecpos != m_vecsize) return true;
else return false;
}
int GetError() { return m_error; }
#ifndef SWIGJAVA
SndObj operator=(SndObj obj){
if(&obj == this) return *this;
for(int n = 0; n < m_vecsize; n++) m_output[n] = obj.Output(n);
return *this;
}
SndObj& operator+=(SndObj& obj){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]+obj.Output(n);
return *this;
}
SndObj& operator-=(SndObj& obj){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]-obj.Output(n);
return *this;
}
SndObj& operator*=(SndObj& obj){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]*obj.Output(n);
return *this;
}
SndObj& operator+=(float val){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]+val;
return *this;
}
SndObj& operator-=(float val){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]-val;
return *this;
}
SndObj& operator*=(float val){
for(int n = 0; n < m_vecsize; n++) m_output[n] = m_output[n]*val;
return *this;
}
SndObj operator+(SndObj& obj){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]+obj.Output(n);
return temp;
}
SndObj operator-(SndObj& obj){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]-obj.Output(n);
return temp;
}
SndObj operator*(SndObj& obj){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]*obj.Output(n);
return temp;
}
SndObj operator+(float val){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]+val;
return temp;
}
SndObj operator-(float val){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]-val;
return temp;
}
SndObj operator*(float val){
SndObj temp(0, m_vecsize, m_sr);
for(int n = 0; n < m_vecsize; n++) temp.m_output[n] = m_output[n]*val;
return temp;
}
void operator<<(float val){
if(m_vecpos >= m_vecsize) m_vecpos=0;
m_output[m_vecpos++] = val;
}
void operator<<(float* vector){
for(m_vecpos=0;m_vecpos<m_vecsize;m_vecpos++)
m_output[m_vecpos] = vector[m_vecpos];
}
void operator>>(SndIO& out);
void operator<<(SndIO& in);
#endif
int PushIn(float *vector, int size){
for(int i = 0; i<size; i++){
if(m_vecpos >= m_vecsize) m_vecpos = 0;
m_output[m_vecpos++] = vector[i];
}
return m_vecpos;
}
int PopOut(float *vector, int size){
for(int i = 0; i<size; i++){
if(m_altvecpos >= m_vecsize) m_altvecpos = 0;
vector[i] = m_output[m_altvecpos++];
}
return m_altvecpos;
}
int AddOut(float *vector, int size){
for(int i = 0; i<size; i++){
if(m_altvecpos >= m_vecsize) m_altvecpos = 0;
vector[i] += m_output[m_altvecpos++];
}
return m_altvecpos;
}
void GetMsgList(string* list);
void Enable(){ m_enable = 1; }
void Disable(){ m_enable = 0; }
float Output(int pos){ return m_output[pos%m_vecsize];}
int GetVectorSize() { return m_vecsize; }
void SetVectorSize(int vecsize);
void LimitVectorSize(int limit) {
if(limit <= m_vecsize_max)
m_vecsize = limit;
}
void RestoreVectorSize(){ m_vecsize = m_vecsize_max; }
float GetSr(){ return m_sr;}
virtual void SetSr(float sr){ m_sr = sr;}
virtual int Set(char* mess, float value);
virtual int Connect(char* mess, void* input);
void SetInput(SndObj* input){
m_input = input;
}
SndObj* GetInput(){ return m_input; }
SndObj(SndObj* input, int vecsize = DEF_VECSIZE, float sr = DEF_SR);
SndObj();
#if !defined (SWIGPYTHON) && !defined(SWIGCFFI)
SndObj(SndObj& obj);
#endif
virtual ~SndObj();
virtual char* ErrorMessage();
virtual const char* CErrorMessage();
virtual short DoProcess();
};
int
SndObj::FindMsg(char* mess){
msg_link* iter = m_msgtable;
while(iter->previous && iter->msg.compare(mess))
iter = iter->previous;
if(!iter->msg.compare(mess)) return iter->ID;
else return 0;
}
#endif
|