summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Klotz <uwe_klotz@web.de>2014-11-15 18:09:17 +0100
committerUwe Klotz <uwe_klotz@web.de>2014-11-15 19:42:51 +0100
commit33bc828f5c4b0dcdce17727f962ed8078daa23ce (patch)
tree6e3006f18399e6ac9c9c28d77d2dadab2254fb41
parentbebae2b489d2d11b4e204ea72fcb5e4fcfde813a (diff)
SampleUtil: Rename the new functions
-rw-r--r--plugins/soundsourcem4a/soundsourcem4a.cpp2
-rw-r--r--plugins/soundsourcewv/soundsourcewv.cpp2
-rw-r--r--src/sampleutil.cpp93
-rw-r--r--src/sampleutil.h70
-rw-r--r--src/soundsourceoggvorbis.cpp2
-rw-r--r--src/soundsourcesndfile.cpp2
6 files changed, 85 insertions, 86 deletions
diff --git a/plugins/soundsourcem4a/soundsourcem4a.cpp b/plugins/soundsourcem4a/soundsourcem4a.cpp
index 6b2e5b2d09..963a4156c9 100644
--- a/plugins/soundsourcem4a/soundsourcem4a.cpp
+++ b/plugins/soundsourcem4a/soundsourcem4a.cpp
@@ -149,7 +149,7 @@ unsigned SoundSourceM4A::read(volatile unsigned long size, const SAMPLE* destina
// At this point *destination should be filled. If mono : double all samples
// (L => R)
if (m_iChannels == 1) {
- SampleUtil::widenMonoToStereo(as_buffer, total_bytes_decoded / 2);
+ SampleUtil::doubleMonoToDualMono(as_buffer, total_bytes_decoded / 2);
}
// Tell us about it only if we end up decoding a different value
diff --git a/plugins/soundsourcewv/soundsourcewv.cpp b/plugins/soundsourcewv/soundsourcewv.cpp
index d7df57a669..87ba22b64b 100644
--- a/plugins/soundsourcewv/soundsourcewv.cpp
+++ b/plugins/soundsourcewv/soundsourcewv.cpp
@@ -105,7 +105,7 @@ unsigned SoundSourceWV::read(volatile unsigned long size, const SAMPLE* destinat
}
if (m_iChannels==1) { //if MONO : expand array to double it's size; see ssov.cpp
- SampleUtil::widenMonoToStereo(dest, sampsread / 2);
+ SampleUtil::doubleMonoToDualMono(dest, sampsread / 2);
}
return sampsread;
diff --git a/src/sampleutil.cpp b/src/sampleutil.cpp
index 2655bd1294..96af937247 100644
--- a/src/sampleutil.cpp
+++ b/src/sampleutil.cpp
@@ -23,53 +23,6 @@ void SampleUtil::free(CSAMPLE* pBuffer) {
}
// static
-void SampleUtil::widenMonoToStereo(SAMPLE* pBuffer, unsigned int numFrames) {
- // backward loop
- unsigned int sampleOffset = numFrames;
- while (0 < sampleOffset--) {
- pBuffer[sampleOffset * 2] = pBuffer[sampleOffset];
- pBuffer[sampleOffset * 2 + 1] = pBuffer[sampleOffset];
- }
-}
-
-// static
-void SampleUtil::widenMonoToStereo(CSAMPLE* pBuffer, unsigned int numFrames) {
- // backward loop
- unsigned int sampleOffset = numFrames;
- while (0 < sampleOffset--) {
- pBuffer[sampleOffset * 2] = pBuffer[sampleOffset];
- pBuffer[sampleOffset * 2 + 1] = pBuffer[sampleOffset];
- }
-}
-
-// static
-void SampleUtil::copyWidenMonoToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
- unsigned int numFrames) {
- // forward loop
- for (unsigned int i = 0; i < numFrames; ++i) {
- pDest[i * 2] = pSrc[i];
- pDest[i * 2 + 1] = pSrc[i];
- }
-}
-
-// static
-void SampleUtil::narrowMultiToStereo(CSAMPLE* pBuffer, unsigned int numFrames,
- unsigned int numChannels) {
- // the copying implementation can be reused here
- copyNarrowMultiToStereo(pBuffer, pBuffer, numFrames, numChannels);
-}
-
-// static
-void SampleUtil::copyNarrowMultiToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
- unsigned int numFrames, unsigned int numChannels) {
- // forward loop
- for (unsigned int i = 0; i < numFrames; ++i) {
- pDest[i * 2] = pSrc[i * numChannels];
- pDest[i * 2 + 1] = pSrc[i * numChannels + 1];
- }
-}
-
-// static
void SampleUtil::applyGain(CSAMPLE* pBuffer, CSAMPLE_GAIN gain,
unsigned int iNumSamples) {
if (gain == CSAMPLE_GAIN_ONE)
@@ -333,3 +286,49 @@ void SampleUtil::mixStereoToMono(CSAMPLE* pDest, const CSAMPLE* pSrc,
}
}
+// static
+void SampleUtil::doubleMonoToDualMono(SAMPLE* pBuffer, unsigned int numFrames) {
+ // backward loop
+ unsigned int i = numFrames;
+ while (0 < i--) {
+ pBuffer[i * 2] = pBuffer[i];
+ pBuffer[i * 2 + 1] = pBuffer[i];
+ }
+}
+
+// static
+void SampleUtil::doubleMonoToDualMono(CSAMPLE* pBuffer, unsigned int numFrames) {
+ // backward loop
+ unsigned int i = numFrames;
+ while (0 < i--) {
+ pBuffer[i * 2] = pBuffer[i];
+ pBuffer[i * 2 + 1] = pBuffer[i];
+ }
+}
+
+// static
+void SampleUtil::copyMonoToDualMono(CSAMPLE* pDest, const CSAMPLE* pSrc,
+ unsigned int numFrames) {
+ // forward loop
+ for (unsigned int i = 0; i < numFrames; ++i) {
+ pDest[i * 2] = pSrc[i];
+ pDest[i * 2 + 1] = pSrc[i];
+ }
+}
+
+// static
+void SampleUtil::stripMultiToStereo(CSAMPLE* pBuffer, unsigned int numFrames,
+ unsigned int numChannels) {
+ // the copying implementation can safely be reused for this in-place operation
+ copyMultiToStereo(pBuffer, pBuffer, numFrames, numChannels);
+}
+
+// static
+void SampleUtil::copyMultiToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
+ unsigned int numFrames, unsigned int numChannels) {
+ // forward loop
+ for (unsigned int i = 0; i < numFrames; ++i) {
+ pDest[i * 2] = pSrc[i * numChannels];
+ pDest[i * 2 + 1] = pSrc[i * numChannels + 1];
+ }
+}
diff --git a/src/sampleutil.h b/src/sampleutil.h
index 1aa77ce6ed..9ac91bee9e 100644
--- a/src/sampleutil.h
+++ b/src/sampleutil.h
@@ -68,41 +68,6 @@ public:
std::copy(pSrc, pSrc + iNumSamples, pDest);
}
- // In-place widens the mono samples in pBuffer to stereo
- // samples.
- // (numFrames) samples will be read from pBuffer
- // (numFrames * 2) samples will be written to pBuffer
- static void widenMonoToStereo(SAMPLE* pBuffer, unsigned int numFrames);
-
- // In-place widens the mono samples in pBuffer to stereo
- // samples.
- // (numFrames) samples will be read from pBuffer
- // (numFrames * 2) samples will be written into pBuffer
- static void widenMonoToStereo(CSAMPLE* pBuffer, unsigned int numFrames);
-
- // Copies and widens the mono samples in pSrc to stereo
- // samples into pDest.
- // (numFrames) samples will be read from pSrc
- // (numFrames * 2) samples will be written into pDest
- static void copyWidenMonoToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
- unsigned int numFrames);
-
- // In-place narrows interleaved multi-channel samples in
- // pBuffer with numChannels >= 2 to stereo samples.
- // Only samples from the first two channels are used.
- // pBuffer must contain (numFrames * numChannels) samples
- // (numFrames * 2) samples will be written into pBuffer
- static void narrowMultiToStereo(CSAMPLE* pBuffer, unsigned int numFrames,
- unsigned int numChannels);
-
- // Copies and narrows interleaved multi-channel sample data
- // in pSrc with numChannels >= 2 to stereo samples into pDest.
- // Only samples from the first two channels are used.
- // pSrc must contain (numFrames * numChannels) samples
- // (numFrames * 2) samples will be written into pDest
- static void copyNarrowMultiToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
- unsigned int numFrames, unsigned int numChannels);
-
// Multiply every sample in pBuffer by gain
static void applyGain(CSAMPLE* pBuffer, CSAMPLE gain,
unsigned int iNumSamples);
@@ -213,6 +178,41 @@ public:
static void mixStereoToMono(CSAMPLE* pDest, const CSAMPLE* pSrc,
unsigned int iNumSamples);
+ // In-place doubles the mono samples in pBuffer to dual mono samples.
+ // (numFrames) samples will be read from pBuffer
+ // (numFrames * 2) samples will be written into pBuffer
+ static void doubleMonoToDualMono(SAMPLE* pBuffer, unsigned int numFrames);
+
+ // In-place doubles the mono samples in pBuffer to dual mono samples.
+ // (numFrames) samples will be read from pBuffer
+ // (numFrames * 2) samples will be written into pBuffer
+ static void doubleMonoToDualMono(CSAMPLE* pBuffer, unsigned int numFrames);
+
+ // Copies and doubles the mono samples in pSrc to dual mono samples
+ // into pDest.
+ // (numFrames) samples will be read from pSrc
+ // (numFrames * 2) samples will be written into pDest
+ static void copyMonoToDualMono(CSAMPLE* pDest, const CSAMPLE* pSrc,
+ unsigned int numFrames);
+
+ // In-place strips interleaved multi-channel samples in pBuffer with
+ // numChannels >= 2 down to stereo samples. Only samples from the first
+ // two channels will be read and written. Samples from all other
+ // channels are discarded.
+ // pBuffer must contain (numFrames * numChannels) samples
+ // (numFrames * 2) samples will be written into pBuffer
+ static void stripMultiToStereo(CSAMPLE* pBuffer, unsigned int numFrames,
+ unsigned int numChannels);
+
+ // Copies and strips interleaved multi-channel sample data in pSrc with
+ // numChannels >= 2 down to stereo samples into pDest. Only samples from
+ // the first two channels will be read and written. Samples from all other
+ // channels will be ignored.
+ // pSrc must contain (numFrames * numChannels) samples
+ // (numFrames * 2) samples will be written into pDest
+ static void copyMultiToStereo(CSAMPLE* pDest, const CSAMPLE* pSrc,
+ unsigned int numFrames, unsigned int numChannels);
+
// Include auto-generated methods (e.g. copyXWithGain, copyXWithRampingGain,
// etc.)
#include "sampleutil_autogen.h"
diff --git a/src/soundsourceoggvorbis.cpp b/src/soundsourceoggvorbis.cpp
index d3f85d2776..de52869e19 100644
--- a/src/soundsourceoggvorbis.cpp
+++ b/src/soundsourceoggvorbis.cpp
@@ -205,7 +205,7 @@ unsigned SoundSourceOggVorbis::read(volatile unsigned long size, const SAMPLE *
// convert into stereo if file is mono
if (channels == 1) {
- SampleUtil::widenMonoToStereo(dest, index / 2);
+ SampleUtil::doubleMonoToDualMono(dest, index / 2);
// Pretend we read twice as many bytes as we did, since we just repeated
// each pair of bytes.
index *= 2;
diff --git a/src/soundsourcesndfile.cpp b/src/soundsourcesndfile.cpp
index 95a49f4a57..62a696017b 100644
--- a/src/soundsourcesndfile.cpp
+++ b/src/soundsourcesndfile.cpp
@@ -129,7 +129,7 @@ unsigned SoundSourceSndFile::read(unsigned long size, const SAMPLE * destination
int readNo = sf_read_short(fh, dest, size/2);
// dest has enough capacity for (readNo * 2) samples
- SampleUtil::widenMonoToStereo(dest, readNo);
+ SampleUtil::doubleMonoToDualMono(dest, readNo);
// We doubled the readNo bytes we read into stereo.
return readNo * 2;