Add instrument selector to import dialog.
Idea here is for importing large multi-track MIDI files to be immediately listenable upon play without tediously adding a ton of instrument plugins manually.
This commit is contained in:
parent
10ad55fcf5
commit
1de39b8971
@ -402,8 +402,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
|
||||
int get_regionview_count_from_region_list (boost::shared_ptr<ARDOUR::Region>);
|
||||
|
||||
void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t&);
|
||||
void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, framepos_t&);
|
||||
void do_import (std::vector<std::string> paths,
|
||||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
ARDOUR::SrcQuality quality,
|
||||
framepos_t& pos,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
void do_embed (std::vector<std::string> paths,
|
||||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
framepos_t& pos,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison);
|
||||
|
||||
@ -1290,19 +1300,47 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
bool idle_drop_paths (std::vector<std::string> paths, framepos_t frame, double ypos, bool copy);
|
||||
void drop_paths_part_two (const std::vector<std::string>& paths, framepos_t frame, double ypos, bool copy);
|
||||
|
||||
int import_sndfiles (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,
|
||||
ARDOUR::SrcQuality, framepos_t& pos,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
|
||||
int embed_sndfiles (std::vector<std::string> paths, bool multiple_files, bool& check_sample_rate,
|
||||
Editing::ImportDisposition disposition, Editing::ImportMode mode,
|
||||
framepos_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
|
||||
int import_sndfiles (std::vector<std::string> paths,
|
||||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
ARDOUR::SrcQuality quality,
|
||||
framepos_t& pos,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
bool replace,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
int add_sources (std::vector<std::string> paths, ARDOUR::SourceList& sources, framepos_t& pos,
|
||||
Editing::ImportDisposition, Editing::ImportMode,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
|
||||
int embed_sndfiles (std::vector<std::string> paths,
|
||||
bool multiple_files,
|
||||
bool& check_sample_rate,
|
||||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
framepos_t& pos,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t, framepos_t& pos, Editing::ImportMode mode,
|
||||
boost::shared_ptr<ARDOUR::Track>& existing_track, const std::string& new_track_name);
|
||||
int add_sources (std::vector<std::string> paths,
|
||||
ARDOUR::SourceList& sources,
|
||||
framepos_t& pos,
|
||||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
bool add_channel_suffix,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region,
|
||||
uint32_t in_chans,
|
||||
uint32_t out_chans,
|
||||
framepos_t& pos,
|
||||
Editing::ImportMode mode,
|
||||
boost::shared_ptr<ARDOUR::Track>& existing_track,
|
||||
const std::string& new_track_name,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument);
|
||||
|
||||
boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
|
||||
boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
|
||||
|
@ -263,7 +263,12 @@ Editor::get_nth_selected_midi_track (int nth) const
|
||||
}
|
||||
|
||||
void
|
||||
Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMode mode, SrcQuality quality, framepos_t& pos)
|
||||
Editor::do_import (vector<string> paths,
|
||||
ImportDisposition disposition,
|
||||
ImportMode mode,
|
||||
SrcQuality quality,
|
||||
framepos_t& pos,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<Track> track;
|
||||
vector<string> to_import;
|
||||
@ -298,7 +303,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
|
||||
ok = false;
|
||||
} else {
|
||||
ipw.show ();
|
||||
ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false) == 0);
|
||||
ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false, instrument) == 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -343,7 +348,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
|
||||
track = get_nth_selected_audio_track (nth++);
|
||||
}
|
||||
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace) == 0);
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace, instrument) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportDistinctChannels:
|
||||
@ -351,7 +356,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
|
||||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace) == 0);
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace, instrument) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportSerializeFiles:
|
||||
@ -359,7 +364,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
|
||||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace) == 0);
|
||||
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace, instrument) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportMergeFiles:
|
||||
@ -377,7 +382,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
|
||||
}
|
||||
|
||||
void
|
||||
Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, framepos_t& pos)
|
||||
Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, framepos_t& pos, ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<Track> track;
|
||||
bool check_sample_rate = true;
|
||||
@ -403,7 +408,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
||||
track = get_nth_selected_audio_track (nth++);
|
||||
}
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track, instrument) < -1) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -420,14 +425,14 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
||||
to_embed.clear ();
|
||||
to_embed.push_back (*a);
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track, instrument) < -1) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Editing::ImportMergeFiles:
|
||||
if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track) < -1) {
|
||||
if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
@ -443,7 +448,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
||||
to_embed.clear ();
|
||||
to_embed.push_back (*a);
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -459,8 +464,16 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
||||
}
|
||||
|
||||
int
|
||||
Editor::import_sndfiles (vector<string> paths, ImportDisposition disposition, ImportMode mode, SrcQuality quality, framepos_t& pos,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
|
||||
Editor::import_sndfiles (vector<string> paths,
|
||||
ImportDisposition disposition,
|
||||
ImportMode mode,
|
||||
SrcQuality quality,
|
||||
framepos_t& pos,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
bool replace,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
import_status.paths = paths;
|
||||
import_status.done = false;
|
||||
@ -504,7 +517,7 @@ Editor::import_sndfiles (vector<string> paths, ImportDisposition disposition, Im
|
||||
import_status.mode,
|
||||
import_status.target_regions,
|
||||
import_status.target_tracks,
|
||||
track, false
|
||||
track, false, instrument
|
||||
);
|
||||
|
||||
/* update position from results */
|
||||
@ -517,10 +530,16 @@ Editor::import_sndfiles (vector<string> paths, ImportDisposition disposition, Im
|
||||
}
|
||||
|
||||
int
|
||||
Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||
bool& check_sample_rate, ImportDisposition disposition, ImportMode mode,
|
||||
framepos_t& pos, int target_regions, int target_tracks,
|
||||
boost::shared_ptr<Track>& track)
|
||||
Editor::embed_sndfiles (vector<string> paths,
|
||||
bool multifile,
|
||||
bool& check_sample_rate,
|
||||
ImportDisposition disposition,
|
||||
ImportMode mode,
|
||||
framepos_t& pos,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<AudioFileSource> source;
|
||||
SourceList sources;
|
||||
@ -629,15 +648,23 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||
}
|
||||
|
||||
if (!sources.empty()) {
|
||||
return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true);
|
||||
return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true, instrument);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos, ImportDisposition disposition, ImportMode mode,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool /*add_channel_suffix*/)
|
||||
Editor::add_sources (vector<string> paths,
|
||||
SourceList& sources,
|
||||
framepos_t& pos,
|
||||
ImportDisposition disposition,
|
||||
ImportMode mode,
|
||||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
bool /*add_channel_suffix*/,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
vector<boost::shared_ptr<Region> > regions;
|
||||
string region_name;
|
||||
@ -832,7 +859,7 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
|
||||
}
|
||||
}
|
||||
|
||||
finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n]);
|
||||
finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], instrument);
|
||||
|
||||
rlen = (*r)->length();
|
||||
|
||||
@ -858,8 +885,14 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
|
||||
}
|
||||
|
||||
int
|
||||
Editor::finish_bringing_in_material (boost::shared_ptr<Region> region, uint32_t in_chans, uint32_t out_chans, framepos_t& pos,
|
||||
ImportMode mode, boost::shared_ptr<Track>& existing_track, const string& new_track_name)
|
||||
Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
|
||||
uint32_t in_chans,
|
||||
uint32_t out_chans,
|
||||
framepos_t& pos,
|
||||
ImportMode mode,
|
||||
boost::shared_ptr<Track>& existing_track,
|
||||
const string& new_track_name,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
|
||||
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
|
||||
@ -907,10 +940,11 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region, uint32_t
|
||||
|
||||
existing_track = at.front();
|
||||
} else if (mr) {
|
||||
list<boost::shared_ptr<MidiTrack> > mt (_session->new_midi_track (ChanCount (DataType::MIDI, 1),
|
||||
ChanCount (DataType::MIDI, 1),
|
||||
boost::shared_ptr<PluginInfo>(),
|
||||
Normal, 0, 1));
|
||||
list<boost::shared_ptr<MidiTrack> > mt (
|
||||
_session->new_midi_track (ChanCount (DataType::MIDI, 1),
|
||||
ChanCount (DataType::MIDI, 1),
|
||||
instrument,
|
||||
Normal, 0, 1));
|
||||
|
||||
if (mt.empty()) {
|
||||
return -1;
|
||||
|
@ -206,9 +206,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
|
||||
|
||||
virtual Editing::MouseMode effective_mouse_mode () const = 0;
|
||||
|
||||
/** Import existing media */
|
||||
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t&) = 0;
|
||||
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, framepos_t&) = 0;
|
||||
/** Import existing media */
|
||||
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t&, boost::shared_ptr<ARDOUR::PluginInfo> instrument=boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
||||
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, framepos_t&, boost::shared_ptr<ARDOUR::PluginInfo> instrument=boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
||||
|
||||
/** Open main export dialog */
|
||||
virtual void export_audio () = 0;
|
||||
|
@ -1746,6 +1746,18 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s,
|
||||
hbox->pack_start (*vbox, false, false);
|
||||
options.pack_start (*hbox, false, false);
|
||||
|
||||
l = manage (new Label);
|
||||
l->set_markup (_("<b>Instrument</b>"));
|
||||
|
||||
vbox = manage (new VBox);
|
||||
vbox->set_border_width (12);
|
||||
vbox->set_spacing (6);
|
||||
vbox->pack_start (*l, false, false);
|
||||
vbox->pack_start (instrument_combo, false, false);
|
||||
hbox = manage (new HBox);
|
||||
hbox->pack_start (*vbox, false, false);
|
||||
options.pack_start (*hbox, false, false);
|
||||
|
||||
str.clear ();
|
||||
str.push_back (_("Best"));
|
||||
str.push_back (_("Good"));
|
||||
@ -1949,6 +1961,7 @@ SoundFileOmega::do_something (int action)
|
||||
ImportPosition pos = get_position ();
|
||||
ImportMode mode = get_mode ();
|
||||
ImportDisposition chns = get_channel_disposition ();
|
||||
PluginInfoPtr instrument = instrument_combo.selected_instrument();
|
||||
framepos_t where;
|
||||
|
||||
switch (pos) {
|
||||
@ -1969,9 +1982,9 @@ SoundFileOmega::do_something (int action)
|
||||
SrcQuality quality = get_src_quality();
|
||||
|
||||
if (copy_files_btn.get_active()) {
|
||||
PublicEditor::instance().do_import (paths, chns, mode, quality, where);
|
||||
PublicEditor::instance().do_import (paths, chns, mode, quality, where, instrument);
|
||||
} else {
|
||||
PublicEditor::instance().do_embed (paths, chns, mode, where);
|
||||
PublicEditor::instance().do_embed (paths, chns, mode, where, instrument);
|
||||
}
|
||||
|
||||
if (action == RESPONSE_OK) {
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "ardour_window.h"
|
||||
#include "editing.h"
|
||||
#include "audio_clock.h"
|
||||
#include "instrument_selector.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
class Session;
|
||||
@ -284,6 +285,7 @@ class SoundFileOmega : public SoundFileBrowser
|
||||
Gtk::ComboBoxText where_combo;
|
||||
Gtk::ComboBoxText channel_combo;
|
||||
Gtk::ComboBoxText src_combo;
|
||||
InstrumentSelector instrument_combo;
|
||||
|
||||
Gtk::CheckButton copy_files_btn;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user