diff options
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor_export_audio.cc | 30 | ||||
-rw-r--r-- | gtk2_ardour/export_channel_selector.cc | 115 | ||||
-rw-r--r-- | gtk2_ardour/export_channel_selector.h | 61 | ||||
-rw-r--r-- | gtk2_ardour/export_dialog.cc | 31 | ||||
-rw-r--r-- | gtk2_ardour/export_dialog.h | 22 |
5 files changed, 204 insertions, 55 deletions
diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index b382200d38..621482f0f1 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -91,17 +91,25 @@ Editor::export_range () void Editor::export_region () { -// if (selection->regions.empty()) { -// return; -// } -// -// boost::shared_ptr<Region> r = selection->regions.front()->region(); -// -// ExportDialog* dialog = new ExportRegionDialog (*this, r); -// -// dialog->connect_to_session (session); -// dialog->set_range (clicked_regionview->region()->first_frame(), clicked_regionview->region()->last_frame()); -// dialog->start_export(); + if (selection->regions.empty()) { + return; + } + + try { + boost::shared_ptr<Region> r = selection->regions.front()->region(); + AudioRegion & region (dynamic_cast<AudioRegion &> (*r)); + + RouteTimeAxisView & rtv (dynamic_cast<RouteTimeAxisView &> (selection->regions.front()->get_time_axis_view())); + AudioTrack & track (dynamic_cast<AudioTrack &> (*rtv.route())); + + ExportRegionDialog dialog (*this, region, track); + dialog.set_session (session); + dialog.run(); + + } catch (std::bad_cast & e) { + error << "Exporting Region failed!" << endmsg; + return; + } } int diff --git a/gtk2_ardour/export_channel_selector.cc b/gtk2_ardour/export_channel_selector.cc index 41ecec9094..e26d05d7c8 100644 --- a/gtk2_ardour/export_channel_selector.cc +++ b/gtk2_ardour/export_channel_selector.cc @@ -39,7 +39,7 @@ using namespace ARDOUR; using namespace PBD; -ExportChannelSelector::ExportChannelSelector () : +PortExportChannelSelector::PortExportChannelSelector () : channels_label (_("Channels:"), Gtk::ALIGN_LEFT), split_checkbox (_("Split to mono files")), max_channels (20), @@ -68,11 +68,11 @@ ExportChannelSelector::ExportChannelSelector () : channels_spinbutton.set_range (1, max_channels); channels_spinbutton.set_value (2); - channels_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportChannelSelector::update_channel_count)); + channels_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &PortExportChannelSelector::update_channel_count)); /* Other signals */ - split_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportChannelSelector::update_split_state)); + split_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &PortExportChannelSelector::update_split_state)); channel_view.CriticalSelectionChanged.connect (CriticalSelectionChanged.make_slot()); /* Finalize */ @@ -81,7 +81,7 @@ ExportChannelSelector::ExportChannelSelector () : } -ExportChannelSelector::~ExportChannelSelector () +PortExportChannelSelector::~PortExportChannelSelector () { // if (session) { // session->add_instant_xml (get_state(), false); @@ -89,7 +89,7 @@ ExportChannelSelector::~ExportChannelSelector () } void -ExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_) +PortExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_) { state = state_; session = session_; @@ -102,7 +102,7 @@ ExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigSta } void -ExportChannelSelector::fill_route_list () +PortExportChannelSelector::fill_route_list () { channel_view.clear_routes (); Session::RouteList routes = *session->get_routes(); @@ -123,7 +123,7 @@ ExportChannelSelector::fill_route_list () } void -ExportChannelSelector::update_channel_count () +PortExportChannelSelector::update_channel_count () { uint32_t chans = static_cast<uint32_t> (channels_spinbutton.get_value()); channel_view.set_channel_count (chans); @@ -131,14 +131,14 @@ ExportChannelSelector::update_channel_count () } void -ExportChannelSelector::update_split_state () +PortExportChannelSelector::update_split_state () { state->config->set_split (split_checkbox.get_active()); CriticalSelectionChanged(); } void -ExportChannelSelector::RouteCols::add_channels (uint32_t chans) +PortExportChannelSelector::RouteCols::add_channels (uint32_t chans) { while (chans > 0) { channels.push_back (Channel (*this)); @@ -147,8 +147,8 @@ ExportChannelSelector::RouteCols::add_channels (uint32_t chans) } } -ExportChannelSelector::RouteCols::Channel & -ExportChannelSelector::RouteCols::get_channel (uint32_t channel) +PortExportChannelSelector::RouteCols::Channel & +PortExportChannelSelector::RouteCols::get_channel (uint32_t channel) { if (channel > n_channels) { std::cout << "Invalid channel cout for get_channel!" << std::endl; @@ -164,7 +164,7 @@ ExportChannelSelector::RouteCols::get_channel (uint32_t channel) return *it; } -ExportChannelSelector::ChannelTreeView::ChannelTreeView (uint32_t max_channels) : +PortExportChannelSelector::ChannelTreeView::ChannelTreeView (uint32_t max_channels) : n_channels (0) { /* Main columns */ @@ -186,13 +186,13 @@ ExportChannelSelector::ChannelTreeView::ChannelTreeView (uint32_t max_channels) column->add_attribute (text_renderer->property_text(), route_cols.name); Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(get_column_cell_renderer (0)); - toggle->signal_toggled().connect (mem_fun (*this, &ExportChannelSelector::ChannelTreeView::update_toggle_selection)); + toggle->signal_toggled().connect (mem_fun (*this, &PortExportChannelSelector::ChannelTreeView::update_toggle_selection)); static_columns = get_columns().size(); } void -ExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c) +PortExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c) { /* TODO Without the following line, the state might get reset. * Pointing to the same address does not mean the state of the configuration hasn't changed. @@ -208,6 +208,11 @@ ExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c) for (Gtk::ListStore::Children::iterator r_it = route_list->children().begin(); r_it != route_list->children().end(); ++r_it) { + ARDOUR::PortExportChannel * pec; + if (!(pec = dynamic_cast<ARDOUR::PortExportChannel *> (c_it->get()))) { + continue; + } + Glib::RefPtr<Gtk::ListStore> port_list = r_it->get_value (route_cols.port_list_col); std::set<AudioPort *> route_ports; std::set<AudioPort *> intersection; @@ -219,7 +224,7 @@ ExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c) (*p_it)->get_value (route_cols.port_cols.label))); } - std::set_intersection ((*c_it)->begin(), (*c_it)->end(), + std::set_intersection (pec->get_ports().begin(), pec->get_ports().end(), route_ports.begin(), route_ports.end(), std::insert_iterator<std::set<AudioPort *> > (intersection, intersection.begin())); @@ -253,7 +258,7 @@ ExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c) } void -ExportChannelSelector::ChannelTreeView::add_route (ARDOUR::IO * route) +PortExportChannelSelector::ChannelTreeView::add_route (ARDOUR::IO * route) { Gtk::TreeModel::iterator iter = route_list->append(); Gtk::TreeModel::Row row = *iter; @@ -291,7 +296,7 @@ ExportChannelSelector::ChannelTreeView::add_route (ARDOUR::IO * route) } void -ExportChannelSelector::ChannelTreeView::set_channel_count (uint32_t channels) +PortExportChannelSelector::ChannelTreeView::set_channel_count (uint32_t channels) { int offset = channels - n_channels; @@ -315,7 +320,7 @@ ExportChannelSelector::ChannelTreeView::set_channel_count (uint32_t channels) column->add_attribute (combo_renderer->property_model(), route_cols.port_list_col); column->add_attribute (combo_renderer->property_editable(), route_cols.selected); - combo_renderer->signal_edited().connect (sigc::bind (sigc::mem_fun (*this, &ExportChannelSelector::ChannelTreeView::update_selection_text), n_channels)); + combo_renderer->signal_edited().connect (sigc::bind (sigc::mem_fun (*this, &PortExportChannelSelector::ChannelTreeView::update_selection_text), n_channels)); /* put data into view */ @@ -344,7 +349,7 @@ ExportChannelSelector::ChannelTreeView::set_channel_count (uint32_t channels) } void -ExportChannelSelector::ChannelTreeView::update_config () +PortExportChannelSelector::ChannelTreeView::update_config () { if (!config) { return; } @@ -353,7 +358,8 @@ ExportChannelSelector::ChannelTreeView::update_config () for (uint32_t i = 1; i <= n_channels; ++i) { - boost::shared_ptr<ExportChannel> channel (new ExportChannel ()); + ExportChannelPtr channel (new PortExportChannel ()); + PortExportChannel * pec = static_cast<PortExportChannel *> (channel.get()); for (Gtk::ListStore::Children::iterator it = route_list->children().begin(); it != route_list->children().end(); ++it) { Gtk::TreeModel::Row row = *it; @@ -364,7 +370,7 @@ ExportChannelSelector::ChannelTreeView::update_config () AudioPort * port = row[route_cols.get_channel (i).port]; if (port) { - channel->add_port (port); + pec->add_port (port); } } @@ -375,7 +381,7 @@ ExportChannelSelector::ChannelTreeView::update_config () } void -ExportChannelSelector::ChannelTreeView::update_toggle_selection (Glib::ustring const & path) +PortExportChannelSelector::ChannelTreeView::update_toggle_selection (Glib::ustring const & path) { Gtk::TreeModel::iterator iter = get_model ()->get_iter (path); bool selected = iter->get_value (route_cols.selected); @@ -408,7 +414,7 @@ ExportChannelSelector::ChannelTreeView::update_toggle_selection (Glib::ustring c } void -ExportChannelSelector::ChannelTreeView::update_selection_text (Glib::ustring const & path, Glib::ustring const & new_text, uint32_t channel) +PortExportChannelSelector::ChannelTreeView::update_selection_text (Glib::ustring const & path, Glib::ustring const & new_text, uint32_t channel) { Gtk::TreeModel::iterator iter = get_model ()->get_iter (path); iter->set_value (route_cols.get_channel (channel).label, new_text); @@ -425,3 +431,66 @@ ExportChannelSelector::ChannelTreeView::update_selection_text (Glib::ustring con update_config (); } + +RegionExportChannelSelector::RegionExportChannelSelector (ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track) : + session (0), + region (region), + track (track), + region_chans (region.n_channels()), + track_chans (track.n_outputs().n_audio()), + + raw_button (type_group), + processed_button (type_group) +{ + pack_start (vbox); + + raw_button.set_label (string_compose (_("Raw region export, no fades or plugins (%1 channels)"), region_chans)); + raw_button.signal_toggled ().connect (sigc::mem_fun (*this, &RegionExportChannelSelector::handle_selection)); + vbox.pack_start (raw_button); + + processed_button.set_label (string_compose (_("Processed region export with fades and plugins applied (%1 channels)"), track_chans)); + processed_button.signal_toggled ().connect (sigc::mem_fun (*this, &RegionExportChannelSelector::handle_selection)); + vbox.pack_start (processed_button); + + vbox.show_all_children (); + show_all_children (); +} + +void +RegionExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_) +{ + state = state_; + session = session_; + + handle_selection (); +} + +void +RegionExportChannelSelector::handle_selection () +{ + if (!state) { + return; + } + + state->config->clear_channels (); + + if (raw_button.get_active ()) { + + factory.reset (new RegionExportChannelFactory (session, region, track, RegionExportChannelFactory::Raw)); + + for (size_t chan = 0; chan < region_chans; ++chan) { + state->config->register_channel (factory->create (chan)); + } + + } else if (processed_button.get_active ()) { + + factory.reset (new RegionExportChannelFactory(session, region, track, RegionExportChannelFactory::Processed)); + + for (size_t chan = 0; chan < region_chans; ++chan) { + state->config->register_channel (factory->create (chan)); + } + + } + + CriticalSelectionChanged (); +} diff --git a/gtk2_ardour/export_channel_selector.h b/gtk2_ardour/export_channel_selector.h index 0faf652bd8..c2e99940aa 100644 --- a/gtk2_ardour/export_channel_selector.h +++ b/gtk2_ardour/export_channel_selector.h @@ -24,6 +24,7 @@ #include <list> #include <ardour/export_profile_manager.h> +#include <ardour/export_channel.h> #include <gtkmm.h> #include <sigc++/signal.h> @@ -31,31 +32,39 @@ namespace ARDOUR { class Session; - class ExportChannel; class ExportChannelConfiguration; + class RegionExportChannelFactory; class ExportHandler; class AudioPort; class IO; + class AudioRegion; + class AudioTrack; } class XMLNode; -/// -class ExportChannelSelector : public Gtk::HBox { - private: - +class ExportChannelSelector : public Gtk::HBox +{ + protected: typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr; - typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr; public: + virtual ~ExportChannelSelector () {} + + virtual void set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_) = 0; + sigc::signal<void> CriticalSelectionChanged; +}; + +class PortExportChannelSelector : public ExportChannelSelector +{ - ExportChannelSelector (); - ~ExportChannelSelector (); + public: + + PortExportChannelSelector (); + ~PortExportChannelSelector (); void set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_); - - sigc::signal<void> CriticalSelectionChanged; private: @@ -63,8 +72,7 @@ class ExportChannelSelector : public Gtk::HBox { void update_channel_count (); void update_split_state (); - typedef boost::shared_ptr<ARDOUR::ExportChannel> ChannelPtr; - typedef std::list<ChannelPtr> CahnnelList; + typedef std::list<ARDOUR::ExportChannelPtr> CahnnelList; ARDOUR::Session * session; ARDOUR::ExportProfileManager::ChannelConfigStatePtr state; @@ -178,4 +186,33 @@ class ExportChannelSelector : public Gtk::HBox { }; +class RegionExportChannelSelector : public ExportChannelSelector +{ + public: + RegionExportChannelSelector (ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track); + + virtual void set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_); + + private: + + void handle_selection (); + + ARDOUR::Session * session; + ARDOUR::ExportProfileManager::ChannelConfigStatePtr state; + boost::shared_ptr<ARDOUR::RegionExportChannelFactory> factory; + ARDOUR::AudioRegion const & region; + ARDOUR::AudioTrack & track; + + uint32_t region_chans; + uint32_t track_chans; + + /*** GUI components ***/ + + Gtk::VBox vbox; + + Gtk::RadioButtonGroup type_group; + Gtk::RadioButton raw_button; + Gtk::RadioButton processed_button; +}; + #endif /* __export_channel_selector_h__ */ diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index 7ae81a016a..86263c8d3f 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -45,8 +45,6 @@ ExportDialog::~ExportDialog () void ExportDialog::set_session (ARDOUR::Session* s) { - init (); - session = s; /* Init handler and profile manager */ @@ -55,6 +53,12 @@ ExportDialog::set_session (ARDOUR::Session* s) status = session->get_export_status (); profile_manager.reset (new ExportProfileManager (*session)); + /* Possibly init stuff in derived classes */ + + init (); + + /* Rest of session related initialization */ + preset_selector->set_manager (profile_manager); file_notebook->set_session_and_manager (session, profile_manager); @@ -163,7 +167,7 @@ ExportDialog::init_components () { preset_selector.reset (new ExportPresetSelector ()); timespan_selector.reset (new ExportTimespanSelectorMultiple ()); - channel_selector.reset (new ExportChannelSelector ()); + channel_selector.reset (new PortExportChannelSelector ()); file_notebook.reset (new ExportFileNotebook ()); } @@ -358,7 +362,7 @@ ExportRangeDialog::init_components () { preset_selector.reset (new ExportPresetSelector ()); timespan_selector.reset (new ExportTimespanSelectorSingle (range_id)); - channel_selector.reset (new ExportChannelSelector ()); + channel_selector.reset (new PortExportChannelSelector ()); file_notebook.reset (new ExportFileNotebook ()); } @@ -371,6 +375,23 @@ ExportSelectionDialog::init_components () { preset_selector.reset (new ExportPresetSelector ()); timespan_selector.reset (new ExportTimespanSelectorSingle (X_("selection"))); - channel_selector.reset (new ExportChannelSelector ()); + channel_selector.reset (new PortExportChannelSelector ()); + file_notebook.reset (new ExportFileNotebook ()); +} + +ExportRegionDialog::ExportRegionDialog (PublicEditor & editor, ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track) : + ExportDialog (editor, _("Export Region")), + region (region), + track (track) +{} + +void +ExportRegionDialog::init_components () +{ + Glib::ustring loc_id = profile_manager->set_single_range (region.position(), region.position() + region.length(), region.name()); + + preset_selector.reset (new ExportPresetSelector ()); + timespan_selector.reset (new ExportTimespanSelectorSingle (loc_id)); + channel_selector.reset (new RegionExportChannelSelector (region, track)); file_notebook.reset (new ExportFileNotebook ()); } diff --git a/gtk2_ardour/export_dialog.h b/gtk2_ardour/export_dialog.h index c0c5a24b20..0de6c6ffac 100644 --- a/gtk2_ardour/export_dialog.h +++ b/gtk2_ardour/export_dialog.h @@ -63,6 +63,12 @@ class ExportDialog : public ArdourDialog { protected: + typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr; + typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr; + + HandlerPtr handler; + ManagerPtr profile_manager; + // initializes GUI layout virtual void init_gui (); @@ -94,13 +100,9 @@ class ExportDialog : public ArdourDialog { void show_progress (); gint progress_timeout (); - typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr; - typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr; typedef boost::shared_ptr<ARDOUR::ExportStatus> StatusPtr; PublicEditor & editor; - HandlerPtr handler; - ManagerPtr profile_manager; StatusPtr status; /*** GUI components ***/ @@ -153,4 +155,16 @@ class ExportSelectionDialog : public ExportDialog void init_components (); }; +class ExportRegionDialog : public ExportDialog +{ + public: + ExportRegionDialog (PublicEditor & editor, ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track); + + private: + void init_components (); + + ARDOUR::AudioRegion const & region; + ARDOUR::AudioTrack & track; +}; + #endif /* __ardour_export_dialog_h__ */ |