, _dcp_trim_start (0)
, _dcp_trim_end (0)
, _dcp_ab (false)
+ , _use_source_audio (true)
, _audio_stream (-1)
, _audio_gain (0)
, _audio_delay (0)
, _dcp_trim_start (o._dcp_trim_start)
, _dcp_trim_end (o._dcp_trim_end)
, _dcp_ab (o._dcp_ab)
+ , _use_source_audio (o._use_source_audio)
, _audio_stream (o._audio_stream)
+ , _external_audio (o._external_audio)
, _audio_gain (o._audio_gain)
, _audio_delay (o._audio_delay)
, _still_duration (o._still_duration)
f << "dcp_trim_start " << _dcp_trim_start << "\n";
f << "dcp_trim_end " << _dcp_trim_end << "\n";
f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
+ f << "use_source_audio " << (_use_source_audio ? "1" : "0") << "\n";
f << "selected_audio_stream " << _audio_stream << "\n";
+ for (vector<string>::const_iterator i = _external_audio.begin(); i != _external_audio.end(); ++i) {
+ f << "external_audio " << *i << "\n";
+ }
f << "audio_gain " << _audio_gain << "\n";
f << "audio_delay " << _audio_delay << "\n";
f << "still_duration " << _still_duration << "\n";
Film::read_metadata ()
{
boost::mutex::scoped_lock lm (_state_mutex);
+
+ _external_audio.clear ();
+ _thumbs.clear ();
+ _audio_streams.clear ();
+ _subtitle_streams.clear ();
ifstream f (file ("metadata").c_str());
multimap<string, string> kv = read_key_value (f);
_dcp_trim_end = atoi (v.c_str ());
} else if (k == "dcp_ab") {
_dcp_ab = (v == "1");
+ } else if (k == "use_source_audio") {
+ _use_source_audio = (v == "1");
} else if (k == "selected_audio_stream") {
_audio_stream = atoi (v.c_str ());
+ } else if (k == "external_audio") {
+ _external_audio.push_back (v);
} else if (k == "audio_gain") {
_audio_gain = atof (v.c_str ());
} else if (k == "audio_delay") {
string
Film::dci_name () const
{
- boost::mutex::scoped_lock lm (_state_mutex);
-
stringstream d;
- string fixed_name = to_upper_copy (_name);
+ string fixed_name = to_upper_copy (name());
for (size_t i = 0; i < fixed_name.length(); ++i) {
if (fixed_name[i] == ' ') {
fixed_name[i] = '-';
d << fixed_name << "_";
- if (_dcp_content_type) {
- d << _dcp_content_type->dci_name() << "_";
+ if (dcp_content_type()) {
+ d << dcp_content_type()->dci_name() << "_";
}
- if (_format) {
- d << _format->dci_name() << "_";
+ if (format()) {
+ d << format()->dci_name() << "_";
}
- if (!_audio_language.empty ()) {
- d << _audio_language;
- if (!_subtitle_language.empty() && _with_subtitles) {
- d << "-" << _subtitle_language;
+ if (!audio_language().empty ()) {
+ d << audio_language();
+ if (!subtitle_language().empty() && with_subtitles()) {
+ d << "-" << subtitle_language();
} else {
d << "-XX";
}
d << "_";
}
- if (!_territory.empty ()) {
- d << _territory;
- if (!_rating.empty ()) {
- d << "-" << _rating;
+ if (!territory().empty ()) {
+ d << territory();
+ if (!rating().empty ()) {
+ d << "-" << rating();
}
d << "_";
}
- switch (_audio_streams[_audio_stream].channels()) {
+ switch (audio_channels()) {
case 1:
d << "10_";
break;
d << "2K_";
- if (!_studio.empty ()) {
- d << _studio << "_";
+ if (!studio().empty ()) {
+ d << studio() << "_";
}
d << boost::gregorian::to_iso_string (_dci_date) << "_";
- if (!_facility.empty ()) {
- d << _facility << "_";
+ if (!facility().empty ()) {
+ d << facility() << "_";
}
- if (!_package_type.empty ()) {
- d << _package_type;
+ if (!package_type().empty ()) {
+ d << package_type();
}
return d.str ();
signal_changed (DCP_AB);
}
+void
+Film::set_use_source_audio (bool s)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _use_source_audio = s;
+ }
+ signal_changed (USE_SOURCE_AUDIO);
+}
+
void
Film::set_audio_stream (int s)
{
signal_changed (AUDIO_STREAM);
}
+void
+Film::set_external_audio (vector<string> a)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _external_audio = a;
+ }
+ signal_changed (EXTERNAL_AUDIO);
+}
+
void
Film::set_audio_gain (float g)
{
Film::audio_channels () const
{
boost::mutex::scoped_lock lm (_state_mutex);
- if (_audio_stream == -1) {
- return 0;
- }
- return _audio_streams[_audio_stream].channels ();
+ if (_use_source_audio) {
+ if (_audio_stream >= 0) {
+ return _audio_streams[_audio_stream].channels ();
+ }
+ } else {
+ int last_filled = -1;
+ for (size_t i = 0; i < _external_audio.size(); ++i) {
+ if (!_external_audio[i].empty()) {
+ last_filled = i;
+ }
+ }
+
+ return last_filled + 1;
+ }
+
+ return 0;
}
void
DCP_TRIM_START,
DCP_TRIM_END,
DCP_AB,
+ USE_SOURCE_AUDIO,
AUDIO_STREAM,
+ EXTERNAL_AUDIO,
AUDIO_GAIN,
AUDIO_DELAY,
STILL_DURATION,
return _dcp_ab;
}
+ bool use_source_audio () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _use_source_audio;
+ }
+
int audio_stream_index () const {
boost::mutex::scoped_lock lm (_state_mutex);
return _audio_stream;
assert (_audio_stream < int (_audio_streams.size()));
return _audio_streams[_audio_stream];
}
+
+ std::vector<std::string> external_audio () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _external_audio;
+ }
float audio_gain () const {
boost::mutex::scoped_lock lm (_state_mutex);
void set_dcp_trim_start (int);
void set_dcp_trim_end (int);
void set_dcp_ab (bool);
+ void set_use_source_audio (bool);
void set_audio_stream (int);
+ void set_external_audio (std::vector<std::string>);
void set_audio_gain (float);
void set_audio_delay (int);
void set_still_duration (int);
has the specified filters and post-processing.
*/
bool _dcp_ab;
+ bool _use_source_audio;
/** An index into our _audio_streams vector for the stream to use for audio, or -1 if there is none */
int _audio_stream;
+ std::vector<std::string> _external_audio;
/** Gain to apply to audio in dB */
float _audio_gain;
/** Delay to apply to audio (positive moves audio later) in milliseconds */
#define TIMING(...)
#endif
+#define MAX_AUDIO_CHANNELS 6
+
class Scaler;
extern std::string seconds_to_hms (int);
_audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
_use_source_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
_use_external_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ _external_audio[i]->Connect (
+ wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::external_audio_changed), 0, this
+ );
+ }
}
void
_audio_sizer->Add (video_control (_use_external_audio));
_audio_sizer->AddSpacer (0);
+ assert (MAX_AUDIO_CHANNELS == 6);
+
char const * channels[] = {
"L",
"R",
"Rs"
};
- for (int i = 0; i < 6; ++i) {
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
add_label_to_sizer (_audio_sizer, _audio_panel, channels[i]);
- _external_audio_channel[i] = new wxFilePickerCtrl (_audio_panel, wxID_ANY, wxT (""), wxT ("Select Audio File"), wxT ("*.wav"));
- _audio_sizer->Add (video_control (_external_audio_channel[i]), 1, wxEXPAND);
+ _external_audio[i] = new wxFilePickerCtrl (_audio_panel, wxID_ANY, wxT (""), wxT ("Select Audio File"), wxT ("*.wav"));
+ _audio_sizer->Add (video_control (_external_audio[i]), 1, wxEXPAND);
}
_audio_gain->SetRange (-60, 60);
case Film::SUBTITLE_STREAM:
checked_set (_subtitle_stream, _film->subtitle_stream_index ());
break;
+ case Film::USE_SOURCE_AUDIO:
+ checked_set (_use_source_audio, _film->use_source_audio ());
+ checked_set (_use_external_audio, !_film->use_source_audio ());
+ setup_audio_control_sensitivity ();
+ break;
+ case Film::EXTERNAL_AUDIO:
+ {
+ vector<string> a = _film->external_audio ();
+ for (size_t i = 0; i < a.size() && i < MAX_AUDIO_CHANNELS; ++i) {
+ checked_set (_external_audio[i], a[i]);
+ }
+ break;
+ }
}
}
film_changed (Film::DCP_TRIM_START);
film_changed (Film::DCP_TRIM_END);
film_changed (Film::DCP_AB);
+ film_changed (Film::USE_SOURCE_AUDIO);
+ film_changed (Film::AUDIO_STREAM);
+ film_changed (Film::EXTERNAL_AUDIO);
film_changed (Film::SIZE);
film_changed (Film::LENGTH);
film_changed (Film::FRAMES_PER_SECOND);
bool const external = _generally_sensitive && _use_external_audio->GetValue();
_audio_stream->Enable (source);
- for (int i = 0; i < 6; ++i) {
- _external_audio_channel[i]->Enable (external);
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ _external_audio[i]->Enable (external);
}
}
void
FilmEditor::use_audio_changed (wxCommandEvent &)
{
+ _film->set_use_source_audio (_use_source_audio->GetValue ());
setup_audio_control_sensitivity ();
}
+
+void
+FilmEditor::external_audio_changed (wxCommandEvent &)
+{
+ vector<string> a;
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ a.push_back (wx_to_std (_external_audio[i]->GetPath()));
+ }
+
+ _film->set_external_audio (a);
+}
void audio_stream_changed (wxCommandEvent &);
void subtitle_stream_changed (wxCommandEvent &);
void use_audio_changed (wxCommandEvent &);
+ void external_audio_changed (wxCommandEvent &);
/* Handle changes to the model */
void film_changed (Film::Property);
wxRadioButton* _use_source_audio;
wxComboBox* _audio_stream;
wxRadioButton* _use_external_audio;
- wxFilePickerCtrl* _external_audio_channel[6];
+ wxFilePickerCtrl* _external_audio[MAX_AUDIO_CHANNELS];
/** The Film's audio gain */
wxSpinCtrl* _audio_gain;
/** A button to open the gain calculation dialogue */
widget->SetValue (value);
}
}
+
+void
+checked_set (wxRadioButton* widget, bool value)
+{
+ if (widget->GetValue() != value) {
+ widget->SetValue (value);
+ }
+}
extern void checked_set (wxComboBox* widget, int value);
extern void checked_set (wxTextCtrl* widget, std::string value);
extern void checked_set (wxCheckBox* widget, bool value);
+extern void checked_set (wxRadioButton* widget, bool value);