home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / sound / mpw32-5s.zip / SYNFILT.H < prev    next >
C/C++ Source or Header  |  1996-06-25  |  2KB  |  68 lines

  1. /*
  2.  *  @(#) synthesis_filter.h 1.8, last edit: 6/15/94 16:52:00
  3.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  4.  *  @(#) Berlin University of Technology
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef SYNTHESIS_FILTER_H
  22. #define SYNTHESIS_FILTER_H
  23.  
  24. #include "all.h"
  25. #include "obuffer.h"
  26.  
  27.  
  28. // A class for the synthesis filter bank:
  29. // This class does a fast downsampling from 32, 44.1 or 48 kHz to 8 kHz, if ULAW is defined.
  30. // Frequencies above 4 kHz are removed by ignoring higher subbands.
  31. class SynthesisFilter
  32. {
  33.   static const real d[512];
  34.   real v1[512], v2[512];
  35.   real *actual_v;            // v1 or v2
  36.   uint32 actual_write_pos;        // 0-15
  37.  
  38.   real     samples[32];            // 32 new subband samples
  39.  
  40.   uint32 channel;
  41.   real     scalefactor;
  42.   uint32 range_violations;
  43.   real     max_violation;
  44.   uint32 written_samples;
  45.  
  46.   void compute_new_v (void);
  47.   void compute_pcm_samples (Obuffer *);
  48.  
  49. public:
  50.     SynthesisFilter (uint32 channelnumber, real scalefactor = 32768.0);
  51.       // the scalefactor scales the calculated float pcm samples to short values
  52.       // (raw pcm samples are in [-1.0, 1.0], if no violations occur)
  53.  
  54.   void    input_sample (real sample, uint32 subbandnumber)
  55.   {
  56.      samples[subbandnumber] = sample;
  57.   };
  58.   void    calculate_pcm_samples (Obuffer *);
  59.     // calculate 32 PCM samples and put the into the Obuffer-object
  60.  
  61.   real     seconds_played (uint32 frequency)
  62.   {
  63.     return (real)written_samples / (real)frequency;
  64.   }
  65. };
  66.  
  67. #endif
  68.