reduce the number of public header files
parent
09c15110dc
commit
56e6b387c1
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AUDIO_DECODER_H
|
|
||||||
#define AUDIO_DECODER_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include <utility>
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct UnsupportedExtensionEx : public std::runtime_error
|
|
||||||
{
|
|
||||||
UnsupportedExtensionEx() : std::runtime_error("Unsupported file extension") {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LoadPathNotImplEx : public std::runtime_error
|
|
||||||
{
|
|
||||||
LoadPathNotImplEx() : std::runtime_error("Loading from path not implemented") {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LoadBufferNotImplEx : public std::runtime_error
|
|
||||||
{
|
|
||||||
LoadBufferNotImplEx() : std::runtime_error("Loading from buffer not implemented") {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BaseDecoder
|
|
||||||
{
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) = 0;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) = 0;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() = 0;
|
|
||||||
virtual ~BaseDecoder() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::pair<std::string, std::shared_ptr<nqr::BaseDecoder>> DecoderPair;
|
|
||||||
|
|
||||||
class NyquistIO
|
|
||||||
{
|
|
||||||
std::string ParsePathForExtension(const std::string & path) const;
|
|
||||||
std::shared_ptr<nqr::BaseDecoder> GetDecoderForExtension(const std::string & ext);
|
|
||||||
void BuildDecoderTable();
|
|
||||||
void AddDecoderToTable(std::shared_ptr<nqr::BaseDecoder> decoder);
|
|
||||||
std::map<std::string, std::shared_ptr<BaseDecoder>> decoderTable;
|
|
||||||
NO_MOVE(NyquistIO);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
NyquistIO();
|
|
||||||
~NyquistIO();
|
|
||||||
void Load(AudioData * data, const std::string & path);
|
|
||||||
void Load(AudioData * data, const std::string & extension, const std::vector<uint8_t> & buffer);
|
|
||||||
bool IsFileSupported(const std::string & path) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AUDIO_DECODER_H
|
||||||
|
#define AUDIO_DECODER_H
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include <utility>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
namespace nqr
|
||||||
|
{
|
||||||
|
struct BaseDecoder
|
||||||
|
{
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) = 0;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) = 0;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() = 0;
|
||||||
|
virtual ~BaseDecoder() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::pair<std::string, std::shared_ptr<nqr::BaseDecoder>> DecoderPair;
|
||||||
|
|
||||||
|
class NyquistIO
|
||||||
|
{
|
||||||
|
std::string ParsePathForExtension(const std::string & path) const;
|
||||||
|
std::shared_ptr<nqr::BaseDecoder> GetDecoderForExtension(const std::string & ext);
|
||||||
|
void BuildDecoderTable();
|
||||||
|
void AddDecoderToTable(std::shared_ptr<nqr::BaseDecoder> decoder);
|
||||||
|
std::map<std::string, std::shared_ptr<BaseDecoder>> decoderTable;
|
||||||
|
|
||||||
|
NO_MOVE(NyquistIO);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
NyquistIO();
|
||||||
|
~NyquistIO();
|
||||||
|
void Load(AudioData * data, const std::string & path);
|
||||||
|
void Load(AudioData * data, const std::string & extension, const std::vector<uint8_t> & buffer);
|
||||||
|
bool IsFileSupported(const std::string & path) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UnsupportedExtensionEx : public std::runtime_error { UnsupportedExtensionEx() : std::runtime_error("Unsupported file extension") {} };
|
||||||
|
struct LoadPathNotImplEx : public std::runtime_error { LoadPathNotImplEx() : std::runtime_error("Loading from path not implemented") {} };
|
||||||
|
struct LoadBufferNotImplEx : public std::runtime_error { LoadBufferNotImplEx() : std::runtime_error("Loading from buffer not implemented") {} };
|
||||||
|
|
||||||
|
struct WavDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
WavDecoder() = default;
|
||||||
|
virtual ~WavDecoder() {}
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WavPackDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
WavPackDecoder() = default;
|
||||||
|
virtual ~WavPackDecoder() override {};
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VorbisDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
VorbisDecoder() = default;
|
||||||
|
virtual ~VorbisDecoder() override {}
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OpusDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
OpusDecoder() = default;
|
||||||
|
virtual ~OpusDecoder() override {}
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MusepackDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
MusepackDecoder() = default;
|
||||||
|
virtual ~MusepackDecoder() override {};
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Mp3Decoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
Mp3Decoder() = default;
|
||||||
|
virtual ~Mp3Decoder() override {};
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FlacDecoder final : public nqr::BaseDecoder
|
||||||
|
{
|
||||||
|
FlacDecoder() = default;
|
||||||
|
virtual ~FlacDecoder() override {}
|
||||||
|
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
||||||
|
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
||||||
|
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace nqr
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DITHER_OPERATIONS_H
|
|
||||||
#define DITHER_OPERATIONS_H
|
|
||||||
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
enum DitherType
|
|
||||||
{
|
|
||||||
DITHER_NONE,
|
|
||||||
DITHER_TRIANGLE
|
|
||||||
};
|
|
||||||
|
|
||||||
class Dither
|
|
||||||
{
|
|
||||||
std::uniform_real_distribution<float> distribution;
|
|
||||||
std::mt19937 rndGen;
|
|
||||||
float prev = 0.0f;
|
|
||||||
DitherType d;
|
|
||||||
public:
|
|
||||||
|
|
||||||
Dither(DitherType d) : distribution(-0.5f, +0.5f), d(d) {}
|
|
||||||
|
|
||||||
float operator()(float s)
|
|
||||||
{
|
|
||||||
if (d == DITHER_TRIANGLE)
|
|
||||||
{
|
|
||||||
const float value = distribution(rndGen);
|
|
||||||
s = s + value - prev;
|
|
||||||
prev = value;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC_DECODER_H
|
|
||||||
#define FLAC_DECODER_H
|
|
||||||
|
|
||||||
// http://lists.xiph.org/pipermail/flac-dev/2012-March/003276.html
|
|
||||||
#define FLAC__NO_DLL
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
//@todo expose this in API
|
|
||||||
inline std::map<int, std::string> GetQualityTable()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
{ 0, "0 (Fastest)" },
|
|
||||||
{ 1, "1" },
|
|
||||||
{ 2, "2" },
|
|
||||||
{ 3, "3" },
|
|
||||||
{ 4, "4" },
|
|
||||||
{ 5, "5 (Default)" },
|
|
||||||
{ 6, "6" },
|
|
||||||
{ 7, "7" },
|
|
||||||
{ 8, "8 (Highest)" },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FlacDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
FlacDecoder() = default;
|
|
||||||
virtual ~FlacDecoder() override {}
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef IMA4_UTIL_H
|
|
||||||
#define IMA4_UTIL_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct ADPCMState
|
|
||||||
{
|
|
||||||
int frame_size;
|
|
||||||
int firstDataBlockByte;
|
|
||||||
int dataSize;
|
|
||||||
int currentByte;
|
|
||||||
const uint8_t * inBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int ima_index_table[16] =
|
|
||||||
{
|
|
||||||
-1, -1, -1, -1, // +0 / +3 : - the step
|
|
||||||
2, 4, 6, 8, // +4 / +7 : + the step
|
|
||||||
-1, -1, -1, -1, // -0 / -3 : - the step
|
|
||||||
2, 4, 6, 8, // -4 / -7 : + the step
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline int ima_clamp_index(int index)
|
|
||||||
{
|
|
||||||
if (index < 0) return 0;
|
|
||||||
else if (index > 88) return 88;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int16_t ima_clamp_predict(int16_t predict)
|
|
||||||
{
|
|
||||||
if (predict < -32768) return -32768;
|
|
||||||
else if (predict > 32767) return 32767;
|
|
||||||
return predict;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int ima_step_table[89] =
|
|
||||||
{
|
|
||||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34,
|
|
||||||
37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143,
|
|
||||||
157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494,
|
|
||||||
544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552,
|
|
||||||
1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026,
|
|
||||||
4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442,
|
|
||||||
11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623,
|
|
||||||
27086, 29794, 32767
|
|
||||||
};
|
|
||||||
|
|
||||||
// Decodes an IMA ADPCM nibble to a 16 bit pcm sample
|
|
||||||
static inline int16_t decode_nibble(uint8_t nibble, int16_t & p, int & s)
|
|
||||||
{
|
|
||||||
// Compute a delta to add to the predictor value
|
|
||||||
int diff = ima_step_table[s] >> 3;
|
|
||||||
if (nibble & 4) diff += ima_step_table[s];
|
|
||||||
if (nibble & 2) diff += ima_step_table[s] >> 1;
|
|
||||||
if (nibble & 1) diff += ima_step_table[s] >> 2;
|
|
||||||
|
|
||||||
// Sign
|
|
||||||
if (nibble & 8) diff = -diff;
|
|
||||||
|
|
||||||
// Add delta
|
|
||||||
p += diff;
|
|
||||||
|
|
||||||
s += ima_index_table[nibble];
|
|
||||||
s = ima_clamp_index(s);
|
|
||||||
|
|
||||||
return ima_clamp_predict(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void decode_ima_adpcm(ADPCMState & state, int16_t * outBuffer, uint32_t num_channels)
|
|
||||||
{
|
|
||||||
const uint8_t * data = state.inBuffer;
|
|
||||||
|
|
||||||
// Loop over the interleaved channels
|
|
||||||
for (uint32_t ch = 0; ch < num_channels; ch++)
|
|
||||||
{
|
|
||||||
const int byteOffset = ch * 4;
|
|
||||||
|
|
||||||
// Header Structure:
|
|
||||||
// Byte0: packed low byte of the initial predictor
|
|
||||||
// Byte1: packed high byte of the initial predictor
|
|
||||||
// Byte2: initial step index
|
|
||||||
// Byte3: Reserved empty value
|
|
||||||
int16_t predictor = ((int16_t)data[byteOffset + 1] << 8) | data[byteOffset];
|
|
||||||
int stepIndex = data[byteOffset + 2];
|
|
||||||
|
|
||||||
uint8_t reserved = data[byteOffset + 3];
|
|
||||||
if (reserved != 0) throw std::runtime_error("adpcm decode error");
|
|
||||||
|
|
||||||
int byteIdx = num_channels * 4 + byteOffset; //the byte index of the first data word for this channel
|
|
||||||
int idx = ch;
|
|
||||||
|
|
||||||
// Decode nibbles of the remaining data
|
|
||||||
while (byteIdx < state.frame_size)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 4; j++)
|
|
||||||
{
|
|
||||||
outBuffer[idx] = decode_nibble(data[byteIdx] & 0xf, predictor, stepIndex); // low nibble
|
|
||||||
idx += num_channels;
|
|
||||||
outBuffer[idx] = decode_nibble(data[byteIdx] >> 4, predictor, stepIndex); // high nibble
|
|
||||||
idx += num_channels;
|
|
||||||
byteIdx++;
|
|
||||||
}
|
|
||||||
byteIdx += (num_channels - 1) << 2; // Jump to the next data word for the current channel
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MP3_DECODER_H
|
|
||||||
#define MP3_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct Mp3Decoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
Mp3Decoder() = default;
|
|
||||||
virtual ~Mp3Decoder() override {};
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MUSEPACK_DECODER_H
|
|
||||||
#define MUSEPACK_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct MusepackDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
MusepackDecoder() = default;
|
|
||||||
virtual ~MusepackDecoder() override {};
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPUS_DECODER_H
|
|
||||||
#define OPUS_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
// Opus is a general-purpose codec designed to replace Vorbis at some point. Primarily, it's a low
|
|
||||||
// delay format making it suitable for high-quality, real time streaming. It's not really
|
|
||||||
// an archival format or something designed for heavy DSP post-processing since
|
|
||||||
// it's fundamentally limited to encode/decode at 48khz.
|
|
||||||
// https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/index.html
|
|
||||||
struct OpusDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
OpusDecoder() = default;
|
|
||||||
virtual ~OpusDecoder() override {}
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef POSTPROCESS_H
|
|
||||||
#define POSTPROCESS_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void DeinterleaveStereo(T * c1, T * c2, T const * src, size_t count)
|
|
||||||
{
|
|
||||||
auto src_end = src + count;
|
|
||||||
while (src != src_end)
|
|
||||||
{
|
|
||||||
*c1 = src[0];
|
|
||||||
*c2 = src[1];
|
|
||||||
c1++;
|
|
||||||
c2++;
|
|
||||||
src += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void InterleaveChannels(const T * src, T * dest, size_t numFramesPerChannel, size_t numChannels, size_t N)
|
|
||||||
{
|
|
||||||
for (size_t ch = 0; ch < numChannels; ch++)
|
|
||||||
{
|
|
||||||
size_t x = ch;
|
|
||||||
const T * srcChannel = &src[ch * numFramesPerChannel];
|
|
||||||
for(size_t i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
dest[x] = srcChannel[i];
|
|
||||||
x += numChannels;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void DeinterleaveChannels(const T * src, T * dest, size_t numFramesPerChannel, size_t numChannels, size_t N)
|
|
||||||
{
|
|
||||||
for(size_t ch = 0; ch < numChannels; ch++)
|
|
||||||
{
|
|
||||||
size_t x = ch;
|
|
||||||
T *destChannel = &dest[ch * numFramesPerChannel];
|
|
||||||
for (size_t i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
destChannel[i] = (T) src[x];
|
|
||||||
x += numChannels;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void StereoToMono(const T * src, T * dest, size_t N)
|
|
||||||
{
|
|
||||||
for (size_t i = 0, j = 0; i < N; i += 2, ++j)
|
|
||||||
{
|
|
||||||
dest[j] = (src[i] + src[i + 1]) / 2.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void MonoToStereo(const T * src, T * dest, size_t N)
|
|
||||||
{
|
|
||||||
for(size_t i = 0, j = 0; i < N; ++i, j += 2)
|
|
||||||
{
|
|
||||||
dest[j] = src[i];
|
|
||||||
dest[j + 1] = src[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void TrimSilenceInterleaved(std::vector<float> & buffer, float v, bool fromFront, bool fromEnd)
|
|
||||||
{
|
|
||||||
//@todo implement me!
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RIFF_UTILS_H
|
|
||||||
#define RIFF_UTILS_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "WavDecoder.h"
|
|
||||||
#include "Dither.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////
|
|
||||||
// Chunk utilities //
|
|
||||||
/////////////////////
|
|
||||||
|
|
||||||
struct EncoderParams
|
|
||||||
{
|
|
||||||
int channelCount;
|
|
||||||
PCMFormat targetFormat;
|
|
||||||
DitherType dither;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ChunkHeaderInfo
|
|
||||||
{
|
|
||||||
uint32_t offset; // Byte offset into chunk
|
|
||||||
uint32_t size; // Size of the chunk in bytes
|
|
||||||
};
|
|
||||||
|
|
||||||
inline uint32_t GenerateChunkCode(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
|
|
||||||
{
|
|
||||||
#ifdef ARCH_CPU_LITTLE_ENDIAN
|
|
||||||
return ((uint32_t) ((a) | ((b) << 8) | ((c) << 16) | (((uint32_t) (d)) << 24)));
|
|
||||||
#else
|
|
||||||
return ((uint32_t) ((((uint32_t) (a)) << 24) | ((b) << 16) | ((c) << 8) | (d)));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char * GenerateChunkCodeChar(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
|
|
||||||
{
|
|
||||||
auto chunk = GenerateChunkCode(a, b, c, d);
|
|
||||||
|
|
||||||
char * outArr = new char[4];
|
|
||||||
|
|
||||||
uint32_t t = 0x000000FF;
|
|
||||||
|
|
||||||
for(size_t i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
outArr[i] = chunk & t;
|
|
||||||
chunk >>= 8;
|
|
||||||
}
|
|
||||||
return outArr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChunkHeaderInfo ScanForChunk(const std::vector<uint8_t> & fileData, uint32_t chunkMarker);
|
|
||||||
|
|
||||||
WaveChunkHeader MakeWaveHeader(const EncoderParams param, const int sampleRate);
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VORBIS_DECODER_H
|
|
||||||
#define VORBIS_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct VorbisDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
VorbisDecoder() = default;
|
|
||||||
virtual ~VorbisDecoder() override {}
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
#endif
|
|
||||||
@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WAVE_DECODER_H
|
|
||||||
#define WAVE_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
enum WaveFormatCode
|
|
||||||
{
|
|
||||||
FORMAT_UNKNOWN = 0x0, // Unknown Wave Format
|
|
||||||
FORMAT_PCM = 0x1, // PCM Format
|
|
||||||
FORMAT_ADPCM = 0x2, // Microsoft ADPCM Format
|
|
||||||
FORMAT_IEEE = 0x3, // IEEE float/double
|
|
||||||
FORMAT_ALAW = 0x6, // 8-bit ITU-T G.711 A-law
|
|
||||||
FORMAT_MULAW = 0x7, // 8-bit ITU-T G.711 µ-law
|
|
||||||
FORMAT_IMA_ADPCM = 0x11, // IMA ADPCM Format
|
|
||||||
FORMAT_EXT = 0xFFFE // Set via subformat
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RiffChunkHeader
|
|
||||||
{
|
|
||||||
uint32_t id_riff; // Chunk ID: 'RIFF'
|
|
||||||
uint32_t file_size; // Entire file in bytes
|
|
||||||
uint32_t id_wave; // Chunk ID: 'WAVE'
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WaveChunkHeader
|
|
||||||
{
|
|
||||||
uint32_t fmt_id; // Chunk ID: 'fmt '
|
|
||||||
uint32_t chunk_size; // Size in bytes
|
|
||||||
uint16_t format; // Format code
|
|
||||||
uint16_t channel_count; // Num interleaved channels
|
|
||||||
uint32_t sample_rate; // SR
|
|
||||||
uint32_t data_rate; // Data rate
|
|
||||||
uint16_t frame_size; // 1 frame = channels * bits per sample (also known as block align)
|
|
||||||
uint16_t bit_depth; // Bits per sample
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BextChunk
|
|
||||||
{
|
|
||||||
uint32_t fmt_id; // Chunk ID: 'bext'
|
|
||||||
uint32_t chunk_size; // Size in bytes
|
|
||||||
uint8_t description[256]; // Description of the sound (ascii)
|
|
||||||
uint8_t origin[32]; // Name of the originator (ascii)
|
|
||||||
uint8_t origin_ref[32]; // Reference of the originator (ascii)
|
|
||||||
uint8_t orgin_date[10]; // yyyy-mm-dd (ascii)
|
|
||||||
uint8_t origin_time[8]; // hh-mm-ss (ascii)
|
|
||||||
uint64_t time_ref; // First sample count since midnight
|
|
||||||
uint32_t version; // Version of the BWF
|
|
||||||
uint8_t uimd[64]; // Byte 0 of SMPTE UMID
|
|
||||||
uint8_t reserved[188]; // 190 bytes, reserved for future use & set to NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FactChunk
|
|
||||||
{
|
|
||||||
uint32_t fact_id; // Chunk ID: 'fact'
|
|
||||||
uint32_t chunk_size; // Size in bytes
|
|
||||||
uint32_t sample_length; // number of samples per channel
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExtensibleData
|
|
||||||
{
|
|
||||||
uint16_t size;
|
|
||||||
uint16_t valid_bits_per_sample;
|
|
||||||
uint32_t channel_mask;
|
|
||||||
struct GUID
|
|
||||||
{
|
|
||||||
uint32_t data0;
|
|
||||||
uint16_t data1;
|
|
||||||
uint16_t data2;
|
|
||||||
uint16_t data3;
|
|
||||||
uint8_t data4[6];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class C, class R>
|
|
||||||
std::basic_ostream<C,R> & operator << (std::basic_ostream<C,R> & a, const WaveChunkHeader & b)
|
|
||||||
{
|
|
||||||
return a <<
|
|
||||||
"Format ID:\t\t" << b.fmt_id <<
|
|
||||||
"\nChunk Size:\t\t" << b.chunk_size <<
|
|
||||||
"\nFormat Code:\t\t" << b.format <<
|
|
||||||
"\nChannels:\t\t" << b.channel_count <<
|
|
||||||
"\nSample Rate:\t\t" << b.sample_rate <<
|
|
||||||
"\nData Rate:\t\t" << b.data_rate <<
|
|
||||||
"\nFrame Size:\t\t" << b.frame_size <<
|
|
||||||
"\nBit Depth:\t\t" << b.bit_depth << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@todo expose speaker/channel/layout masks in the API:
|
|
||||||
|
|
||||||
enum SpeakerChannelMask
|
|
||||||
{
|
|
||||||
SPEAKER_FRONT_LEFT = 0x00000001,
|
|
||||||
SPEAKER_FRONT_RIGHT = 0x00000002,
|
|
||||||
SPEAKER_FRONT_CENTER = 0x00000004,
|
|
||||||
SPEAKER_LOW_FREQUENCY = 0x00000008,
|
|
||||||
SPEAKER_BACK_LEFT = 0x00000010,
|
|
||||||
SPEAKER_BACK_RIGHT = 0x00000020,
|
|
||||||
SPEAKER_FRONT_LEFT_OF_CENTER = 0x00000040,
|
|
||||||
SPEAKER_FRONT_RIGHT_OF_CENTER = 0x00000080,
|
|
||||||
SPEAKER_BACK_CENTER = 0x00000100,
|
|
||||||
SPEAKER_SIDE_LEFT = 0x00000200,
|
|
||||||
SPEAKER_SIDE_RIGHT = 0x00000400,
|
|
||||||
SPEAKER_TOP_CENTER = 0x00000800,
|
|
||||||
SPEAKER_TOP_FRONT_LEFT = 0x00001000,
|
|
||||||
SPEAKER_TOP_FRONT_CENTER = 0x00002000,
|
|
||||||
SPEAKER_TOP_FRONT_RIGHT = 0x00004000,
|
|
||||||
SPEAKER_TOP_BACK_LEFT = 0x00008000,
|
|
||||||
SPEAKER_TOP_BACK_CENTER = 0x00010000,
|
|
||||||
SPEAKER_TOP_BACK_RIGHT = 0x00020000,
|
|
||||||
SPEAKER_RESERVED = 0x7FFC0000,
|
|
||||||
SPEAKER_ALL = 0x80000000
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SpeakerLayoutMask
|
|
||||||
{
|
|
||||||
SPEAKER_MONO = (SPEAKER_FRONT_CENTER),
|
|
||||||
SPEAKER_STEREO = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT),
|
|
||||||
SPEAKER_2POINT1 = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY),
|
|
||||||
SPEAKER_SURROUND = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER),
|
|
||||||
SPEAKER_QUAD = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT),
|
|
||||||
SPEAKER_4POINT1 = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT),
|
|
||||||
SPEAKER_5POINT1 = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT),
|
|
||||||
SPEAKER_7POINT1 = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER),
|
|
||||||
SPEAKER_5POINT1_SURROUND = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT),
|
|
||||||
SPEAKER_7POINT1_SURROUND = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT),
|
|
||||||
};
|
|
||||||
|
|
||||||
//@todo verify mask values
|
|
||||||
inline int ComputeChannelMask(const size_t channels)
|
|
||||||
{
|
|
||||||
switch (channels)
|
|
||||||
{
|
|
||||||
case 1: return SPEAKER_MONO;
|
|
||||||
case 2: return SPEAKER_STEREO;
|
|
||||||
case 3: return SPEAKER_2POINT1;
|
|
||||||
case 4: return SPEAKER_QUAD;
|
|
||||||
case 5: return SPEAKER_4POINT1;
|
|
||||||
case 6: return SPEAKER_5POINT1;
|
|
||||||
default: return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct WavDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
WavDecoder() = default;
|
|
||||||
virtual ~WavDecoder() {}
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WAVEPACK_DECODER_H
|
|
||||||
#define WAVEPACK_DECODER_H
|
|
||||||
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
namespace nqr
|
|
||||||
{
|
|
||||||
|
|
||||||
struct WavPackDecoder final : public nqr::BaseDecoder
|
|
||||||
{
|
|
||||||
WavPackDecoder() = default;
|
|
||||||
virtual ~WavPackDecoder() override {};
|
|
||||||
virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override final;
|
|
||||||
virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector<uint8_t> & memory) override final;
|
|
||||||
virtual std::vector<std::string> GetSupportedFileExtensions() override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace nqr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "RiffUtils.h"
|
|
||||||
|
|
||||||
using namespace nqr;
|
|
||||||
|
|
||||||
ChunkHeaderInfo nqr::ScanForChunk(const std::vector<uint8_t> & fileData, uint32_t chunkMarker)
|
|
||||||
{
|
|
||||||
// D[n] aligned to 16 bytes now
|
|
||||||
const uint16_t * d = reinterpret_cast<const uint16_t *>(fileData.data());
|
|
||||||
|
|
||||||
for (size_t i = 0; i < fileData.size() / sizeof(uint16_t); i++)
|
|
||||||
{
|
|
||||||
// This will be in machine endianess
|
|
||||||
uint32_t m = Pack(Read16(d[i]), Read16(d[i+1]));
|
|
||||||
|
|
||||||
if (m == chunkMarker)
|
|
||||||
{
|
|
||||||
uint32_t cSz = Pack(Read16(d[i+2]), Read16(d[i+3]));
|
|
||||||
return {(uint32_t (i * sizeof(uint16_t))), cSz}; // return i in bytes to the start of the data
|
|
||||||
}
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
return {0, 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveChunkHeader nqr::MakeWaveHeader(const EncoderParams param, const int sampleRate)
|
|
||||||
{
|
|
||||||
WaveChunkHeader header;
|
|
||||||
|
|
||||||
int bitdepth = GetFormatBitsPerSample(param.targetFormat);
|
|
||||||
|
|
||||||
header.fmt_id = GenerateChunkCode('f', 'm', 't', ' ');
|
|
||||||
header.chunk_size = 16;
|
|
||||||
header.format = (param.targetFormat <= PCMFormat::PCM_32) ? WaveFormatCode::FORMAT_PCM : WaveFormatCode::FORMAT_IEEE;
|
|
||||||
header.channel_count = param.channelCount;
|
|
||||||
header.sample_rate = sampleRate;
|
|
||||||
header.data_rate = sampleRate * param.channelCount * (bitdepth / 8);
|
|
||||||
header.frame_size = param.channelCount * (bitdepth / 8);
|
|
||||||
header.bit_depth = bitdepth;
|
|
||||||
|
|
||||||
return header;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue