enum SampleRate {
SR_None = 0,
+ SR_Session = 1,
SR_22_05 = 220500,
SR_44_1 = 44100,
SR_48 = 48000,
void set_extension (std::string const & extension) { _extension = extension; }
std::string const & extension () const { return _extension; }
+
+ static SampleRate nearest_sample_rate (framecnt_t sample_rate);
protected:
class ExportFormatLinear : public ExportFormat, public HasSampleFormat {
public:
- ExportFormatLinear (std::string name, FormatId format_id);
+ ExportFormatLinear (std::string name, FormatId format_id);
~ExportFormatLinear () {};
bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
REGISTER (_ExportFormatBase_Quality);
REGISTER_CLASS_ENUM (ExportFormatBase, SR_None);
+ REGISTER_CLASS_ENUM (ExportFormatBase, SR_Session);
REGISTER_CLASS_ENUM (ExportFormatBase, SR_22_05);
REGISTER_CLASS_ENUM (ExportFormatBase, SR_44_1);
REGISTER_CLASS_ENUM (ExportFormatBase, SR_48);
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
void
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_44_1, "44,1 kHz")));
add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_48, "48 kHz")));
set_silence_beginning (other.silence_beginning_time());
set_silence_end (other.silence_end_time());
+
+ set_extension(other.extension());
}
ExportFormatSpecification::~ExportFormatSpecification ()
case SR_192:
desc += "192 kHz";
break;
+ case SR_Session:
+ desc += _("Session rate");
+ break;
case SR_None:
break;
}
add_sample_rate (SR_88_2);
add_sample_rate (SR_96);
add_sample_rate (SR_192);
+ add_sample_rate (SR_Session);
add_endianness (E_FileDefault);
add_sample_rate (SR_88_2);
add_sample_rate (SR_96);
add_sample_rate (SR_192);
+ add_sample_rate (SR_Session);
add_endianness (E_FileDefault);
add_sample_rate (SR_88_2);
add_sample_rate (SR_96);
add_sample_rate (SR_192);
+ add_sample_rate (SR_Session);
add_sample_format (SF_8);
add_sample_format (SF_16);
add_sample_rate (SR_88_2);
add_sample_rate (SR_96);
add_sample_rate (SR_192);
+ add_sample_rate (SR_Session);
add_sample_format (SF_U8);
add_sample_format (SF_16);
void
ExportGraphBuilder::add_config (FileSpec const & config)
{
- if (!config.channel_config->get_split ()) {
- add_split_config (config);
+ // If the sample rate is "session rate", change it to the real value.
+ // 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;
}
// each corresponding to a file, at this stage
typedef std::list<boost::shared_ptr<ExportChannelConfiguration> > ConfigList;
ConfigList file_configs;
- config.channel_config->configurations_for_files (file_configs);
+ new_config.channel_config->configurations_for_files (file_configs);
unsigned chan = 1;
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.filename.reset (new ExportFilename (*copy.filename));