ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

rate.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef AUDIO_RATE_H
00024 #define AUDIO_RATE_H
00025 
00026 #include "common/scummsys.h"
00027 
00028 namespace Audio {
00029 
00030 class AudioStream;
00031 
00032 typedef int16 st_sample_t;
00033 typedef uint16 st_volume_t;
00034 typedef uint32 st_size_t;
00035 typedef uint32 st_rate_t;
00036 
00037 /* Minimum and maximum values a sample can hold. */
00038 enum {
00039     ST_SAMPLE_MAX = 0x7fffL,
00040     ST_SAMPLE_MIN = (-ST_SAMPLE_MAX - 1L)
00041 };
00042 
00043 enum {
00044     ST_EOF = -1,
00045     ST_SUCCESS = 0
00046 };
00047 
00048 static inline void clampedAdd(int16& a, int b) {
00049     int val;
00050 #ifdef OUTPUT_UNSIGNED_AUDIO
00051     val = (a ^ 0x8000) + b;
00052 #else
00053     val = a + b;
00054 #endif
00055 
00056     if (val > ST_SAMPLE_MAX)
00057         val = ST_SAMPLE_MAX;
00058     else if (val < ST_SAMPLE_MIN)
00059         val = ST_SAMPLE_MIN;
00060 
00061 #ifdef OUTPUT_UNSIGNED_AUDIO
00062     a = ((int16)val) ^ 0x8000;
00063 #else
00064     a = val;
00065 #endif
00066 }
00067 
00068 class RateConverter {
00069 public:
00070     RateConverter() {}
00071     virtual ~RateConverter() {}
00072 
00076     virtual int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) = 0;
00077 
00078     virtual int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) = 0;
00079 };
00080 
00081 RateConverter *makeRateConverter(st_rate_t inrate, st_rate_t outrate, bool stereo, bool reverseStereo = false);
00082 
00083 } // End of namespace Audio
00084 
00085 #endif


Generated on Sat May 18 2019 05:01:16 for ResidualVM by doxygen 1.7.1
curved edge   curved edge