add basic, not terribly glossy MIDI region export
git-svn-id: svn://localhost/ardour2/branches/3.0@12402 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
7873fdb55c
commit
e0d0735fa2
@ -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, region, track);
|
||||
|
||||
ExportRegionDialog dialog (*this, *(audio_region.get()), track);
|
||||
dialog.set_session (_session);
|
||||
dialog.run();
|
||||
dialog.run ();
|
||||
|
||||
} else if (midi_region) {
|
||||
|
||||
} catch (std::bad_cast & e) {
|
||||
error << "Exporting Region failed!" << endmsg;
|
||||
return;
|
||||
MidiExportDialog dialog (*this, midi_region);
|
||||
dialog.set_session (_session);
|
||||
int ret = dialog.run ();
|
||||
switch (ret) {
|
||||
case Gtk::RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
string path = dialog.get_path ();
|
||||
(void) midi_region->clone (path);
|
||||
}
|
||||
}
|
||||
|
||||
|
48
gtk2_ardour/midi_export_dialog.cc
Normal file
48
gtk2_ardour/midi_export_dialog.cc
Normal file
@ -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 ();
|
||||
|
||||
}
|
41
gtk2_ardour/midi_export_dialog.h
Normal file
41
gtk2_ardour/midi_export_dialog.h
Normal file
@ -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__ */
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user