summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_export_audio.cc32
-rw-r--r--gtk2_ardour/midi_export_dialog.cc48
-rw-r--r--gtk2_ardour/midi_export_dialog.h41
-rw-r--r--gtk2_ardour/wscript1
4 files changed, 113 insertions, 9 deletions
diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc
index ac0c3f67c4..9521f6a0c6 100644
--- a/gtk2_ardour/editor_export_audio.cc
+++ b/gtk2_ardour/editor_export_audio.cc
@@ -46,6 +46,7 @@
#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"
@@ -110,20 +111,33 @@ Editor::export_region ()
return;
}
- try {
- boost::shared_ptr<Region> r = selection->regions.front()->region();
- AudioRegion & region (dynamic_cast<AudioRegion &> (*r));
-
+ boost::shared_ptr<Region> r = selection->regions.front()->region();
+ boost::shared_ptr<AudioRegion> audio_region = boost::dynamic_pointer_cast<AudioRegion>(r);
+ boost::shared_ptr<MidiRegion> midi_region = boost::dynamic_pointer_cast<MidiRegion>(r);
+
+ if (audio_region) {
+
RouteTimeAxisView & rtv (dynamic_cast<RouteTimeAxisView &> (selection->regions.front()->get_time_axis_view()));
AudioTrack & track (dynamic_cast<AudioTrack &> (*rtv.route()));
+
+ ExportRegionDialog dialog (*this, *(audio_region.get()), track);
+ dialog.set_session (_session);
+ dialog.run ();
+
+ } else if (midi_region) {
- ExportRegionDialog dialog (*this, region, track);
+ MidiExportDialog dialog (*this, midi_region);
dialog.set_session (_session);
- dialog.run();
+ int ret = dialog.run ();
+ switch (ret) {
+ case Gtk::RESPONSE_ACCEPT:
+ break;
+ default:
+ return;
+ }
- } catch (std::bad_cast & e) {
- error << "Exporting Region failed!" << endmsg;
- return;
+ string path = dialog.get_path ();
+ (void) midi_region->clone (path);
}
}
diff --git a/gtk2_ardour/midi_export_dialog.cc b/gtk2_ardour/midi_export_dialog.cc
new file mode 100644
index 0000000000..95bb7b6587
--- /dev/null
+++ b/gtk2_ardour/midi_export_dialog.cc
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2012 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <gtkmm/stock.h>
+
+#include "ardour/midi_region.h"
+
+#include "midi_export_dialog.h"
+
+using namespace ARDOUR;
+
+MidiExportDialog::MidiExportDialog (PublicEditor&, boost::shared_ptr<MidiRegion> region)
+ : ArdourDialog (string_compose (_("Export MIDI: %1"), region->name()))
+ , file_chooser (Gtk::FILE_CHOOSER_ACTION_SAVE)
+{
+ add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
+ add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ get_vbox()->pack_start (file_chooser);
+ file_chooser.set_filename (region->name() + ".mid");
+ file_chooser.show ();
+}
+
+MidiExportDialog::~MidiExportDialog ()
+{
+}
+
+std::string
+MidiExportDialog::get_path () const
+{
+ return file_chooser.get_filename ();
+
+}
diff --git a/gtk2_ardour/midi_export_dialog.h b/gtk2_ardour/midi_export_dialog.h
new file mode 100644
index 0000000000..86b2328415
--- /dev/null
+++ b/gtk2_ardour/midi_export_dialog.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2012 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __gtk2_ardour_midi_export_dialog_h__
+#define __gtk2_ardour_midi_export_dialog_h__
+
+#include <boost/shared_ptr.hpp>
+
+#include <gtkmm/filechooser.h>
+
+#include "ardour_dialog.h"
+#include "public_editor.h"
+
+class MidiExportDialog : public ArdourDialog {
+ public:
+ MidiExportDialog (PublicEditor& editor, boost::shared_ptr<ARDOUR::MidiRegion>);
+ ~MidiExportDialog ();
+
+ std::string get_path() const;
+
+ private:
+ Gtk::FileChooserWidget file_chooser;
+};
+
+#endif /* __gtk2_ardour_midi_export_dialog_h__ */
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index e1fccbd328..b9fca6cc0a 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -137,6 +137,7 @@ gtk2_ardour_sources = [
'midi_channel_dialog.cc',
'midi_channel_selector.cc',
'midi_cut_buffer.cc',
+ 'midi_export_dialog.cc',
'midi_list_editor.cc',
'midi_port_dialog.cc',
'midi_region_view.cc',