aboutsummaryrefslogtreecommitdiff
path: root/audio/rate_arm.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2015-11-09 16:39:17 +0100
committerEugene Sandulenko2015-11-09 16:39:17 +0100
commit82c98e98033eafa2ed04febe2607f09636e7e6a5 (patch)
tree450e3e543c839c6b89aedf1a1e329fd9072d51ee /audio/rate_arm.cpp
parent30b6682130e5aefe1e019eb37c0cd25b5831d225 (diff)
parent9003ce517ff9906b0288f9f7c02197fd091d4554 (diff)
downloadscummvm-rg350-82c98e98033eafa2ed04febe2607f09636e7e6a5.tar.gz
scummvm-rg350-82c98e98033eafa2ed04febe2607f09636e7e6a5.tar.bz2
scummvm-rg350-82c98e98033eafa2ed04febe2607f09636e7e6a5.zip
Merge pull request #625 from digitall/rate-hack
AUDIO: Add support for sample rates >65kHz.
Diffstat (limited to 'audio/rate_arm.cpp')
-rw-r--r--audio/rate_arm.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/audio/rate_arm.cpp b/audio/rate_arm.cpp
index 4ad8d71a34..7765266673 100644
--- a/audio/rate_arm.cpp
+++ b/audio/rate_arm.cpp
@@ -68,6 +68,16 @@ namespace Audio {
*/
#define INTERMEDIATE_BUFFER_SIZE 512
+/**
+ * The default fractional type in frac.h (with 16 fractional bits) limits
+ * the rate conversion code to 65536Hz audio: we need to able to handle
+ * 96kHz audio, so we use fewer fractional bits in this code.
+ */
+enum {
+ FRAC_BITS_LOW = 15,
+ FRAC_ONE_LOW = (1L << FRAC_BITS_LOW),
+ FRAC_HALF_LOW = (1L << (FRAC_BITS_LOW-1))
+};
/**
* Audio rate converter based on simple resampling. Used when no
@@ -287,17 +297,18 @@ LinearRateConverter<stereo, reverseStereo>::LinearRateConverter(st_rate_t inrate
error("Input and Output rates must be different to use rate effect");
}
- if (inrate >= 65536 || outrate >= 65536) {
- error("rate effect can only handle rates < 65536");
+ if (inrate >= 131072 || outrate >= 131072) {
+ error("rate effect can only handle rates < 131072");
}
- lr.opos = FRAC_ONE;
+ lr.opos = FRAC_ONE_LOW;
/* increment */
- incr = (inrate << FRAC_BITS) / outrate;
+ incr = (inrate << FRAC_BITS_LOW) / outrate;
lr.opos_inc = incr;
+ // FIXME: Does 32768 here need changing to 65536 or 0? Compare to rate.cpp code...
lr.ilast[0] = lr.ilast[1] = 32768;
lr.icur[0] = lr.icur[1] = 0;
@@ -438,7 +449,7 @@ public:
*/
RateConverter *makeRateConverter(st_rate_t inrate, st_rate_t outrate, bool stereo, bool reverseStereo) {
if (inrate != outrate) {
- if ((inrate % outrate) == 0) {
+ if ((inrate % outrate) == 0 && (inrate < 65536)) {
if (stereo) {
if (reverseStereo)
return new SimpleRateConverter<true, true>(inrate, outrate);