X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_export_audio.cc;h=e40030d671d5a7fe6a0b7b65df792a7dba6b0511;hb=4e411dfd7bab6793426979fe005faf2435c0df0d;hp=851a045f0d376bb68f21079bdb68415ba9b5e40f;hpb=046f8026628a52adeb6983948e39b2665f4c0b49;p=ardour.git diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 851a045f0d..e40030d671 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -19,31 +19,38 @@ /* Note: public Editor methods are documented in public_editor.h */ +#include #include #include #include -#include "export_dialog.h" -#include "editor.h" -#include "public_editor.h" -#include "selection.h" -#include "time_axis_view.h" -#include "audio_time_axis.h" -#include "audio_region_view.h" -#include "midi_region_view.h" +#include + +#include "gtkmm2ext/choice.h" #include "pbd/pthread_utils.h" -#include "ardour/types.h" + #include "ardour/audio_track.h" #include "ardour/audiofilesource.h" -#include "ardour/audio_diskstream.h" -#include "ardour/audioregion.h" #include "ardour/audioplaylist.h" +#include "ardour/audioregion.h" #include "ardour/chan_count.h" +#include "ardour/midi_region.h" +#include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/source_factory.h" -#include "ardour/audiofilesource.h" +#include "ardour/types.h" + +#include "audio_region_view.h" +#include "audio_time_axis.h" +#include "editor.h" +#include "export_dialog.h" +#include "midi_export_dialog.h" +#include "midi_region_view.h" +#include "public_editor.h" +#include "selection.h" +#include "time_axis_view.h" #include "i18n.h" @@ -55,8 +62,16 @@ using namespace Gtk; void Editor::export_audio () { - ExportDialog dialog (*this); - dialog.set_session (session); + ExportDialog dialog (*this, _("Export"), ExportProfileManager::RegularExport); + dialog.set_session (_session); + dialog.run(); +} + +void +Editor::stem_export () +{ + StemExportDialog dialog (*this); + dialog.set_session (_session); dialog.run(); } @@ -64,7 +79,7 @@ void Editor::export_selection () { ExportSelectionDialog dialog (*this); - dialog.set_session (session); + dialog.set_session (_session); dialog.run(); } @@ -83,7 +98,7 @@ Editor::export_range () if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { ExportRangeDialog dialog (*this, l->id().to_s()); - dialog.set_session (session); + dialog.set_session (_session); dialog.run(); } } @@ -96,20 +111,68 @@ Editor::export_region () return; } - try { - boost::shared_ptr r = selection->regions.front()->region(); - AudioRegion & region (dynamic_cast (*r)); - + boost::shared_ptr r = selection->regions.front()->region(); + boost::shared_ptr audio_region = boost::dynamic_pointer_cast(r); + boost::shared_ptr midi_region = boost::dynamic_pointer_cast(r); + + if (audio_region) { + RouteTimeAxisView & rtv (dynamic_cast (selection->regions.front()->get_time_axis_view())); AudioTrack & track (dynamic_cast (*rtv.route())); + + ExportRegionDialog dialog (*this, *(audio_region.get()), track); + dialog.set_session (_session); + dialog.run (); + + } else if (midi_region) { + + MidiExportDialog dialog (*this, midi_region); + dialog.set_session (_session); + int ret = dialog.run (); + switch (ret) { + case Gtk::RESPONSE_ACCEPT: + break; + default: + return; + } - ExportRegionDialog dialog (*this, region, track); - dialog.set_session (session); - dialog.run(); + dialog.hide (); - } catch (std::bad_cast & e) { - error << "Exporting Region failed!" << endmsg; - return; + string path = dialog.get_path (); + + if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { + + MessageDialog checker (_("File Exists!"), + true, + Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_NONE); + + checker.set_title (_("File Exists!")); + + checker.add_button (Stock::CANCEL, RESPONSE_CANCEL); + checker.add_button (_("Overwrite Existing File"), RESPONSE_ACCEPT); + checker.set_default_response (RESPONSE_CANCEL); + + checker.set_wmclass (X_("midi_export_file_exists"), PROGRAM_NAME); + checker.set_position (Gtk::WIN_POS_MOUSE); + + ret = checker.run (); + + switch (ret) { + case Gtk::RESPONSE_ACCEPT: + /* force ::g_unlink because the backend code will + go wrong if it tries to open an existing + file for writing. + */ + ::g_unlink (path.c_str()); + break; + default: + return; + } + + } + + (void) midi_region->clone (path); } } @@ -133,26 +196,27 @@ Editor::write_region_selection (RegionSelection& regions) } void -Editor::bounce_region_selection () +Editor::bounce_region_selection (bool with_processing) { + /* no need to check for bounceable() because this operation never puts + * its results back in the playlist (only in the region list). + */ + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { boost::shared_ptr region ((*i)->region()); RouteTimeAxisView* rtv = dynamic_cast(&(*i)->get_time_axis_view()); - Track* track = dynamic_cast(rtv->route().get()); + boost::shared_ptr track = boost::dynamic_pointer_cast (rtv->route()); InterThreadInfo itt; - itt.done = false; - itt.cancel = false; - itt.progress = 0.0f; + boost::shared_ptr r; - boost::shared_ptr r = track->bounce_range (region->position(), region->position() + region->length(), itt); - cerr << "Result of bounce of " - << region->name() << " len = " << region->length() - << " was " - << r->name() << " len = " << r->length() - << endl; + if (with_processing) { + r = track->bounce_range (region->position(), region->position() + region->length(), itt, track->main_outs(), false); + } else { + r = track->bounce_range (region->position(), region->position() + region->length(), itt, boost::shared_ptr(), false); + } } } @@ -160,17 +224,17 @@ bool Editor::write_region (string path, boost::shared_ptr region) { boost::shared_ptr fs; - const nframes64_t chunk_size = 4096; - nframes64_t to_read; + const framepos_t chunk_size = 4096; + framepos_t to_read; Sample buf[chunk_size]; gain_t gain_buffer[chunk_size]; - nframes64_t pos; + framepos_t pos; char s[PATH_MAX+1]; uint32_t cnt; vector > sources; uint32_t nchans; - const string sound_directory = session->session_directory().sound_path().to_string(); + const string sound_directory = _session->session_directory().sound_path(); nchans = region->n_channels(); @@ -197,7 +261,7 @@ Editor::write_region (string path, boost::shared_ptr region) path = s; - if (::access (path.c_str(), F_OK) != 0) { + if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { break; } } @@ -211,9 +275,9 @@ Editor::write_region (string path, boost::shared_ptr region) try { fs = boost::dynamic_pointer_cast ( - SourceFactory::createWritable (DataType::AUDIO, *session, - path, true, - false, session->frame_rate())); + SourceFactory::createWritable (DataType::AUDIO, *_session, + path, true, + false, _session->frame_rate())); } catch (failed_constructor& err) { @@ -232,7 +296,7 @@ Editor::write_region (string path, boost::shared_ptr region) pos = region->position(); while (to_read) { - nframes64_t this_time; + framepos_t this_time; this_time = min (to_read, chunk_size); @@ -294,9 +358,9 @@ Editor::write_audio_selection (TimeSelection& ts) if (atv->is_audio_track()) { - boost::shared_ptr playlist = boost::dynamic_pointer_cast(atv->get_diskstream()->playlist()); + boost::shared_ptr playlist = boost::dynamic_pointer_cast(atv->track()->playlist()); - if (playlist && write_audio_range (*playlist, atv->get_diskstream()->n_channels(), ts) == 0) { + if (playlist && write_audio_range (*playlist, atv->track()->n_channels(), ts) == 0) { ret = -1; break; } @@ -310,17 +374,17 @@ bool Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list& range) { boost::shared_ptr fs; - const nframes64_t chunk_size = 4096; - nframes64_t nframes; + const framepos_t chunk_size = 4096; + framepos_t nframes; Sample buf[chunk_size]; gain_t gain_buffer[chunk_size]; - nframes64_t pos; + framepos_t pos; char s[PATH_MAX+1]; uint32_t cnt; string path; vector > sources; - const string sound_directory = session->session_directory().sound_path().to_string(); + const string sound_directory = _session->session_directory().sound_path(); uint32_t channels = count.n_audio(); @@ -336,7 +400,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list legalize_for_path(playlist.name()).c_str(), cnt, n); } - if (::access (s, F_OK) != 0) { + if (!Glib::file_test (s, Glib::FILE_TEST_EXISTS)) { break; } } @@ -350,9 +414,9 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list try { fs = boost::dynamic_pointer_cast ( - SourceFactory::createWritable (DataType::AUDIO, *session, - path, true, - false, session->frame_rate())); + SourceFactory::createWritable (DataType::AUDIO, *_session, + path, true, + false, _session->frame_rate())); } catch (failed_constructor& err) { @@ -370,7 +434,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list pos = (*i).start; while (nframes) { - nframes64_t this_time; + framepos_t this_time; this_time = min (nframes, chunk_size); @@ -402,7 +466,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list while (nframes) { - nframes64_t this_time = min (nframes, chunk_size); + framepos_t this_time = min (nframes, chunk_size); memset (buf, 0, sizeof (Sample) * this_time); for (uint32_t n=0; n < channels; ++n) {