void
Encoder::write_audio (shared_ptr<const AudioBuffers> data)
{
- AudioMapping m (_film->audio_channels ());
+ AudioMapping m (_film);
if (m.dcp_channels() != _film->audio_channels()) {
- /* Remap (currently just for mono -> 5.1) */
+ /* Remap and pad with silence */
shared_ptr<AudioBuffers> b (new AudioBuffers (m.dcp_channels(), data->frames ()));
for (int i = 0; i < m.dcp_channels(); ++i) {
, _j2k_bandwidth (200000000)
, _dci_metadata (Config::instance()->default_dci_metadata ())
, _dcp_frame_rate (0)
+ , _minimum_audio_channels (0)
, _source_frame_rate (0)
, _dirty (false)
{
, _dci_metadata (o._dci_metadata)
, _dci_date (o._dci_date)
, _dcp_frame_rate (o._dcp_frame_rate)
+ , _minimum_audio_channels (o._minimum_audio_channels)
, _size (o._size)
, _length (o._length)
, _content_digest (o._content_digest)
_dci_metadata.write (f);
f << "dci_date " << boost::gregorian::to_iso_string (_dci_date) << endl;
f << "dcp_frame_rate " << _dcp_frame_rate << endl;
+ f << "minimum_audio_channels " << _minimum_audio_channels << endl;
f << "width " << _size.width << endl;
f << "height " << _size.height << endl;
f << "length " << _length.get_value_or(0) << endl;
_dci_date = boost::gregorian::from_undelimited_string (v);
} else if (k == "dcp_frame_rate") {
_dcp_frame_rate = atoi (v.c_str ());
+ } else if (k == "minimum_audio_channels") {
+ _minimum_audio_channels = atoi (v.c_str ());
}
_dci_metadata.read (k, v);
signal_changed (DCP_FRAME_RATE);
}
+void
+Film::set_minimum_audio_channels (int c)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _minimum_audio_channels = c;
+ }
+ signal_changed (MINIMUM_AUDIO_CHANNELS);
+}
+
void
Film::set_size (libdcp::Size s)
{
CONTENT_AUDIO_STREAMS,
SUBTITLE_STREAMS,
SOURCE_FRAME_RATE,
- DCP_FRAME_RATE
+ DCP_FRAME_RATE,
+ MINIMUM_AUDIO_CHANNELS
};
return _source_frame_rate;
}
+ int minimum_audio_channels () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _minimum_audio_channels;
+ }
+
boost::shared_ptr<AudioStream> audio_stream () const;
bool has_audio () const;
void set_content_audio_streams (std::vector<boost::shared_ptr<AudioStream> >);
void set_subtitle_streams (std::vector<boost::shared_ptr<SubtitleStream> >);
void set_source_frame_rate (float);
+ void set_minimum_audio_channels (int);
/** Emitted when some property has changed */
mutable boost::signals2::signal<void (Property)> Changed;
boost::gregorian::date _dci_date;
/** Frames per second to run our DCP at */
int _dcp_frame_rate;
+ int _minimum_audio_channels;
/* Data which are cached to speed things up */
/* Set up the decoder to use the film's set streams */
_decoders.video->set_subtitle_stream (f->subtitle_stream ());
if (f->audio_stream ()) {
- _decoders.audio->set_audio_stream (f->audio_stream ());
+ _decoders.audio->set_audio_stream (f->audio_stream ());
}
_decoders.video->connect_video (_delay_line);
#include "filter.h"
#include "sound_processor.h"
#include "config.h"
+#include "film.h"
#ifdef DVDOMATIC_WINDOWS
#include "stack.hpp"
#endif
return channels[c];
}
-AudioMapping::AudioMapping (int c)
- : _source_channels (c)
+AudioMapping::AudioMapping (shared_ptr<const Film> f)
+ : _source_channels (f->audio_stream() ? f->audio_stream()->channels() : 0)
+ , _minimum_channels (f->minimum_audio_channels ())
{
}
return static_cast<int> (c);
}
+/** @return minimum number of DCP channels that we can allow in this
+ DCP, given the nature of the source.
+*/
int
-AudioMapping::dcp_channels () const
+AudioMapping::minimum_dcp_channels () const
{
if (_source_channels == 1) {
/* The source is mono, so to put the mono channel into
return _source_channels;
}
+/** @return number of channels that there should be in the DCP, including
+ * any silent padded ones.
+ */
+int
+AudioMapping::dcp_channels () const
+{
+ return max (_source_channels, _minimum_channels);
+}
+
FrameRateConversion::FrameRateConversion (float source, int dcp)
: skip (false)
, repeat (false)
#define MAX_AUDIO_CHANNELS 6
class Scaler;
+class Film;
extern std::string seconds_to_hms (int);
extern std::string seconds_to_approximate_hms (int);
class AudioMapping
{
public:
- AudioMapping (int);
+ AudioMapping (boost::shared_ptr<const Film>);
boost::optional<libdcp::Channel> source_to_dcp (int c) const;
boost::optional<int> dcp_to_source (libdcp::Channel c) const;
+
+ int minimum_dcp_channels () const;
int dcp_channels () const;
private:
int _source_channels;
+ int _minimum_channels;
};
extern int64_t video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float frames_per_second);
_picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0);
- AudioMapping m (_film->audio_channels ());
+ AudioMapping m (_film);
if (m.dcp_channels() > 0) {
_sound_asset.reset (
add_item (file, _("&Properties..."), ID_file_properties, NEEDS_FILM);
#ifndef __WXOSX__
file->AppendSeparator ();
-#endif
+#endif
add_item (file, _("&Exit"), wxID_EXIT, ALWAYS);
#ifdef __WXOSX__
return;
}
- AudioMapping m (_film->audio_stream()->channels ());
+ AudioMapping m (_film);
for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
if (m.dcp_to_source(static_cast<libdcp::Channel>(i))) {
_plot->set_analysis (a);
- AudioMapping m (_film->audio_stream()->channels ());
+ AudioMapping m (_film);
optional<libdcp::Channel> c = m.source_to_dcp (0);
if (c) {
_channel_checkbox[c.get()]->SetValue (true);
assert (c < MAX_AUDIO_CHANNELS);
- AudioMapping m (_film->audio_stream()->channels ());
+ AudioMapping m (_film);
optional<int> s = m.dcp_to_source (static_cast<libdcp::Channel> (c));
if (s) {
_plot->set_channel_visible (s.get(), _channel_checkbox[c]->GetValue ());
_dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
_dcp_frame_rate->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
_best_dcp_frame_rate->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
+ _pad_with_silence->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::pad_with_silence_toggled), 0, this);
+ _minimum_audio_channels->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::minimum_audio_channels_changed), 0, this);
_dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
_still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
_trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::trim_start_changed), 0, this);
grid->Add (s);
}
+ {
+ _pad_with_silence = new wxCheckBox (_audio_panel, wxID_ANY, _("Pad with silence to"));
+ grid->Add (_pad_with_silence);
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _minimum_audio_channels = new wxSpinCtrl (_audio_panel);
+ s->Add (_minimum_audio_channels, 1);
+ add_label_to_sizer (s, _audio_panel, _("channels"));
+ grid->Add (s);
+ }
+
{
_use_content_audio = new wxRadioButton (_audio_panel, wxID_ANY, _("Use content's audio"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
grid->Add (video_control (_use_content_audio));
_audio_gain->SetRange (-60, 60);
_audio_delay->SetRange (-1000, 1000);
+ _minimum_audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
}
void
setup_streams ();
setup_show_audio_sensitivity ();
setup_frame_rate_description ();
+ setup_minimum_audio_channels ();
break;
case Film::TRUST_CONTENT_HEADER:
checked_set (_trust_content_header, _film->trust_content_header ());
setup_streams ();
setup_show_audio_sensitivity ();
setup_frame_rate_description ();
+ setup_minimum_audio_channels ();
break;
case Film::FORMAT:
{
setup_audio_control_sensitivity ();
setup_show_audio_sensitivity ();
setup_frame_rate_description ();
+ setup_minimum_audio_channels ();
break;
case Film::USE_CONTENT_AUDIO:
_film->log()->log (String::compose ("Film::USE_CONTENT_AUDIO changed; setting GUI using %1", _film->use_content_audio ()));
setup_audio_control_sensitivity ();
setup_show_audio_sensitivity ();
setup_frame_rate_description ();
+ setup_minimum_audio_channels ();
break;
case Film::SUBTITLE_STREAM:
if (_film->subtitle_stream()) {
setup_audio_details ();
setup_show_audio_sensitivity ();
setup_frame_rate_description ();
+ setup_minimum_audio_channels ();
break;
}
case Film::DCP_FRAME_RATE:
}
setup_frame_rate_description ();
+ case Film::MINIMUM_AUDIO_CHANNELS:
+ checked_set (_minimum_audio_channels, _film->minimum_audio_channels ());
+ setup_minimum_audio_channels ();
+ break;
}
}
for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
_external_audio[i]->Enable (external);
}
+
+ _pad_with_silence->Enable (_generally_sensitive && _film && _film->audio_stream() && _film->audio_stream()->channels() < MAX_AUDIO_CHANNELS);
+ _minimum_audio_channels->Enable (_generally_sensitive && _pad_with_silence->GetValue ());
}
void
{
_film->set_trim_type (_trim_type->GetSelection () == 0 ? Film::CPL : Film::ENCODE);
}
+
+void
+FilmEditor::setup_minimum_audio_channels ()
+{
+ if (!_film || !_film->audio_stream ()) {
+ _pad_with_silence->SetValue (false);
+ return;
+ }
+
+ _pad_with_silence->SetValue (_film->audio_stream()->channels() < _film->minimum_audio_channels());
+
+ AudioMapping m (_film);
+ _minimum_audio_channels->SetRange (m.minimum_dcp_channels(), MAX_AUDIO_CHANNELS);
+}
+
+void
+FilmEditor::pad_with_silence_toggled (wxCommandEvent &)
+{
+ setup_audio_control_sensitivity ();
+}
+
+void
+FilmEditor::minimum_audio_channels_changed (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _film->set_minimum_audio_channels (_minimum_audio_channels->GetValue ());
+}
void external_audio_changed (wxCommandEvent &);
void dcp_frame_rate_changed (wxCommandEvent &);
void best_dcp_frame_rate_clicked (wxCommandEvent &);
+ void pad_with_silence_toggled (wxCommandEvent &);
+ void minimum_audio_channels_changed (wxCommandEvent &);
/* Handle changes to the model */
void film_changed (Film::Property);
void setup_scaling_description ();
void setup_notebook_size ();
void setup_frame_rate_description ();
+ void setup_minimum_audio_channels ();
wxControl* video_control (wxControl *);
wxControl* still_control (wxControl *);
wxStaticText* _source_frame_rate;
wxChoice* _dcp_frame_rate;
wxButton* _best_dcp_frame_rate;
+ wxCheckBox* _pad_with_silence;
+ wxSpinCtrl* _minimum_audio_channels;
wxStaticText* _frame_rate_description;
/** The Film's length */
wxStaticText* _length;