Finally implement position aware silence adding in export (i.e. bbt times are converted to frames correctly)
This will work when Session::convert_to_frames_at is fixed :) git-svn-id: svn://localhost/ardour2/branches/3.0@8295 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ffadfff650
commit
94c69b3c91
|
@ -228,11 +228,11 @@ ExportFormatDialog::load_state (FormatPtr spec)
|
|||
|
||||
trim_start_checkbox.set_active (spec->trim_beginning());
|
||||
silence_start = spec->silence_beginning_time();
|
||||
silence_start_checkbox.set_active (spec->silence_beginning() > 0);
|
||||
silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
|
||||
|
||||
trim_end_checkbox.set_active (spec->trim_end());
|
||||
silence_end = spec->silence_end_time();
|
||||
silence_end_checkbox.set_active (spec->silence_end() > 0);
|
||||
silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
|
||||
|
||||
for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
|
||||
if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class ExportFormatSpecification : public ExportFormatBase {
|
|||
Time (Session & session) : AnyTime (), session (session) {}
|
||||
Time & operator= (AnyTime const & other);
|
||||
|
||||
framecnt_t get_frames (framecnt_t target_rate) const;
|
||||
framecnt_t get_frames_at (framepos_t position, framecnt_t target_rate) const;
|
||||
|
||||
/* Serialization */
|
||||
|
||||
|
@ -123,11 +123,10 @@ class ExportFormatSpecification : public ExportFormatBase {
|
|||
|
||||
bool tag () const { return _tag && supports_tagging; }
|
||||
|
||||
framecnt_t silence_beginning () const { return _silence_beginning.get_frames (sample_rate()); }
|
||||
framecnt_t silence_end () const { return _silence_end.get_frames (sample_rate()); }
|
||||
|
||||
framecnt_t silence_beginning (framecnt_t samplerate) const { return _silence_beginning.get_frames (samplerate); }
|
||||
framecnt_t silence_end (framecnt_t samplerate) const { return _silence_end.get_frames (samplerate); }
|
||||
framecnt_t silence_beginning_at (framepos_t position, framecnt_t samplerate) const
|
||||
{ return _silence_beginning.get_frames_at (position, samplerate); }
|
||||
framecnt_t silence_end_at (framepos_t position, framecnt_t samplerate) const
|
||||
{ return _silence_end.get_frames_at (position, samplerate); }
|
||||
|
||||
AnyTime silence_beginning_time () const { return _silence_beginning; }
|
||||
AnyTime silence_end_time () const { return _silence_end; }
|
||||
|
|
|
@ -66,6 +66,7 @@ class ExportGraphBuilder
|
|||
bool process_normalize (); // returns true when finished
|
||||
|
||||
void reset ();
|
||||
void set_current_timespan (boost::shared_ptr<ExportTimespan> span);
|
||||
void add_config (FileSpec const & config);
|
||||
|
||||
private:
|
||||
|
@ -214,6 +215,7 @@ class ExportGraphBuilder
|
|||
};
|
||||
|
||||
Session const & session;
|
||||
boost::shared_ptr<ExportTimespan> timespan;
|
||||
|
||||
// Roots for export processor trees
|
||||
typedef boost::ptr_list<ChannelConfig> ChannelConfigList;
|
||||
|
|
|
@ -227,6 +227,36 @@ namespace ARDOUR {
|
|||
};
|
||||
|
||||
AnyTime() { type = Frames; frames = 0; }
|
||||
|
||||
bool operator== (AnyTime const & other) const {
|
||||
if (type != other.type) { return false; }
|
||||
|
||||
switch (type) {
|
||||
case Timecode:
|
||||
return timecode == other.timecode;
|
||||
case BBT:
|
||||
return bbt == other.bbt;
|
||||
case Frames:
|
||||
return frames == other.frames;
|
||||
case Seconds:
|
||||
return seconds == other.seconds;
|
||||
}
|
||||
}
|
||||
|
||||
bool not_zero() const
|
||||
{
|
||||
switch (type) {
|
||||
case Timecode:
|
||||
return timecode.hours != 0 || timecode.minutes != 0 ||
|
||||
timecode.seconds != 0 || timecode.frames != 0;
|
||||
case BBT:
|
||||
return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
|
||||
case Frames:
|
||||
return frames != 0;
|
||||
case Seconds:
|
||||
return seconds != 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct AudioRange {
|
||||
|
|
|
@ -42,25 +42,14 @@ using std::string;
|
|||
ExportFormatSpecification::Time &
|
||||
ExportFormatSpecification::Time::operator= (AnyTime const & other)
|
||||
{
|
||||
type = other.type;
|
||||
timecode = other.timecode;
|
||||
bbt = other.bbt;
|
||||
|
||||
if (type == Frames) {
|
||||
frames = other.frames;
|
||||
} else {
|
||||
seconds = other.seconds;
|
||||
}
|
||||
|
||||
static_cast<AnyTime &>(*this) = other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
framecnt_t
|
||||
ExportFormatSpecification::Time::get_frames (framecnt_t target_rate) const
|
||||
ExportFormatSpecification::Time::get_frames_at (framepos_t position, framecnt_t target_rate) const
|
||||
{
|
||||
//TODO position
|
||||
framecnt_t duration = session.convert_to_frames_at (0, *this);
|
||||
|
||||
framecnt_t duration = session.convert_to_frames_at (position, *this);
|
||||
return ((double) target_rate / session.frame_rate()) * duration + 0.5;
|
||||
}
|
||||
|
||||
|
@ -283,14 +272,14 @@ ExportFormatSpecification::get_state ()
|
|||
node->add_property ("enabled", trim_beginning() ? "true" : "false");
|
||||
|
||||
node = start->add_child ("Add");
|
||||
node->add_property ("enabled", silence_beginning() > 0 ? "true" : "false");
|
||||
node->add_property ("enabled", _silence_beginning.not_zero() ? "true" : "false");
|
||||
node->add_child_nocopy (_silence_beginning.get_state());
|
||||
|
||||
node = end->add_child ("Trim");
|
||||
node->add_property ("enabled", trim_end() ? "true" : "false");
|
||||
|
||||
node = end->add_child ("Add");
|
||||
node->add_property ("enabled", silence_end() > 0 ? "true" : "false");
|
||||
node->add_property ("enabled", _silence_end.not_zero() ? "true" : "false");
|
||||
node->add_child_nocopy (_silence_end.get_state());
|
||||
|
||||
return *root;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "ardour/export_channel_configuration.h"
|
||||
#include "ardour/export_filename.h"
|
||||
#include "ardour/export_format_specification.h"
|
||||
#include "ardour/export_timespan.h"
|
||||
#include "ardour/sndfile_helpers.h"
|
||||
|
||||
#include "pbd/filesystem.h"
|
||||
|
@ -69,11 +70,18 @@ ExportGraphBuilder::process_normalize ()
|
|||
void
|
||||
ExportGraphBuilder::reset ()
|
||||
{
|
||||
timespan.reset();
|
||||
channel_configs.clear ();
|
||||
channels.clear ();
|
||||
normalizers.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
ExportGraphBuilder::set_current_timespan (boost::shared_ptr<ExportTimespan> span)
|
||||
{
|
||||
timespan = span;
|
||||
}
|
||||
|
||||
void
|
||||
ExportGraphBuilder::add_config (FileSpec const & config)
|
||||
{
|
||||
|
@ -391,8 +399,12 @@ ExportGraphBuilder::SilenceHandler::SilenceHandler (ExportGraphBuilder & parent,
|
|||
silence_trimmer.reset (new SilenceTrimmer<Sample>(max_frames_in));
|
||||
silence_trimmer->set_trim_beginning (config.format->trim_beginning());
|
||||
silence_trimmer->set_trim_end (config.format->trim_end());
|
||||
silence_trimmer->add_silence_to_beginning (config.format->silence_beginning(sample_rate));
|
||||
silence_trimmer->add_silence_to_end (config.format->silence_end(sample_rate));
|
||||
|
||||
framecnt_t sb = config.format->silence_beginning_at (parent.timespan->get_start(), sample_rate);
|
||||
framecnt_t se = config.format->silence_end_at (parent.timespan->get_end(), sample_rate);
|
||||
|
||||
silence_trimmer->add_silence_to_beginning (sb);
|
||||
silence_trimmer->add_silence_to_end (se);
|
||||
|
||||
add_child (new_config);
|
||||
}
|
||||
|
@ -424,8 +436,8 @@ ExportGraphBuilder::SilenceHandler::operator== (FileSpec const & other_config) c
|
|||
ExportFormatSpecification & other_format = *other_config.format;
|
||||
return (format.trim_beginning() == other_format.trim_beginning()) &&
|
||||
(format.trim_end() == other_format.trim_end()) &&
|
||||
(format.silence_beginning() == other_format.silence_beginning()) &&
|
||||
(format.silence_end() == other_format.silence_end());
|
||||
(format.silence_beginning_time() == other_format.silence_beginning_time()) &&
|
||||
(format.silence_end_time() == other_format.silence_end_time());
|
||||
}
|
||||
|
||||
/* ChannelConfig */
|
||||
|
|
|
@ -162,6 +162,7 @@ ExportHandler::start_timespan ()
|
|||
|
||||
timespan_bounds = config_map.equal_range (current_timespan);
|
||||
graph_builder->reset ();
|
||||
graph_builder->set_current_timespan (current_timespan);
|
||||
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
|
||||
// Filenames can be shared across timespans
|
||||
FileSpec & spec = it->second;
|
||||
|
|
|
@ -52,6 +52,13 @@ struct Time {
|
|||
subframes = 0;
|
||||
rate = a_rate;
|
||||
}
|
||||
|
||||
bool operator== (const Time& other) const {
|
||||
return negative == other.negative && hours == other.hours &&
|
||||
minutes == other.minutes && seconds == other.seconds &&
|
||||
frames == other.frames && subframes == other.subframes &&
|
||||
rate == other.rate && drop == other.drop;
|
||||
}
|
||||
|
||||
std::ostream& print (std::ostream& ostr) const {
|
||||
if (negative) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user