pcm/Normalizer: hard-code the preferences
This commit is contained in:
parent
d2f2dde2e1
commit
6e5d9d4490
|
@ -18,7 +18,7 @@ class NormalizeFilter final : public Filter {
|
|||
|
||||
public:
|
||||
explicit NormalizeFilter(const AudioFormat &audio_format)
|
||||
:Filter(audio_format), compressor(Compressor_new(0)) {
|
||||
:Filter(audio_format), compressor(Compressor_new()) {
|
||||
}
|
||||
|
||||
~NormalizeFilter() override {
|
||||
|
|
|
@ -4,17 +4,15 @@
|
|||
|
||||
#include "Normalizer.hxx"
|
||||
|
||||
/*** Default configuration stuff ***/
|
||||
#define TARGET 16384 /*!< Target level (on a scale of 0-32767) */
|
||||
|
||||
#define GAINMAX 32 /*!< The maximum amount to amplify by */
|
||||
#define GAINSMOOTH 8 /*!< How much inertia ramping has*/
|
||||
#define BUCKETS 400 /*!< How long of a history to use by default */
|
||||
|
||||
struct Compressor {
|
||||
int target;
|
||||
int maxgain;
|
||||
int smooth;
|
||||
///! Target level (on a scale of 0-32767)
|
||||
static constexpr int target = 16384;
|
||||
|
||||
//! The maximum amount to amplify by
|
||||
static constexpr int maxgain = 32;
|
||||
|
||||
//! How much inertia ramping has
|
||||
static constexpr int smooth = 8;
|
||||
|
||||
//! History of the peak values
|
||||
int *peaks;
|
||||
|
@ -34,17 +32,10 @@ Compressor_new(unsigned int history) noexcept
|
|||
{
|
||||
auto obj = new Compressor();
|
||||
|
||||
obj->target = TARGET;
|
||||
obj->maxgain = GAINMAX;
|
||||
obj->smooth = GAINSMOOTH;
|
||||
|
||||
obj->peaks = obj->gain = obj->clipped = nullptr;
|
||||
obj->bufsz = 0;
|
||||
obj->pos = 0;
|
||||
|
||||
if (!history)
|
||||
history = BUCKETS;
|
||||
|
||||
obj->bufsz = history;
|
||||
obj->peaks = new int[history]{};
|
||||
obj->gain = new int[history]{};
|
||||
|
|
|
@ -10,7 +10,7 @@ struct Compressor;
|
|||
|
||||
//! Create a new compressor (use history value of 0 for default)
|
||||
struct Compressor *
|
||||
Compressor_new(unsigned int history) noexcept;
|
||||
Compressor_new(unsigned int history = 400) noexcept;
|
||||
|
||||
//! Delete a compressor
|
||||
void
|
||||
|
|
|
@ -35,7 +35,7 @@ try {
|
|||
if (argc > 1)
|
||||
audio_format = ParseAudioFormat(argv[1], false);
|
||||
|
||||
compressor = Compressor_new(0);
|
||||
compressor = Compressor_new();
|
||||
|
||||
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
|
||||
Compressor_Process_int16(compressor,
|
||||
|
|
Loading…
Reference in New Issue