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

  1. /*  RxWav
  2.    Copyright (C) 1999  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. Peek
  30. Vuole il puntatore ad un campione in una traccia gia' allocata
  31. ***********************************************************************/
  32. ULONG
  33. WavPeek (PCSZ name, LONG argc, const RXSTRING * argv,
  34.      PCSZ queuename, PRXSTRING retstr)
  35. {
  36.   PSHORT pCh = NULL;
  37.   APIRET rc;
  38.  
  39.   if (argc != 1)
  40.     {
  41.       SendMsg (FUNC_PEEK, ERR_NUMERO_PARAMETRI);
  42.       return INVALID_ROUTINE;
  43.     }
  44.  
  45.   if (!sscanf (argv[0].strptr, "%d", &pCh))
  46.     {
  47.       SendMsg (FUNC_PEEK, ERR_PUNTATORE_ERRATO);
  48.       return INVALID_ROUTINE;
  49.     }
  50.  
  51.   pCh = AllineaCh (pCh, (ULONG) 2, FUNC_PEEK);
  52.   if (!pCh)
  53.     return INVALID_ROUTINE;
  54.  
  55.   sprintf (retstr->strptr, "%i", *pCh);
  56.   retstr->strlength = strlen (retstr->strptr);
  57.   return VALID_ROUTINE;
  58. }
  59.  
  60.  
  61. /***********************************************************************
  62. Poke
  63. Vuole il puntatore ad un campione in una traccia gia' allocata ed il
  64. valore da assegnare
  65. ***********************************************************************/
  66. ULONG
  67. WavPoke (PCSZ name, LONG argc, const RXSTRING * argv,
  68.      PCSZ queuename, PRXSTRING retstr)
  69. {
  70.   PSHORT pCh = NULL;
  71.   double camp;
  72.   APIRET rc;
  73.  
  74.   if (argc != 2)
  75.     {
  76.       SendMsg (FUNC_POKE, ERR_NUMERO_PARAMETRI);
  77.       return INVALID_ROUTINE;
  78.     }
  79.  
  80.   if (!sscanf (argv[0].strptr, "%d", &pCh))
  81.     {
  82.       SendMsg (FUNC_POKE, ERR_PUNTATORE_ERRATO);
  83.       return INVALID_ROUTINE;
  84.     }
  85.  
  86.   camp = atof (argv[1].strptr);
  87.   if ((camp < -1) | (camp > 1))
  88.     {
  89.       SendMsg (FUNC_POKE, ERR_VALORE_INVALIDO);
  90.       return INVALID_ROUTINE;
  91.     }
  92.  
  93.   pCh = AllineaCh (pCh, (ULONG) 2, FUNC_POKE);
  94.   if (!pCh)
  95.     return INVALID_ROUTINE;
  96.  
  97.   *pCh = camp * MAX_CAMPIONE;
  98.  
  99.   sprintf (retstr->strptr, "%i", ERR_OK);
  100.   retstr->strlength = strlen (retstr->strptr);
  101.   return VALID_ROUTINE;
  102. }
  103.