summaryrefslogtreecommitdiff
path: root/libs/ardour/export_utilities.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/export_utilities.cc')
-rw-r--r--libs/ardour/export_utilities.cc58
1 files changed, 29 insertions, 29 deletions
diff --git a/libs/ardour/export_utilities.cc b/libs/ardour/export_utilities.cc
index dcc43c8a7f..a91912359e 100644
--- a/libs/ardour/export_utilities.cc
+++ b/libs/ardour/export_utilities.cc
@@ -24,7 +24,7 @@
#include <cmath>
#undef _ISOC99_SOURCE
#undef _ISOC9X_SOURCE
-#undef __USE_SVID
+#undef __USE_SVID
#define __USE_SVID 1
#include <cstdlib>
#undef __USE_SVID
@@ -68,14 +68,14 @@ SampleRateConverter::SampleRateConverter (uint32_t channels, nframes_t in_rate,
active = false;
return;
}
-
+
active = true;
int err;
if ((src_state = src_new (quality, channels, &err)) == 0) {
throw ExportFailed (string_compose (X_("Cannot initialize sample rate conversion: %1"), src_strerror (err)));
}
-
+
src_data.src_ratio = out_rate / (double) in_rate;
}
@@ -101,7 +101,7 @@ SampleRateConverter::process (float * data, nframes_t frames)
}
/* Manage memory */
-
+
nframes_t out_samples_max = (nframes_t) ceil (frames * src_data.src_ratio * channels);
if (data_out_size < out_samples_max) {
@@ -109,13 +109,13 @@ SampleRateConverter::process (float * data, nframes_t frames)
data_out = new float[out_samples_max];
src_data.data_out = data_out;
-
+
max_leftover_frames = 4 * frames;
leftover_data = (float *) realloc (leftover_data, max_leftover_frames * channels * sizeof (float));
if (!leftover_data) {
throw ExportFailed (X_("A memory allocation error occured during sample rate conversion"));
}
-
+
data_out_size = out_samples_max;
}
@@ -127,7 +127,7 @@ SampleRateConverter::process (float * data, nframes_t frames)
int err;
int cnt = 0;
nframes_t frames_out_total = 0;
-
+
do {
src_data.output_frames = out_samples_max / channels;
src_data.end_of_input = end_of_input;
@@ -140,13 +140,13 @@ SampleRateConverter::process (float * data, nframes_t frames)
src_data.data_in = leftover_data;
if (cnt == 0) {
-
+
/* first time, append new data from data_in into the leftover_data buffer */
memcpy (leftover_data + (leftover_frames * channels), data_in, frames_in * channels * sizeof(float));
src_data.input_frames = frames_in + leftover_frames;
} else {
-
+
/* otherwise, just use whatever is still left in leftover_data; the contents
were adjusted using memmove() right after the last SRC call (see
below)
@@ -154,7 +154,7 @@ SampleRateConverter::process (float * data, nframes_t frames)
src_data.input_frames = leftover_frames;
}
-
+
} else {
src_data.data_in = data_in;
@@ -167,7 +167,7 @@ SampleRateConverter::process (float * data, nframes_t frames)
if ((err = src_process (src_state, &src_data)) != 0) {
throw ExportFailed (string_compose ("An error occured during sample rate conversion: %1", src_strerror (err)));
}
-
+
frames_out = src_data.output_frames_gen;
leftover_frames = src_data.input_frames - src_data.input_frames_used;
@@ -179,14 +179,14 @@ SampleRateConverter::process (float * data, nframes_t frames)
memmove (leftover_data, (char *) (src_data.data_in + (src_data.input_frames_used * channels)),
leftover_frames * channels * sizeof(float));
}
-
-
+
+
nframes_t frames_written = piped_to->write (data_out, frames_out);
frames_out_total += frames_written;
} while (leftover_frames > frames_in);
-
+
return frames_out_total;
}
@@ -204,7 +204,7 @@ SampleFormatConverter<TOut>::SampleFormatConverter (uint32_t channels, ExportFor
if (data_width != 24) {
data_width = sizeof (TOut) * 8;
}
-
+
GDitherSize dither_size = GDitherFloat;
switch (data_width) {
@@ -218,7 +218,7 @@ SampleFormatConverter<TOut>::SampleFormatConverter (uint32_t channels, ExportFor
case 24:
dither_size = GDither32bit;
}
-
+
dither = gdither_new ((GDitherType) type, channels, dither_size, data_width);
}
@@ -237,7 +237,7 @@ nframes_t
SampleFormatConverter<TOut>::process (float * data, nframes_t frames)
{
/* Make sure we have enough memory allocated */
-
+
size_t data_size = channels * frames * sizeof (TOut);
if (data_size > data_out_size) {
@@ -246,24 +246,24 @@ SampleFormatConverter<TOut>::process (float * data, nframes_t frames)
data_out = new TOut[data_size];
data_out_size = data_size;
}
-
+
/* Do conversion */
-
+
if (data_width < 32) {
for (uint32_t chn = 0; chn < channels; ++chn) {
gdither_runf (dither, chn, frames, data, data_out);
}
} else {
for (uint32_t chn = 0; chn < channels; ++chn) {
-
+
TOut * ob = data_out;
const double int_max = (float) INT_MAX;
const double int_min = (float) INT_MIN;
-
+
nframes_t i;
for (nframes_t x = 0; x < frames; ++x) {
i = chn + (x * channels);
-
+
if (data[i] > 1.0f) {
ob[i] = static_cast<TOut> (INT_MAX);
} else if (data[i] < -1.0f) {
@@ -278,9 +278,9 @@ SampleFormatConverter<TOut>::process (float * data, nframes_t frames)
}
}
}
-
+
/* Write forward */
-
+
return GraphSinkVertex<float, TOut>::piped_to->write (data_out, frames);
}
@@ -294,10 +294,10 @@ SampleFormatConverter<float>::process (float * data, nframes_t frames)
data[x] = 1.0f;
} else if (data[x] < -1.0f) {
data[x] = -1.0f;
- }
+ }
}
}
-
+
return piped_to->write (data, frames);
}
@@ -311,8 +311,8 @@ Normalizer::Normalizer (uint32_t channels, float target_dB) :
channels (channels),
enabled (false)
{
- target = dB_to_coefficient (target_dB);
-
+ target = dB_to_coefficient (target_dB);
+
if (target == 1.0f) {
/* do not normalize to precisely 1.0 (0 dBFS), to avoid making it appear
that we may have clipped.
@@ -328,7 +328,7 @@ Normalizer::~Normalizer ()
void
Normalizer::set_peak (float peak)
-{
+{
if (peak == 0.0f || peak == target) {
/* don't even try */
enabled = false;