/[svn]/linuxsampler/trunk/src/common/RTMath.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/RTMath.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 617 by schoenebeck, Wed Jun 8 21:00:06 2005 UTC revision 829 by schoenebeck, Sat Jan 14 14:07:47 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 75  class RTMathBase { Line 75  class RTMathBase {
75              return pCentsToFreqTable[index_int] + index_fract * (pCentsToFreqTable[index_int+1] - pCentsToFreqTable[index_int]);              return pCentsToFreqTable[index_int] + index_fract * (pCentsToFreqTable[index_int+1] - pCentsToFreqTable[index_int]);
76          }          }
77    
78            /**
79             * Inverse function to CentsToFreqRatio(). This function is a bit
80             * slow, so it should not be called too frequently.
81             */
82            static double FreqRatioToCents(double FreqRatio) {
83                return log(FreqRatio) / log(TWELVEHUNDREDTH_ROOT_OF_TWO);
84            }
85    
86      private:      private:
87          static float  CentsToFreqTable[CONFIG_MAX_PITCH * 1200 * 2 + 1];          static float  CentsToFreqTable[CONFIG_MAX_PITCH * 1200 * 2 + 1];
88          static float* pCentsToFreqTable;          static float* pCentsToFreqTable;
# Line 95  class __RTMath : public RTMathBase { Line 103  class __RTMath : public RTMathBase {
103          // conversion using truncate          // conversion using truncate
104          inline static int Int(const float a) {          inline static int Int(const float a) {
105              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (int) a;  
                 }  
106                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
107                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
108                      int ret;                      int ret;
# Line 109  class __RTMath : public RTMathBase { Line 114  class __RTMath : public RTMathBase {
114                      return ret;                      return ret;
115                  }                  }
116                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
117                    default: {
118                        return (int) a;
119                    }
120              }              }
121          }          }
122    
# Line 119  class __RTMath : public RTMathBase { Line 127  class __RTMath : public RTMathBase {
127    
128          inline static float Float(const int a) {          inline static float Float(const int a) {
129              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (float) a;  
                 }  
130                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
131                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
132                      float ret;                      float ret;
# Line 134  class __RTMath : public RTMathBase { Line 139  class __RTMath : public RTMathBase {
139                      return ret;                      return ret;
140                  }                  }
141                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
142                    default: {
143                        return (float) a;
144                    }
145              }              }
146          }          }
147    
# Line 146  class __RTMath : public RTMathBase { Line 154  class __RTMath : public RTMathBase {
154    
155          inline static float Sum(const float& a, const float& b) {          inline static float Sum(const float& a, const float& b) {
156              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (a + b);  
                 }  
157                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
158                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
159                      float ret;                      float ret;
# Line 162  class __RTMath : public RTMathBase { Line 167  class __RTMath : public RTMathBase {
167                      return ret;                      return ret;
168                  }                  }
169                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
170                    default: {
171                        return (a + b);
172                    }
173              }              }
174          }          }
175    
# Line 171  class __RTMath : public RTMathBase { Line 179  class __RTMath : public RTMathBase {
179    
180          inline static float Sub(const float& a, const float& b) {          inline static float Sub(const float& a, const float& b) {
181              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (a - b);  
                 }  
182                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
183                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
184                      float ret;                      float ret;
# Line 187  class __RTMath : public RTMathBase { Line 192  class __RTMath : public RTMathBase {
192                      return ret;                      return ret;
193                  }                  }
194                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
195                    default: {
196                        return (a - b);
197                    }
198              }              }
199          }          }
200    
# Line 196  class __RTMath : public RTMathBase { Line 204  class __RTMath : public RTMathBase {
204    
205          inline static float Mul(const float a, const float b) {          inline static float Mul(const float a, const float b) {
206              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (a * b);  
                 }  
207                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
208                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
209                      float ret;                      float ret;
# Line 212  class __RTMath : public RTMathBase { Line 217  class __RTMath : public RTMathBase {
217                      return ret;                      return ret;
218                  }                  }
219                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
220                    default: {
221                        return (a * b);
222                    }
223              }              }
224          }          }
225    
# Line 221  class __RTMath : public RTMathBase { Line 229  class __RTMath : public RTMathBase {
229    
230          inline static float Div(const float a, const float b) {          inline static float Div(const float a, const float b) {
231              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (a / b);  
                 }  
232                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
233                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
234                      float ret;                      float ret;
# Line 237  class __RTMath : public RTMathBase { Line 242  class __RTMath : public RTMathBase {
242                      return ret;                      return ret;
243                  }                  }
244                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
245                    default: {
246                        return (a / b);
247                    }
248              }              }
249          }          }
250    
# Line 246  class __RTMath : public RTMathBase { Line 254  class __RTMath : public RTMathBase {
254    
255          inline static float Min(const float a, const float b) {          inline static float Min(const float a, const float b) {
256              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (b < a) ? b : a;  
                 }  
257                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
258                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
259                      float ret;                      float ret;
# Line 262  class __RTMath : public RTMathBase { Line 267  class __RTMath : public RTMathBase {
267                      return ret;                      return ret;
268                  }                  }
269                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
270                    default: {
271                        return std::min(a, b);
272                    }
273              }              }
274          }          }
275    
# Line 271  class __RTMath : public RTMathBase { Line 279  class __RTMath : public RTMathBase {
279    
280          inline static float Max(const float a, const float b) {          inline static float Max(const float a, const float b) {
281              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return (b > a) ? b : a;  
                 }  
282                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
283                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
284                      float ret;                      float ret;
# Line 287  class __RTMath : public RTMathBase { Line 292  class __RTMath : public RTMathBase {
292                      return ret;                      return ret;
293                  }                  }
294                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
295                    default: {
296                        return std::max(a, b);
297                    }
298              }              }
299          }          }
300    
# Line 296  class __RTMath : public RTMathBase { Line 304  class __RTMath : public RTMathBase {
304    
305          inline static float Fmodf(const float &a, const float &b) {          inline static float Fmodf(const float &a, const float &b) {
306              switch (IMPL) {              switch (IMPL) {
                 case CPP: {  
                     return fmodf(a, b);  
                 }  
307                  #if CONFIG_ASM && ARCH_X86                  #if CONFIG_ASM && ARCH_X86
308                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
309                      float ret;                      float ret;
# Line 319  class __RTMath : public RTMathBase { Line 324  class __RTMath : public RTMathBase {
324                      return ret;                      return ret;
325                  }                  }
326                  #endif // CONFIG_ASM && ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
327                    default: {
328                        return fmodf(a, b);
329                    }
330              }              }
331          }          }
332  };  };

Legend:
Removed from v.617  
changed lines
  Added in v.829

  ViewVC Help
Powered by ViewVC