pcm/dsd2pcm: remove unused sources
This commit is contained in:
parent
64309abc14
commit
5a87fc7c26
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2009, 2011 Sebastian Gesemann. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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 SEBASTIAN GESEMANN ''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 SEBASTIAN GESEMANN 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.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the
|
|
||||||
authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
or implied, of Sebastian Gesemann.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DSD2PCM_HXX_INCLUDED
|
|
||||||
#define DSD2PCM_HXX_INCLUDED
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "dsd2pcm.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C++ PImpl Wrapper for the dsd2pcm C library
|
|
||||||
*/
|
|
||||||
|
|
||||||
class dxd
|
|
||||||
{
|
|
||||||
dsd2pcm_ctx *handle;
|
|
||||||
public:
|
|
||||||
dxd() : handle(dsd2pcm_init()) {}
|
|
||||||
|
|
||||||
dxd(dxd const& x) : handle(dsd2pcm_clone(x.handle)) {}
|
|
||||||
|
|
||||||
~dxd() { dsd2pcm_destroy(handle); }
|
|
||||||
|
|
||||||
friend void swap(dxd & a, dxd & b)
|
|
||||||
{ std::swap(a.handle,b.handle); }
|
|
||||||
|
|
||||||
dxd& operator=(dxd x)
|
|
||||||
{ swap(*this,x); return *this; }
|
|
||||||
|
|
||||||
void translate(size_t samples,
|
|
||||||
const unsigned char *src, ptrdiff_t src_stride,
|
|
||||||
bool lsbitfirst,
|
|
||||||
float *dst, ptrdiff_t dst_stride)
|
|
||||||
{
|
|
||||||
dsd2pcm_translate(handle,samples,src,src_stride,
|
|
||||||
lsbitfirst,dst,dst_stride);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DSD2PCM_HXX_INCLUDED
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
You downloaded the source code for "dsd2pcm" which is a simple little
|
|
||||||
"filter" program, that takes a DSD data stream on stdin and converts
|
|
||||||
it to a PCM stream (352.8 kHz, either 16 or 24 bits) and writes it to
|
|
||||||
stdout. The code is split into three modules:
|
|
||||||
|
|
||||||
(1) dsd2pcm
|
|
||||||
|
|
||||||
This is where the 8:1 decimation magic happens. It's an
|
|
||||||
implementation of a symmetric 96-taps FIR lowpass filter
|
|
||||||
optimized for DSD inputs. If you feed this converter with
|
|
||||||
DSD64 you get a PCM stream at 352.8 kHz and floating point
|
|
||||||
samples. This module is independent and can be reused.
|
|
||||||
|
|
||||||
(2) noiseshape
|
|
||||||
|
|
||||||
A module for applying generic noise shaping filters. It's
|
|
||||||
used for the 16-bit output mode in "main" to preserve the
|
|
||||||
dynamic range. This module is independent and can be reused.
|
|
||||||
|
|
||||||
(3) main.cpp (file contains the main function and handles I/O)
|
|
||||||
|
|
||||||
The first two modules are pure C for maximum portability. In addition,
|
|
||||||
there are C++ wrapper headers for convenient use of these modules in
|
|
||||||
C++. The main application is a C++ application and makes use of the
|
|
||||||
C++ headers to access the functionality of the first two modules.
|
|
||||||
|
|
||||||
|
|
||||||
Under Linux this program is easily compiled by typing
|
|
||||||
|
|
||||||
g++ *.c *.cpp -O3 -o dsd2pcm
|
|
||||||
|
|
||||||
provided you have GCC installed. That's why I didn't bother writing
|
|
||||||
any makefiles. :-p
|
|
||||||
|
|
||||||
|
|
||||||
Cheers!
|
|
||||||
SG
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2009, 2011 Sebastian Gesemann. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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 SEBASTIAN GESEMANN ''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 SEBASTIAN GESEMANN 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.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the
|
|
||||||
authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
or implied, of Sebastian Gesemann.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "dsd2pcm.hpp"
|
|
||||||
#include "noiseshape.hpp"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const float my_ns_coeffs[] = {
|
|
||||||
// b1 b2 a1 a2
|
|
||||||
-1.62666423, 0.79410094, 0.61367127, 0.23311013, // section 1
|
|
||||||
-1.44870017, 0.54196219, 0.03373857, 0.70316556 // section 2
|
|
||||||
};
|
|
||||||
|
|
||||||
const int my_ns_soscount = sizeof(my_ns_coeffs)/(sizeof(my_ns_coeffs[0])*4);
|
|
||||||
|
|
||||||
inline long myround(float x)
|
|
||||||
{
|
|
||||||
return static_cast<long>(x + (x>=0 ? 0.5f : -0.5f));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct id { typedef T type; };
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T clip(
|
|
||||||
typename id<T>::type min,
|
|
||||||
T v,
|
|
||||||
typename id<T>::type max)
|
|
||||||
{
|
|
||||||
if (v<min) return min;
|
|
||||||
if (v>max) return max;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void write_intel16(unsigned char * ptr, unsigned word)
|
|
||||||
{
|
|
||||||
ptr[0] = word & 0xFF;
|
|
||||||
ptr[1] = (word >> 8) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void write_intel24(unsigned char * ptr, unsigned long word)
|
|
||||||
{
|
|
||||||
ptr[0] = word & 0xFF;
|
|
||||||
ptr[1] = (word >> 8) & 0xFF;
|
|
||||||
ptr[2] = (word >> 16) & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using std::cin;
|
|
||||||
using std::cout;
|
|
||||||
using std::cerr;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
const int block = 16384;
|
|
||||||
int channels = -1;
|
|
||||||
int lsbitfirst = -1;
|
|
||||||
int bits = -1;
|
|
||||||
if (argc==4) {
|
|
||||||
if ('1'<=argv[1][0] && argv[1][0]<='9') channels = 1 + (argv[1][0]-'1');
|
|
||||||
if (argv[2][0]=='m' || argv[2][0]=='M') lsbitfirst=0;
|
|
||||||
if (argv[2][0]=='l' || argv[2][0]=='L') lsbitfirst=1;
|
|
||||||
if (!strcmp(argv[3],"16")) bits = 16;
|
|
||||||
if (!strcmp(argv[3],"24")) bits = 24;
|
|
||||||
}
|
|
||||||
if (channels<1 || lsbitfirst<0 || bits<0) {
|
|
||||||
cerr << "\n"
|
|
||||||
"DSD2PCM filter (raw DSD64 --> 352 kHz raw PCM)\n"
|
|
||||||
"(c) 2009 Sebastian Gesemann\n\n"
|
|
||||||
"(filter as in \"reads data from stdin and writes to stdout\")\n\n"
|
|
||||||
"Syntax: dsd2pcm <channels> <bitorder> <bitdepth>\n"
|
|
||||||
"channels = 1,2,3,...,9 (number of channels in DSD stream)\n"
|
|
||||||
"bitorder = L (lsb first), M (msb first) (DSD stream option)\n"
|
|
||||||
"bitdepth = 16 or 24 (intel byte order, output option)\n\n"
|
|
||||||
"Note: At 16 bits/sample a noise shaper kicks in that can preserve\n"
|
|
||||||
"a dynamic range of 135 dB below 30 kHz.\n\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
int bytespersample = bits/8;
|
|
||||||
vector<dxd> dxds (channels);
|
|
||||||
vector<noise_shaper> ns;
|
|
||||||
if (bits==16) {
|
|
||||||
ns.resize(channels, noise_shaper(my_ns_soscount, my_ns_coeffs) );
|
|
||||||
}
|
|
||||||
vector<unsigned char> dsd_data (block * channels);
|
|
||||||
vector<float> float_data (block);
|
|
||||||
vector<unsigned char> pcm_data (block * channels * bytespersample);
|
|
||||||
char * const dsd_in = reinterpret_cast<char*>(&dsd_data[0]);
|
|
||||||
char * const pcm_out = reinterpret_cast<char*>(&pcm_data[0]);
|
|
||||||
while (cin.read(dsd_in,block * channels)) {
|
|
||||||
for (int c=0; c<channels; ++c) {
|
|
||||||
dxds[c].translate(block,&dsd_data[0]+c,channels,
|
|
||||||
lsbitfirst,
|
|
||||||
&float_data[0],1);
|
|
||||||
unsigned char * out = &pcm_data[0] + c*bytespersample;
|
|
||||||
if (bits==16) {
|
|
||||||
for (int s=0; s<block; ++s) {
|
|
||||||
float r = float_data[s]*32768 + ns[c].get();
|
|
||||||
long smp = clip(-32768,myround(r),32767);
|
|
||||||
ns[c].update( clip(-1,smp-r,1) );
|
|
||||||
write_intel16(out,smp);
|
|
||||||
out += channels*bytespersample;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int s=0; s<block; ++s) {
|
|
||||||
float r = float_data[s]*8388608;
|
|
||||||
long smp = clip(-8388608,myround(r),8388607);
|
|
||||||
write_intel24(out,smp);
|
|
||||||
out += channels*bytespersample;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cout.write(pcm_out,block*channels*bytespersample);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2009, 2011 Sebastian Gesemann. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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 SEBASTIAN GESEMANN ''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 SEBASTIAN GESEMANN 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.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the
|
|
||||||
authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
or implied, of Sebastian Gesemann.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "noiseshape.h"
|
|
||||||
|
|
||||||
extern int noise_shape_init(
|
|
||||||
noise_shape_ctx *ctx,
|
|
||||||
int sos_count,
|
|
||||||
const float *coeffs)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
ctx->sos_count = sos_count;
|
|
||||||
ctx->bbaa = coeffs;
|
|
||||||
ctx->t1 = (float*) malloc(sizeof(float)*sos_count);
|
|
||||||
if (!ctx->t1) goto escape1;
|
|
||||||
ctx->t2 = (float*) malloc(sizeof(float)*sos_count);
|
|
||||||
if (!ctx->t2) goto escape2;
|
|
||||||
for (i=0; i<sos_count; ++i) {
|
|
||||||
ctx->t1[i] = 0.f;
|
|
||||||
ctx->t2[i] = 0.f;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
escape2:
|
|
||||||
free(ctx->t1);
|
|
||||||
escape1:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void noise_shape_destroy(
|
|
||||||
noise_shape_ctx *ctx)
|
|
||||||
{
|
|
||||||
free(ctx->t1);
|
|
||||||
free(ctx->t2);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern int noise_shape_clone(
|
|
||||||
const noise_shape_ctx *from,
|
|
||||||
noise_shape_ctx *to)
|
|
||||||
{
|
|
||||||
to->sos_count = from->sos_count;
|
|
||||||
to->bbaa = from->bbaa;
|
|
||||||
to->t1 = (float*) malloc(sizeof(float)*to->sos_count);
|
|
||||||
if (!to->t1) goto error1;
|
|
||||||
to->t2 = (float*) malloc(sizeof(float)*to->sos_count);
|
|
||||||
if (!to->t2) goto error2;
|
|
||||||
memcpy(to->t1,from->t1,sizeof(float)*to->sos_count);
|
|
||||||
memcpy(to->t2,from->t2,sizeof(float)*to->sos_count);
|
|
||||||
return 0;
|
|
||||||
error2:
|
|
||||||
free(to->t1);
|
|
||||||
error1:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern float noise_shape_get(noise_shape_ctx *ctx)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float acc;
|
|
||||||
const float *c;
|
|
||||||
acc = 0.0;
|
|
||||||
c = ctx->bbaa;
|
|
||||||
for (i=0; i<ctx->sos_count; ++i) {
|
|
||||||
float t1i = ctx->t1[i];
|
|
||||||
float t2i = ctx->t2[i];
|
|
||||||
ctx->t2[i] = acc -= t1i * c[2] + t2i * c[3];
|
|
||||||
acc += t1i * c[0] + t2i * c[1];
|
|
||||||
c += 4;
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void noise_shape_update(noise_shape_ctx *ctx, float qerror)
|
|
||||||
{
|
|
||||||
float *p;
|
|
||||||
int i;
|
|
||||||
for (i=0; i<ctx->sos_count; ++i) {
|
|
||||||
ctx->t2[i] += qerror;
|
|
||||||
}
|
|
||||||
p = ctx->t1;
|
|
||||||
ctx->t1 = ctx->t2;
|
|
||||||
ctx->t2 = p;
|
|
||||||
}
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2009, 2011 Sebastian Gesemann. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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 SEBASTIAN GESEMANN ''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 SEBASTIAN GESEMANN 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.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the
|
|
||||||
authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
or implied, of Sebastian Gesemann.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NOISE_SHAPE_H_INCLUDED
|
|
||||||
#define NOISE_SHAPE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct noise_shape_ctx_s {
|
|
||||||
int sos_count; /* number of second order sections */
|
|
||||||
const float *bbaa; /* filter coefficients, owned by user */
|
|
||||||
float *t1, *t2; /* filter state, owned by ns library */
|
|
||||||
} noise_shape_ctx;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initializes a noise_shaper context
|
|
||||||
* returns an error code or 0
|
|
||||||
*/
|
|
||||||
extern int noise_shape_init(
|
|
||||||
noise_shape_ctx *ctx,
|
|
||||||
int sos_count,
|
|
||||||
const float *coeffs);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* destroys a noise_shaper context
|
|
||||||
*/
|
|
||||||
extern void noise_shape_destroy(
|
|
||||||
noise_shape_ctx *ctx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initializes a noise_shaper context so that its state
|
|
||||||
* is a copy of a given context
|
|
||||||
* returns an error code or 0
|
|
||||||
*/
|
|
||||||
extern int noise_shape_clone(
|
|
||||||
const noise_shape_ctx *from, noise_shape_ctx *to);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* computes the next "noise shaping sample". Note: This call
|
|
||||||
* alters the internal state. xxx_get and xxx_update must be
|
|
||||||
* called in an alternating manner.
|
|
||||||
*/
|
|
||||||
extern float noise_shape_get(
|
|
||||||
noise_shape_ctx *ctx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates the noise shaper's state with the
|
|
||||||
* last quantization error
|
|
||||||
*/
|
|
||||||
extern void noise_shape_update(
|
|
||||||
noise_shape_ctx *ctx, float qerror);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* extern "C" */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* NOISE_SHAPE_H_INCLUDED */
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2009, 2011 Sebastian Gesemann. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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 SEBASTIAN GESEMANN ''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 SEBASTIAN GESEMANN 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.
|
|
||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those of the
|
|
||||||
authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
or implied, of Sebastian Gesemann.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NOISE_SHAPE_HXX_INCLUDED
|
|
||||||
#define NOISE_SHAPE_HXX_INCLUDED
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "noiseshape.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C++ wrapper for the noiseshape C library
|
|
||||||
*/
|
|
||||||
|
|
||||||
class noise_shaper
|
|
||||||
{
|
|
||||||
noise_shape_ctx ctx;
|
|
||||||
public:
|
|
||||||
noise_shaper(int sos_count, const float *bbaa)
|
|
||||||
{
|
|
||||||
noise_shape_init(&ctx, sos_count, bbaa);
|
|
||||||
}
|
|
||||||
|
|
||||||
noise_shaper(noise_shaper const& x)
|
|
||||||
{
|
|
||||||
noise_shape_clone(&x.ctx,&ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
~noise_shaper()
|
|
||||||
{ noise_shape_destroy(&ctx); }
|
|
||||||
|
|
||||||
noise_shaper& operator=(noise_shaper const& x)
|
|
||||||
{
|
|
||||||
if (this != &x) {
|
|
||||||
noise_shape_destroy(&ctx);
|
|
||||||
noise_shape_clone(&x.ctx,&ctx);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
float get() { return noise_shape_get(&ctx); }
|
|
||||||
|
|
||||||
void update(float error) { noise_shape_update(&ctx,error); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* NOISE_SHAPE_HXX_INCLUDED */
|
|
||||||
|
|
@ -30,19 +30,6 @@ if get_option('dsd')
|
|||||||
'PcmDsd.cxx',
|
'PcmDsd.cxx',
|
||||||
'dsd2pcm/dsd2pcm.c',
|
'dsd2pcm/dsd2pcm.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
executable(
|
|
||||||
'dsd2pcm',
|
|
||||||
'dsd2pcm/main.cpp',
|
|
||||||
'dsd2pcm/dsd2pcm.c',
|
|
||||||
'dsd2pcm/noiseshape.c',
|
|
||||||
include_directories: inc,
|
|
||||||
dependencies: [
|
|
||||||
util_dep,
|
|
||||||
],
|
|
||||||
build_by_default: get_option('test'),
|
|
||||||
install: false,
|
|
||||||
)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libsamplerate_dep = dependency('samplerate', version: '>= 0.1.3', required: get_option('libsamplerate'))
|
libsamplerate_dep = dependency('samplerate', version: '>= 0.1.3', required: get_option('libsamplerate'))
|
||||||
|
Loading…
Reference in New Issue
Block a user