home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / rxwavsrc.zip / RxWavConv.c < prev    next >
C/C++ Source or Header  |  2000-03-06  |  2KB  |  86 lines

  1. /*  RxWav
  2.    Copyright (C) 1999 2000  Giorgio Vicario
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA     */
  17.  
  18. #define INCL_REXXSAA
  19. #include <os2emx.h>
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <regexp.h>
  24. #include <math.h>
  25. #include <float.h>
  26. #include "RxWav.h"
  27.  
  28. /***********************************************************************
  29. Convoluzione:
  30. Vuole due puntatore e la durata della convoluzione
  31. ***********************************************************************/
  32. ULONG
  33. WavConv (PCSZ name, LONG argc, const RXSTRING * argv,
  34.      PCSZ queuename, PRXSTRING retstr)
  35. {
  36.   PSHORT pCh1, pCh2;
  37.   ULONG nCamp;
  38.   double conv;
  39.   INT i, j;
  40.   APIRET rc;
  41.  
  42.   if (argc != 3)
  43.     {
  44.       SendMsg (FUNC_CONV, ERR_NUMERO_PARAMETRI);
  45.       return INVALID_ROUTINE;
  46.     }
  47.  
  48.   if (!sscanf (argv[0].strptr, "%d", &pCh1))
  49.     {
  50.       SendMsg (FUNC_CONV, ERR_PUNTATORE_ERRATO);
  51.       return INVALID_ROUTINE;
  52.     }
  53.  
  54.   if (!sscanf (argv[1].strptr, "%d", &pCh2))
  55.     {
  56.       SendMsg (FUNC_CONV, ERR_PUNTATORE_ERRATO);
  57.       return INVALID_ROUTINE;
  58.     }
  59.  
  60.   nCamp = atol (argv[2].strptr);
  61.   if (!nCamp)
  62.     {
  63.       SendMsg (FUNC_CONV, ERR_NUMERO_CAMPIONI);
  64.       return INVALID_ROUTINE;
  65.     }
  66.  
  67.   pCh1 = AllineaCh (pCh1, nCamp, FUNC_CONV);
  68.   if (!pCh1)
  69.     return INVALID_ROUTINE;
  70.  
  71.   pCh2 = AllineaCh (pCh2, nCamp, FUNC_CONV);
  72.   if (!pCh2)
  73.     return INVALID_ROUTINE;
  74.  
  75.   for (i = nCamp; i != 0; i--)
  76.     {
  77.       conv = (double) *pCh1 * (double) *pCh2++;
  78.       *pCh1++ = (SHORT) (conv / MAX_CAMPIONE);
  79.     }
  80.  
  81.  
  82.   sprintf (retstr->strptr, "%i", ERR_OK);
  83.   retstr->strlength = strlen (retstr->strptr);
  84.   return VALID_ROUTINE;
  85. }
  86.