home *** CD-ROM | disk | FTP | other *** search
/ Cubase Magazine 30 / Issue #30.iso / pc / 2-SOFTWARE / RTEQ 3.0 / SRC / MISC.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-09  |  2.8 KB  |  68 lines

  1. /**********************************************************************************
  2. *                                                                                 *
  3. *    MISC.CPP: Includes some math routines not found in math.h                    *
  4. *                                                                                 *
  5. *    Copyright (C) 2000  Andrei Grecu                                             *
  6. *                                                                                 *
  7. *    This program is free software; you can redistribute it and/or modify         *
  8. *    it under the terms of the GNU General Public License as published by         *
  9. *    the Free Software Foundation; either version 2 of the License, or            *
  10. *    (at your option) any later version.                                          *
  11. *                                                                                 *
  12. *    This program is distributed in the hope that it will be useful,              *
  13. *    but WITHOUT ANY WARRANTY; without even the implied warranty of               *
  14. *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                *
  15. *    GNU General Public License for more details.                                 *
  16. *                                                                                 *
  17. *    You should have received a copy of the GNU General Public License            *
  18. *    along with this program; if not, write to the Free Software                  *
  19. *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    *
  20. *                                                                                 *
  21. *    If you have questions, bug reports regarding my code please contact me at:   *
  22. *    andrei.grecu@aon.at                                                          *
  23. *                                                                                 *
  24. *    Home page:                                                                   *
  25. *    http://members.aon.at/grxpage/index.htm                                      *
  26. *                                                                                 *
  27. **********************************************************************************/
  28.  
  29. #include "precomp.h"
  30. #include <math.h>
  31.  
  32. #include "misc.h"
  33.  
  34. long round(FLOAT x) {
  35.  
  36.     FLOAT y;
  37.  
  38.     if(x > 0) {
  39.         y = x - int(x);
  40.         if(y >= 0.5) return((long)ceil(x));
  41.         if(y < 0.5) return((long)floor(x));
  42.     }
  43.     else {
  44.         y = int(x) - x;
  45.         if(y >= 0.5) return((long)floor(x));
  46.         if(y < 0.5) return((long)ceil(x));
  47.     }
  48.  
  49.     return(0);
  50.  
  51. }
  52.  
  53. signed long band_pass(signed long x) {
  54.  
  55.     if(x > 32767) return(32767);
  56.     else if(x < -32767) return(-32767);
  57.     else return(x);
  58.  
  59. }
  60.  
  61. FLOAT positive(FLOAT x) {
  62.  
  63.     if(x > 0) return(x);
  64.     else return(0);
  65.  
  66. }
  67.  
  68.