summaryrefslogtreecommitdiff
path: root/AudioDevice.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
committerChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
commit32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch)
treec6e107c1ee4d70610e43a7912e57c720334a08c7 /AudioDevice.hpp
parent08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff)
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'AudioDevice.hpp')
-rw-r--r--AudioDevice.hpp98
1 files changed, 0 insertions, 98 deletions
diff --git a/AudioDevice.hpp b/AudioDevice.hpp
deleted file mode 100644
index c4354687..00000000
--- a/AudioDevice.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef AUDIODEVICE_HPP__
-#define AUDIODEVICE_HPP__
-
-#include <QIODevice>
-
-class QDataStream;
-
-//
-// abstract base class for audio devices
-//
-class AudioDevice : public QIODevice
-{
-public:
- enum Channel {Mono, Left, Right, Both}; // these are mapped to combobox index so don't change
-
- static char const * toString (Channel c)
- {
- return Mono == c ? "Mono" : Left == c ? "Left" : Right == c ? "Right" : "Both";
- }
-
- static Channel fromString (QString const& str)
- {
- QString s (str.toCaseFolded ().trimmed ().toLatin1 ());
- return "both" == s ? Both : "right" == s ? Right : "left" == s ? Left : Mono;
- }
-
- bool initialize (OpenMode mode, Channel channel);
-
- bool isSequential () const override {return true;}
-
- size_t bytesPerFrame () const {return sizeof (qint16) * (Mono == m_channel ? 1 : 2);}
-
- Channel channel () const {return m_channel;}
-
-protected:
- AudioDevice (QObject * parent = 0)
- : QIODevice (parent)
- {
- }
-
- void store (char const * source, size_t numFrames, qint16 * dest)
- {
- qint16 const * begin (reinterpret_cast<qint16 const *> (source));
- for ( qint16 const * i = begin; i != begin + numFrames * (bytesPerFrame () / sizeof (qint16)); i += bytesPerFrame () / sizeof (qint16))
- {
- switch (m_channel)
- {
- case Mono:
- *dest++ = *i;
- break;
-
- case Right:
- *dest++ = *(i + 1);
- break;
-
- case Both: // should be able to happen but if it
- // does we'll take left
- Q_ASSERT (Both == m_channel);
- case Left:
- *dest++ = *i;
- break;
- }
- }
- }
-
- qint16 * load (qint16 const sample, qint16 * dest)
- {
- switch (m_channel)
- {
- case Mono:
- *dest++ = sample;
- break;
-
- case Left:
- *dest++ = sample;
- *dest++ = 0;
- break;
-
- case Right:
- *dest++ = 0;
- *dest++ = sample;
- break;
-
- case Both:
- *dest++ = sample;
- *dest++ = sample;
- break;
- }
- return dest;
- }
-
-private:
- Channel m_channel;
-};
-
-Q_DECLARE_METATYPE (AudioDevice::Channel);
-
-#endif