aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-07-28 01:50:46 +0000
committerMax Horn2003-07-28 01:50:46 +0000
commit81baae7ddc2b16031af2526455993c06a2f24d25 (patch)
treed1fb33b5fe1ea08d0078f6c0bf3b1d41d564df99 /sound
parent9865deb0bcd1948046607edab7647c2f328338bd (diff)
downloadscummvm-rg350-81baae7ddc2b16031af2526455993c06a2f24d25.tar.gz
scummvm-rg350-81baae7ddc2b16031af2526455993c06a2f24d25.tar.bz2
scummvm-rg350-81baae7ddc2b16031af2526455993c06a2f24d25.zip
added CopyRateConverter (used if inrate == outrate)
svn-id: r9214
Diffstat (limited to 'sound')
-rw-r--r--sound/rate.cpp4
-rw-r--r--sound/rate.h20
-rw-r--r--sound/resample.cpp8
3 files changed, 22 insertions, 10 deletions
diff --git a/sound/rate.cpp b/sound/rate.cpp
index 5d6faaeee3..f62d20e536 100644
--- a/sound/rate.cpp
+++ b/sound/rate.cpp
@@ -107,7 +107,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
ilast[i] = rate->ilast[i];
ostart = obuf;
- oend = obuf + *osamp;
+ oend = obuf + *osamp * 2;
while (obuf < oend && !input.eof()) {
@@ -159,7 +159,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
}
the_end:
- *osamp = obuf - ostart;
+ *osamp = (obuf - ostart) / 2;
for (i = 0; i < channels; i++)
rate->ilast[i] = ilast[i];
return (ST_SUCCESS);
diff --git a/sound/rate.h b/sound/rate.h
index 080107c831..809042a8b2 100644
--- a/sound/rate.h
+++ b/sound/rate.h
@@ -81,4 +81,24 @@ public:
virtual int drain(st_sample_t *obuf, st_size_t *osamp, st_volume_t vol);
};
+class CopyRateConverter : public RateConverter {
+public:
+ virtual int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
+ int16 tmp;
+ st_size_t len = *osamp;
+ while (!input.eof() && len--) {
+ tmp = input.read() * vol / 256;
+ clampedAdd(*obuf++, tmp);
+ if (input.isStereo())
+ tmp = input.read() * vol / 256;
+ clampedAdd(*obuf++, tmp);
+ }
+ return (ST_SUCCESS);
+ }
+ virtual int drain(st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
+ return (ST_SUCCESS);
+ }
+};
+
+
#endif
diff --git a/sound/resample.cpp b/sound/resample.cpp
index a621d89213..b2758f4517 100644
--- a/sound/resample.cpp
+++ b/sound/resample.cpp
@@ -268,11 +268,7 @@ int st_resample_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_
long Nout = 0; // The number of bytes we effectively output
long Nx; // The number of bytes we will read from input
long Nproc; // The number of bytes we process to generate Nout output bytes
-#if 1 // FIXME: Hack to generate stereo output
- const long obufSize = *osamp / 2;
-#else
const long obufSize = *osamp;
-#endif
TODO: adjust for the changes made to AudioInputStream; add support for stereo
initially, could just average the left/right channel -> bad for quality of course,
@@ -394,11 +390,7 @@ printf("osamp = %ld, Nout = %ld\n", obufSize, Nout);
r->Yposition = 0;
// Finally set *osamp to the number of samples we put into the output buffer
-#if 1 // FIXME: Hack to generate stereo output
- *osamp = numOutSamples * 2;
-#else
*osamp = numOutSamples;
-#endif
return (ST_SUCCESS);
}