summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorUwe Klotz <uwe_klotz@web.de>2014-11-10 17:30:09 +0100
committerUwe Klotz <uwe_klotz@web.de>2014-11-15 19:42:50 +0100
commitfd9f31545f9136164c26da7aae60944f1f93ed29 (patch)
tree257f642f75cf622baa55f17cd4cf69209de40d74 /plugins
parent34de62d51e9137a379769396a22adf39764bc385 (diff)
Enhance and reuse SampleUtil
Diffstat (limited to 'plugins')
-rw-r--r--plugins/soundsourcem4a/SConscript1
-rw-r--r--plugins/soundsourcem4a/soundsourcem4a.cpp12
-rw-r--r--plugins/soundsourcem4a/soundsourcem4a.h2
-rw-r--r--plugins/soundsourcewv/SConscript1
-rw-r--r--plugins/soundsourcewv/soundsourcewv.cpp6
5 files changed, 10 insertions, 12 deletions
diff --git a/plugins/soundsourcem4a/SConscript b/plugins/soundsourcem4a/SConscript
index 32ffeb1118..1f3672142e 100644
--- a/plugins/soundsourcem4a/SConscript
+++ b/plugins/soundsourcem4a/SConscript
@@ -13,6 +13,7 @@ Import('build')
m4a_sources = [
"soundsource.cpp", # required to subclass soundsource
"soundsourcem4a.cpp", # MP4/M4A Support through FAAD/libmp4v2
+ "sampleutil.cpp", # utility functions
]
#Tell SCons to build the SoundSourceM4A plugin
diff --git a/plugins/soundsourcem4a/soundsourcem4a.cpp b/plugins/soundsourcem4a/soundsourcem4a.cpp
index eb0a552bad..6b2e5b2d09 100644
--- a/plugins/soundsourcem4a/soundsourcem4a.cpp
+++ b/plugins/soundsourcem4a/soundsourcem4a.cpp
@@ -14,6 +14,9 @@
* *
***************************************************************************/
+#include "soundsourcem4a.h"
+#include "sampleutil.h"
+
#include <taglib/mp4file.h>
#include <neaacdec.h>
@@ -28,8 +31,6 @@
#include <fcntl.h>
#endif
-#include <QtDebug>
-#include "soundsourcem4a.h"
#include "m4a/mp4-mixxx.cpp"
namespace Mixxx {
@@ -148,12 +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) {
- for (int i = total_bytes_decoded/2-1; i >= 0; --i) {
- // as_buffer[i] is an audio sample (s16)
- //scroll through , copying L->R & expanding buffer
- as_buffer[i*2+1] = as_buffer[i];
- as_buffer[i*2] = as_buffer[i];
- }
+ SampleUtil::widenMonoToStereo(as_buffer, total_bytes_decoded / 2);
}
// Tell us about it only if we end up decoding a different value
diff --git a/plugins/soundsourcem4a/soundsourcem4a.h b/plugins/soundsourcem4a/soundsourcem4a.h
index e6a141489e..0ce9d512d6 100644
--- a/plugins/soundsourcem4a/soundsourcem4a.h
+++ b/plugins/soundsourcem4a/soundsourcem4a.h
@@ -30,6 +30,8 @@
#include "m4a/ip.h"
#include "util/defs.h"
+#include <QtDebug>
+
//As per QLibrary docs: http://doc.trolltech.com/4.6/qlibrary.html#resolve
#ifdef Q_OS_WIN
#define MY_EXPORT __declspec(dllexport)
diff --git a/plugins/soundsourcewv/SConscript b/plugins/soundsourcewv/SConscript
index e0edfa9715..33843b80fc 100644
--- a/plugins/soundsourcewv/SConscript
+++ b/plugins/soundsourcewv/SConscript
@@ -13,6 +13,7 @@ Import('build')
wv_sources = [
"soundsource.cpp", # required to subclass soundsource
"soundsourcewv.cpp", # Wavpack support
+ "sampleutil.cpp", # utility functions
]
diff --git a/plugins/soundsourcewv/soundsourcewv.cpp b/plugins/soundsourcewv/soundsourcewv.cpp
index 3c3ad1640f..d7df57a669 100644
--- a/plugins/soundsourcewv/soundsourcewv.cpp
+++ b/plugins/soundsourcewv/soundsourcewv.cpp
@@ -8,6 +8,7 @@
#include <taglib/wavpackfile.h>
#include "soundsourcewv.h"
+#include "sampleutil.h"
namespace Mixxx {
@@ -104,10 +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
- for(int i=(sampsread/2-1); i>=0; i--) { //algo courtesy of rryan !
- dest[i*2] = dest[i]; //go through array backwards, expanding and copying L -> R
- dest[(i*2)+1] = dest[i];
- }
+ SampleUtil::widenMonoToStereo(dest, sampsread / 2);
}
return sampsread;