summaryrefslogtreecommitdiff
path: root/libs/ardour/export_processor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/export_processor.cc')
-rw-r--r--libs/ardour/export_processor.cc98
1 files changed, 49 insertions, 49 deletions
diff --git a/libs/ardour/export_processor.cc b/libs/ardour/export_processor.cc
index 19ff9ac001..d36ef9f18a 100644
--- a/libs/ardour/export_processor.cc
+++ b/libs/ardour/export_processor.cc
@@ -73,11 +73,11 @@ ExportProcessor::prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, b
temp_file_length = 0;
/* Reset just to be sure all references are dropped */
-
+
reset();
-
+
/* Get parameters needed later on */
-
+
channels = chans;
split_files = split;
filename = fname;
@@ -88,50 +88,50 @@ ExportProcessor::prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, b
trim_end = format->trim_end();
silence_beginning = format->silence_beginning();
silence_end = format->silence_end();
-
+
/* SRC */
-
+
src.reset (new SampleRateConverter (channels, frame_rate, format->sample_rate(), format->src_quality()));
-
+
/* Construct export pipe to temp file */
-
+
status->stage = export_PostProcess;
-
+
if (normalize) {
/* Normalizing => we need a normalizer, peak reader and tempfile */
-
+
normalizer.reset (new Normalizer (channels, format->normalize_target()));
-
+
peak_reader.reset (new PeakReader (channels));
temp_file.reset (new ExportTempFile (channels, format->sample_rate()));
-
+
src->pipe_to (peak_reader);
peak_reader->pipe_to (temp_file);
-
+
} else if (trim_beginning || trim_end) {
/* Not normalizing, but silence will be trimmed => need for a tempfile */
-
+
temp_file.reset (new ExportTempFile (channels, format->sample_rate()));
src->pipe_to (temp_file);
-
+
} else {
/* Due to complexity and time running out, a tempfile will be created for this also... */
-
+
temp_file.reset (new ExportTempFile (channels, format->sample_rate()));
src->pipe_to (temp_file);
}
/* Ensure directory exists */
-
+
sys::path folder (filename->get_folder());
if (!sys::exists (folder)) {
if (!sys::create_directory (folder)) {
throw ExportFailed (X_("sys::create_directory failed for export dir"));
}
}
-
+
/* prep file sinks */
-
+
if (split) {
filename->include_channel = true;
for (uint32_t chn = 1; chn <= channels; ++chn) {
@@ -148,23 +148,23 @@ ExportProcessor::prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, b
writer_list.push_back (pair.second);
WritingFile (filename->get_path (format));
}
-
+
/* Set position info */
-
+
nframes_t start_position = ((double) format->sample_rate() / frame_rate) * start + 0.5;
-
+
for (FileWriterList::iterator it = writer_list.begin(); it != writer_list.end(); ++it) {
(*it)->set_position (start_position);
}
-
+
/* set broadcast info if necessary */
-
+
if (broadcast_info) {
for (FileWriterList::iterator it = writer_list.begin(); it != writer_list.end(); ++it) {
-
+
BroadcastInfo bci;
bci.set_from_session (session, (*it)->position());
-
+
boost::shared_ptr<SndfileWriterBase> sndfile_ptr;
if ((sndfile_ptr = boost::dynamic_pointer_cast<SndfileWriterBase> (*it))) {
if (!bci.write_to_file (sndfile_ptr->get_sndfile())) {
@@ -196,17 +196,17 @@ ExportProcessor::prepare_post_processors ()
float dummy;
src->set_end_of_input ();
src->write (&dummy, 0);
-
+
/* Trim and add silence */
-
+
temp_file->trim_beginning (trim_beginning);
temp_file->trim_end (trim_end);
-
+
temp_file->set_silence_beginning (silence_beginning);
temp_file->set_silence_end (silence_end);
-
+
/* Set up normalizer */
-
+
if (normalize) {
normalizer->set_peak (peak_reader->get_peak ());
}
@@ -216,35 +216,35 @@ void
ExportProcessor::write_files ()
{
/* Write to disk */
-
+
status->stage = export_Write;
temp_file_position = 0;
-
+
uint32_t buffer_size = 4096; // TODO adjust buffer size?
float * buf = new float[channels * buffer_size];
int frames_read;
-
+
FloatSinkPtr disk_sink;
-
+
if (normalize) {
disk_sink = boost::dynamic_pointer_cast<FloatSink> (normalizer);
normalizer->pipe_to (file_sinks[0]);
} else {
disk_sink = file_sinks[0];
}
-
+
if (split_files) {
-
+
/* Get buffers for each channel separately */
-
+
std::vector<float *> chan_bufs;
-
+
for (uint32_t i = 0; i < channels; ++i) {
chan_bufs.push_back(new float[buffer_size]);
}
-
+
/* de-interleave and write files */
-
+
while ((frames_read = temp_file->read (buf, buffer_size)) > 0) {
for (uint32_t channel = 0; channel < channels; ++channel) {
for (uint32_t i = 0; i < buffer_size; ++i) {
@@ -257,33 +257,33 @@ ExportProcessor::write_files ()
}
disk_sink->write (chan_bufs[channel], frames_read);
}
-
+
if (status->aborted()) { break; }
temp_file_position += frames_read;
status->progress = (float) temp_file_position / temp_file_length;
}
-
+
/* Clean up */
-
+
for (std::vector<float *>::iterator it = chan_bufs.begin(); it != chan_bufs.end(); ++it) {
delete[] *it;
}
-
+
} else {
while ((frames_read = temp_file->read (buf, buffer_size)) > 0) {
disk_sink->write (buf, frames_read);
-
+
if (status->aborted()) { break; }
temp_file_position += frames_read;
status->progress = (float) temp_file_position / temp_file_length;
}
}
-
+
delete [] buf;
-
+
/* Tag files if necessary and send exported signal */
-
-
+
+
for (FileWriterList::iterator it = writer_list.begin(); it != writer_list.end(); ++it) {
if (tag) {
AudiofileTagger::tag_file ((*it)->filename(), session.metadata());