mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 10:15:43 +08:00
Ref T731, added namespace for utility functions
This commit is contained in:
committed by
Mat Sutcliffe
parent
9a4fe0ea48
commit
c3684a2f8c
@@ -18,6 +18,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackSound;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,44 +1,55 @@
|
|||||||
|
/* Copyright (C) 2019
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "audioutilities.h"
|
#include "audioutilities.h"
|
||||||
|
|
||||||
QVector<qint16> convertBytesTo16BitPCM(const QByteArray input)
|
namespace BlackSound
|
||||||
{
|
{
|
||||||
int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample
|
QVector<qint16> convertBytesTo16BitPCM(const QByteArray input)
|
||||||
QVector<qint16> output;
|
|
||||||
output.fill(0, inputSamples);
|
|
||||||
|
|
||||||
for (int n = 0; n < inputSamples; n++)
|
|
||||||
{
|
{
|
||||||
output[n] = *reinterpret_cast<const qint16 *>(input.data() + n * 2);
|
int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample
|
||||||
|
QVector<qint16> output;
|
||||||
|
output.fill(0, inputSamples);
|
||||||
|
|
||||||
|
for (int n = 0; n < inputSamples; n++)
|
||||||
|
{
|
||||||
|
output[n] = *reinterpret_cast<const qint16 *>(input.data() + n * 2);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input)
|
QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input)
|
||||||
{
|
|
||||||
Q_UNUSED(input);
|
|
||||||
qFatal("Not implemented");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<qint16> convertFromMonoToStereo(const QVector<qint16> &mono)
|
|
||||||
{
|
|
||||||
QVector<qint16> stereo;
|
|
||||||
stereo.reserve(mono.size() * 2);
|
|
||||||
for (qint16 sample : mono)
|
|
||||||
{
|
{
|
||||||
stereo << sample;
|
Q_UNUSED(input)
|
||||||
stereo << sample;
|
qFatal("Not implemented");
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
return stereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<qint16> convertFromStereoToMono(const QVector<qint16> &stereo)
|
QVector<qint16> convertFromMonoToStereo(const QVector<qint16> &mono)
|
||||||
{
|
|
||||||
QVector<qint16> mono;
|
|
||||||
mono.reserve(stereo.size() / 2);
|
|
||||||
for (int i = 0; i < stereo.size(); i = i + 2)
|
|
||||||
{
|
{
|
||||||
mono.append(stereo.at(i));
|
QVector<qint16> stereo;
|
||||||
|
stereo.reserve(mono.size() * 2);
|
||||||
|
for (qint16 sample : mono)
|
||||||
|
{
|
||||||
|
stereo << sample;
|
||||||
|
stereo << sample;
|
||||||
|
}
|
||||||
|
return stereo;
|
||||||
}
|
}
|
||||||
return mono;
|
|
||||||
}
|
QVector<qint16> convertFromStereoToMono(const QVector<qint16> &stereo)
|
||||||
|
{
|
||||||
|
QVector<qint16> mono;
|
||||||
|
mono.reserve(stereo.size() / 2);
|
||||||
|
for (int i = 0; i < stereo.size(); i = i + 2)
|
||||||
|
{
|
||||||
|
mono.append(stereo.at(i));
|
||||||
|
}
|
||||||
|
return mono;
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
#ifndef AUDIOUTILITIES_H
|
/* Copyright (C) 2019
|
||||||
#define AUDIOUTILITIES_H
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKSOUND_AUDIOUTILITIES_H
|
||||||
|
#define BLACKSOUND_AUDIOUTILITIES_H
|
||||||
|
|
||||||
#include "blacksound/blacksoundexport.h"
|
#include "blacksound/blacksoundexport.h"
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
BLACKSOUND_EXPORT QVector<qint16> convertBytesTo16BitPCM(const QByteArray input);
|
namespace BlackSound
|
||||||
BLACKSOUND_EXPORT QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input);
|
{
|
||||||
BLACKSOUND_EXPORT QVector<qint16> convertFromMonoToStereo(const QVector<qint16> &mono);
|
//! Conversion functions @{
|
||||||
BLACKSOUND_EXPORT QVector<qint16> convertFromStereoToMono(const QVector<qint16> &stereo);
|
BLACKSOUND_EXPORT QVector<qint16> convertBytesTo16BitPCM(const QByteArray input);
|
||||||
|
BLACKSOUND_EXPORT QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input);
|
||||||
|
BLACKSOUND_EXPORT QVector<qint16> convertFromMonoToStereo(const QVector<qint16> &mono);
|
||||||
|
BLACKSOUND_EXPORT QVector<qint16> convertFromStereoToMono(const QVector<qint16> &stereo);
|
||||||
|
//! @}
|
||||||
|
} // ns
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user