Add "session rate" as a possible sample rate for export formats
git-svn-id: svn://localhost/ardour2/branches/3.0@8294 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -94,6 +94,7 @@ class ExportFormatBase {
|
|||||||
|
|
||||||
enum SampleRate {
|
enum SampleRate {
|
||||||
SR_None = 0,
|
SR_None = 0,
|
||||||
|
SR_Session = 1,
|
||||||
SR_22_05 = 220500,
|
SR_22_05 = 220500,
|
||||||
SR_44_1 = 44100,
|
SR_44_1 = 44100,
|
||||||
SR_48 = 48000,
|
SR_48 = 48000,
|
||||||
@@ -162,6 +163,8 @@ class ExportFormatBase {
|
|||||||
|
|
||||||
void set_extension (std::string const & extension) { _extension = extension; }
|
void set_extension (std::string const & extension) { _extension = extension; }
|
||||||
std::string const & extension () const { return _extension; }
|
std::string const & extension () const { return _extension; }
|
||||||
|
|
||||||
|
static SampleRate nearest_sample_rate (framecnt_t sample_rate);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class HasSampleFormat : public PBD::ScopedConnectionList {
|
|||||||
class ExportFormatLinear : public ExportFormat, public HasSampleFormat {
|
class ExportFormatLinear : public ExportFormat, public HasSampleFormat {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ExportFormatLinear (std::string name, FormatId format_id);
|
ExportFormatLinear (std::string name, FormatId format_id);
|
||||||
~ExportFormatLinear () {};
|
~ExportFormatLinear () {};
|
||||||
|
|
||||||
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
|
||||||
|
|||||||
@@ -487,6 +487,7 @@ setup_enum_writer ()
|
|||||||
REGISTER (_ExportFormatBase_Quality);
|
REGISTER (_ExportFormatBase_Quality);
|
||||||
|
|
||||||
REGISTER_CLASS_ENUM (ExportFormatBase, SR_None);
|
REGISTER_CLASS_ENUM (ExportFormatBase, SR_None);
|
||||||
|
REGISTER_CLASS_ENUM (ExportFormatBase, SR_Session);
|
||||||
REGISTER_CLASS_ENUM (ExportFormatBase, SR_22_05);
|
REGISTER_CLASS_ENUM (ExportFormatBase, SR_22_05);
|
||||||
REGISTER_CLASS_ENUM (ExportFormatBase, SR_44_1);
|
REGISTER_CLASS_ENUM (ExportFormatBase, SR_44_1);
|
||||||
REGISTER_CLASS_ENUM (ExportFormatBase, SR_48);
|
REGISTER_CLASS_ENUM (ExportFormatBase, SR_48);
|
||||||
|
|||||||
@@ -198,4 +198,30 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExportFormatBase::SampleRate
|
||||||
|
ExportFormatBase::nearest_sample_rate (framecnt_t sample_rate)
|
||||||
|
{
|
||||||
|
int diff = 0;
|
||||||
|
int smallest_diff = INT_MAX;
|
||||||
|
SampleRate best_match = SR_None;
|
||||||
|
|
||||||
|
#define DO_SR_COMPARISON(rate) \
|
||||||
|
diff = std::abs((rate) - sample_rate); \
|
||||||
|
if(diff < smallest_diff) { \
|
||||||
|
smallest_diff = diff; \
|
||||||
|
best_match = (rate); \
|
||||||
|
}
|
||||||
|
|
||||||
|
DO_SR_COMPARISON(SR_22_05);
|
||||||
|
DO_SR_COMPARISON(SR_22_05);
|
||||||
|
DO_SR_COMPARISON(SR_44_1);
|
||||||
|
DO_SR_COMPARISON(SR_48);
|
||||||
|
DO_SR_COMPARISON(SR_88_2);
|
||||||
|
DO_SR_COMPARISON(SR_96);
|
||||||
|
DO_SR_COMPARISON(SR_192);
|
||||||
|
|
||||||
|
return best_match;
|
||||||
|
#undef DO_SR_COMPARISON
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace ARDOUR
|
}; // namespace ARDOUR
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ ExportFormatManager::init_formats ()
|
|||||||
void
|
void
|
||||||
ExportFormatManager::init_sample_rates ()
|
ExportFormatManager::init_sample_rates ()
|
||||||
{
|
{
|
||||||
|
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_Session, _("Session rate"))));
|
||||||
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_22_05, "22,05 kHz")));
|
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_22_05, "22,05 kHz")));
|
||||||
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_44_1, "44,1 kHz")));
|
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_44_1, "44,1 kHz")));
|
||||||
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_48, "48 kHz")));
|
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_48, "48 kHz")));
|
||||||
|
|||||||
@@ -230,6 +230,8 @@ ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification
|
|||||||
|
|
||||||
set_silence_beginning (other.silence_beginning_time());
|
set_silence_beginning (other.silence_beginning_time());
|
||||||
set_silence_end (other.silence_end_time());
|
set_silence_end (other.silence_end_time());
|
||||||
|
|
||||||
|
set_extension(other.extension());
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportFormatSpecification::~ExportFormatSpecification ()
|
ExportFormatSpecification::~ExportFormatSpecification ()
|
||||||
@@ -556,6 +558,9 @@ ExportFormatSpecification::description ()
|
|||||||
case SR_192:
|
case SR_192:
|
||||||
desc += "192 kHz";
|
desc += "192 kHz";
|
||||||
break;
|
break;
|
||||||
|
case SR_Session:
|
||||||
|
desc += _("Session rate");
|
||||||
|
break;
|
||||||
case SR_None:
|
case SR_None:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ ExportFormatLinear::ExportFormatLinear (string name, FormatId format_id) :
|
|||||||
add_sample_rate (SR_88_2);
|
add_sample_rate (SR_88_2);
|
||||||
add_sample_rate (SR_96);
|
add_sample_rate (SR_96);
|
||||||
add_sample_rate (SR_192);
|
add_sample_rate (SR_192);
|
||||||
|
add_sample_rate (SR_Session);
|
||||||
|
|
||||||
add_endianness (E_FileDefault);
|
add_endianness (E_FileDefault);
|
||||||
|
|
||||||
@@ -262,6 +263,7 @@ ExportFormatOggVorbis::ExportFormatOggVorbis ()
|
|||||||
add_sample_rate (SR_88_2);
|
add_sample_rate (SR_88_2);
|
||||||
add_sample_rate (SR_96);
|
add_sample_rate (SR_96);
|
||||||
add_sample_rate (SR_192);
|
add_sample_rate (SR_192);
|
||||||
|
add_sample_rate (SR_Session);
|
||||||
|
|
||||||
add_endianness (E_FileDefault);
|
add_endianness (E_FileDefault);
|
||||||
|
|
||||||
@@ -301,6 +303,7 @@ ExportFormatFLAC::ExportFormatFLAC () :
|
|||||||
add_sample_rate (SR_88_2);
|
add_sample_rate (SR_88_2);
|
||||||
add_sample_rate (SR_96);
|
add_sample_rate (SR_96);
|
||||||
add_sample_rate (SR_192);
|
add_sample_rate (SR_192);
|
||||||
|
add_sample_rate (SR_Session);
|
||||||
|
|
||||||
add_sample_format (SF_8);
|
add_sample_format (SF_8);
|
||||||
add_sample_format (SF_16);
|
add_sample_format (SF_16);
|
||||||
@@ -334,6 +337,7 @@ ExportFormatBWF::ExportFormatBWF () :
|
|||||||
add_sample_rate (SR_88_2);
|
add_sample_rate (SR_88_2);
|
||||||
add_sample_rate (SR_96);
|
add_sample_rate (SR_96);
|
||||||
add_sample_rate (SR_192);
|
add_sample_rate (SR_192);
|
||||||
|
add_sample_rate (SR_Session);
|
||||||
|
|
||||||
add_sample_format (SF_U8);
|
add_sample_format (SF_U8);
|
||||||
add_sample_format (SF_16);
|
add_sample_format (SF_16);
|
||||||
|
|||||||
@@ -77,8 +77,18 @@ ExportGraphBuilder::reset ()
|
|||||||
void
|
void
|
||||||
ExportGraphBuilder::add_config (FileSpec const & config)
|
ExportGraphBuilder::add_config (FileSpec const & config)
|
||||||
{
|
{
|
||||||
if (!config.channel_config->get_split ()) {
|
// If the sample rate is "session rate", change it to the real value.
|
||||||
add_split_config (config);
|
// However, we need to copy it to not change the config which is saved...
|
||||||
|
FileSpec new_config (config);
|
||||||
|
new_config.format.reset(new ExportFormatSpecification(*new_config.format));
|
||||||
|
if(new_config.format->sample_rate() == ExportFormatBase::SR_Session) {
|
||||||
|
framecnt_t session_rate = session.nominal_frame_rate();
|
||||||
|
new_config.format->set_sample_rate(ExportFormatBase::nearest_sample_rate(session_rate));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!new_config.channel_config->get_split ()) {
|
||||||
|
add_split_config (new_config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,11 +96,11 @@ ExportGraphBuilder::add_config (FileSpec const & config)
|
|||||||
// each corresponding to a file, at this stage
|
// each corresponding to a file, at this stage
|
||||||
typedef std::list<boost::shared_ptr<ExportChannelConfiguration> > ConfigList;
|
typedef std::list<boost::shared_ptr<ExportChannelConfiguration> > ConfigList;
|
||||||
ConfigList file_configs;
|
ConfigList file_configs;
|
||||||
config.channel_config->configurations_for_files (file_configs);
|
new_config.channel_config->configurations_for_files (file_configs);
|
||||||
|
|
||||||
unsigned chan = 1;
|
unsigned chan = 1;
|
||||||
for (ConfigList::iterator it = file_configs.begin(); it != file_configs.end(); ++it, ++chan) {
|
for (ConfigList::iterator it = file_configs.begin(); it != file_configs.end(); ++it, ++chan) {
|
||||||
FileSpec copy = config;
|
FileSpec copy = new_config;
|
||||||
copy.channel_config = *it;
|
copy.channel_config = *it;
|
||||||
|
|
||||||
copy.filename.reset (new ExportFilename (*copy.filename));
|
copy.filename.reset (new ExportFilename (*copy.filename));
|
||||||
|
|||||||
Reference in New Issue
Block a user