X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fsfdb_ui.cc;h=fcd8510d925d3cf04174183c5c8758dc8b220549;hb=63a4cc9cf6e02153a6c647867abfec6b013e0708;hp=ed1cfd44ca6c68daa67589d49bccb0219ed61291;hpb=53cdc8046f0f92eb400ce99bc4e461bae2117976;p=ardour.git diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index ed1cfd44ca..fcd8510d92 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -21,8 +21,6 @@ #include "gtk2ardour-config.h" #endif -#include "i18n.h" - #include #include #include @@ -31,15 +29,16 @@ #include #include +#include #include -#include +#include "pbd/gstdio_compat.h" #include -#include "pbd/convert.h" #include "pbd/tokenizer.h" #include "pbd/enumwriter.h" #include "pbd/pthread_utils.h" +#include "pbd/string_convert.h" #include "pbd/xml++.h" #include @@ -57,20 +56,23 @@ #include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/srcfilesource.h" +#include "ardour/profile.h" #include "ardour_ui.h" #include "editing.h" #include "gui_thread.h" -#include "prompter.h" #include "sfdb_ui.h" #include "editing.h" #include "gain_meter.h" #include "main_clock.h" #include "public_editor.h" #include "timers.h" +#include "ui_config.h" #include "sfdb_freesound_mootcher.h" +#include "pbd/i18n.h" + using namespace ARDOUR; using namespace PBD; using namespace std; @@ -83,8 +85,24 @@ using std::string; string SoundFileBrowser::persistent_folder; typedef TreeView::Selection::ListHandle_Path ListPath; +static MidiTrackNameSource +string2miditracknamesource (string const & str) +{ + if (str == _("by track number")) { + return SMFTrackNumber; + } else if (str == _("by track name")) { + return SMFTrackName; + } else if (str == _("by instrument name")) { + return SMFInstrumentName; + } + + warning << string_compose (_("programming error: unknown midi track name source string %1"), str) << endmsg; + + return SMFTrackNumber; +} + static ImportMode -string2importmode (string str) +string2importmode (string const & str) { if (str == _("as new tracks")) { return ImportAsTrack; @@ -119,13 +137,15 @@ importmode2string (ImportMode mode) } SoundFileBox::SoundFileBox (bool /*persistent*/) - : table (6, 2), + : table (7, 2), length_clock ("sfboxLengthClock", true, "", false, false, true, false), timecode_clock ("sfboxTimecodeClock", true, "", false, false, false, false), main_box (false, 6), autoplay_btn (_("Auto-play")), seek_slider(0,1000,1), - _seeking(false) + _seeking(false), + _src_quality (SrcBest), + _import_position (ImportAtTimestamp) { set_name (X_("SoundFileBox")); @@ -151,6 +171,8 @@ SoundFileBox::SoundFileBox (bool /*persistent*/) channels.set_alignment (1, 0.5); samplerate.set_text (_("Sample rate:")); samplerate.set_alignment (1, 0.5); + tempomap.set_text (_("Tempo Map:")); + tempomap.set_alignment (1, 0.5); preview_label.set_max_width_chars (50); preview_label.set_ellipsize (Pango::ELLIPSIZE_END); @@ -168,14 +190,16 @@ SoundFileBox::SoundFileBox (bool /*persistent*/) table.attach (format, 0, 1, 2, 4, FILL, FILL); table.attach (length, 0, 1, 4, 5, FILL, FILL); table.attach (timecode, 0, 1, 5, 6, FILL, FILL); + table.attach (tempomap, 0, 1, 6, 7, FILL, FILL); table.attach (channels_value, 1, 2, 0, 1, FILL, FILL); table.attach (samplerate_value, 1, 2, 1, 2, FILL, FILL); table.attach (format_text, 1, 2, 2, 4, FILL, FILL); table.attach (length_clock, 1, 2, 4, 5, FILL, FILL); table.attach (timecode_clock, 1, 2, 5, 6, FILL, FILL); + table.attach (tempomap_value, 1, 2, 6, 7, FILL, FILL); - length_clock.set_mode (ARDOUR_UI::instance()->secondary_clock->mode()); + length_clock.set_mode (ARDOUR_UI::instance()->primary_clock->mode()); timecode_clock.set_mode (AudioClock::Timecode); main_box.pack_start (table, false, false); @@ -213,6 +237,9 @@ SoundFileBox::SoundFileBox (bool /*persistent*/) play_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::audition)); stop_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::stop_audition)); + update_autoplay (); + autoplay_btn.signal_toggled().connect(sigc::mem_fun (*this, &SoundFileBox::autoplay_toggled)); + stop_btn.set_sensitive (false); channels_value.set_alignment (0.0f, 0.5f); @@ -248,7 +275,7 @@ SoundFileBox::audition_active(bool active) { } void -SoundFileBox::audition_progress(ARDOUR::framecnt_t pos, ARDOUR::framecnt_t len) { +SoundFileBox::audition_progress(ARDOUR::samplecnt_t pos, ARDOUR::samplecnt_t len) { if (!_seeking) { seek_slider.set_value( 1000.0 * pos / len); seek_slider.set_sensitive (true); @@ -302,11 +329,38 @@ SoundFileBox::setup_labels (const string& filename) tags_entry.set_sensitive (false); if (ms) { - channels_value.set_text (to_string(ms->num_tracks(), std::dec)); + if (ms->is_type0()) { + channels_value.set_text (to_string(ms->channels().size())); + } else { + if (ms->num_tracks() > 1) { + channels_value.set_text (to_string(ms->num_tracks()) + _("(Tracks)")); + } else { + channels_value.set_text (to_string(ms->num_tracks())); + } + } length_clock.set (ms->length(ms->timeline_position())); + switch (ms->num_tempos()) { + case 0: + tempomap_value.set_text (_("No tempo data")); + break; + case 1: { + Evoral::SMF::Tempo* t = ms->nth_tempo (0); + assert (t); + tempomap_value.set_text (string_compose (_("%1/%2 \u2669 = %3"), + t->numerator, + t->denominator, + t->tempo ())); + break; + } + default: + tempomap_value.set_text (string_compose (_("map with %1 sections"), + ms->num_tempos())); + break; + } } else { channels_value.set_text (""); length_clock.set (0); + tempomap_value.set_text (_("No tempo data")); } if (_session && ms) { @@ -341,9 +395,9 @@ SoundFileBox::setup_labels (const string& filename) n = n.substr (8); } format_text.set_text (n); - channels_value.set_text (to_string (sf_info.channels, std::dec)); + channels_value.set_text (to_string (sf_info.channels)); - if (_session && sf_info.samplerate != _session->frame_rate()) { + if (_session && sf_info.samplerate != _session->sample_rate()) { samplerate.set_markup (string_compose ("%1", _("Sample rate:"))); samplerate_value.set_markup (string_compose (X_("%1 Hz"), sf_info.samplerate)); samplerate_value.set_name ("NewSessionSR1Label"); @@ -355,7 +409,7 @@ SoundFileBox::setup_labels (const string& filename) samplerate.set_name ("NewSessionSR2Label"); } - framecnt_t const nfr = _session ? _session->nominal_frame_rate() : 25; + samplecnt_t const nfr = _session ? _session->nominal_sample_rate() : 25; double src_coef = (double) nfr / sf_info.samplerate; length_clock.set (sf_info.length * src_coef + 0.5, true); @@ -382,6 +436,22 @@ SoundFileBox::setup_labels (const string& filename) return true; } +void +SoundFileBox::update_autoplay () +{ + const bool config_autoplay = UIConfiguration::instance().get_autoplay_files(); + + if (autoplay_btn.get_active() != config_autoplay) { + autoplay_btn.set_active (config_autoplay); + } +} + +void +SoundFileBox::autoplay_toggled() +{ + UIConfiguration::instance().set_autoplay_files(autoplay_btn.get_active()); +} + bool SoundFileBox::autoplay() const { @@ -446,7 +516,7 @@ SoundFileBox::audition () SourceFactory::createExternal (DataType::AUDIO, *_session, path, n, Source::Flag (ARDOUR::AudioFileSource::NoPeakFile), false)); - if (afs->sample_rate() != _session->nominal_frame_rate()) { + if (afs->sample_rate() != _session->nominal_sample_rate()) { boost::shared_ptr sfs (new SrcFileSource(*_session, afs, _src_quality)); srclist.push_back(sfs); } else { @@ -479,16 +549,16 @@ SoundFileBox::audition () r = boost::dynamic_pointer_cast (RegionFactory::create (srclist, plist, false)); } - frameoffset_t audition_position = 0; + sampleoffset_t audition_position = 0; switch(_import_position) { case ImportAtTimestamp: audition_position = 0; break; case ImportAtPlayhead: - audition_position = _session->transport_frame(); + audition_position = _session->transport_sample(); break; case ImportAtStart: - audition_position = _session->current_start_frame(); + audition_position = _session->current_start_sample(); break; case ImportAtEditPoint: audition_position = PublicEditor::instance().get_preferred_edit_position (); @@ -555,39 +625,38 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi , _status (0) , _done (false) , import_button (_("Import")) - , close_button (Stock::CLOSE) , gm (0) { -#ifdef GTKOSX +#ifdef __APPLE__ try { /* add_shortcut_folder throws an exception if the folder being added already has a shortcut */ chooser.add_shortcut_folder_uri("file:///Library/GarageBand/Apple Loops"); chooser.add_shortcut_folder_uri("file:///Library/Audio/Apple Loops"); chooser.add_shortcut_folder_uri("file:///Library/Application Support/GarageBand/Instrument Library/Sampler/Sampler Files"); - chooser.add_shortcut_folder_uri("file:///Volumes"); } catch (Glib::Error & e) { std::cerr << "sfdb.add_shortcut_folder() threw Glib::Error " << e.what() << std::endl; } #endif + Gtkmm2ext::add_volume_shortcuts (chooser); //add the file chooser chooser.set_border_width (12); - + audio_and_midi_filter.add_custom (FILE_FILTER_FILENAME, sigc::mem_fun (*this, &SoundFileBrowser::on_audio_and_midi_filter)); audio_and_midi_filter.set_name (_("Audio and MIDI files")); - + audio_filter.add_custom (FILE_FILTER_FILENAME, sigc::mem_fun(*this, &SoundFileBrowser::on_audio_filter)); audio_filter.set_name (_("Audio files")); - + midi_filter.add_custom (FILE_FILTER_FILENAME, sigc::mem_fun(*this, &SoundFileBrowser::on_midi_filter)); midi_filter.set_name (_("MIDI files")); - + matchall_filter.add_pattern ("*.*"); matchall_filter.set_name (_("All files")); - + chooser.add_filter (audio_and_midi_filter); chooser.add_filter (audio_filter); chooser.add_filter (midi_filter); @@ -596,17 +665,17 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi chooser.signal_update_preview().connect(sigc::mem_fun(*this, &SoundFileBrowser::update_preview)); chooser.signal_file_activated().connect (sigc::mem_fun (*this, &SoundFileBrowser::chooser_file_activated)); -#ifdef GTKOSX +#ifdef __APPLE__ /* some broken redraw behaviour - this is a bandaid */ chooser.signal_selection_changed().connect (mem_fun (chooser, &Widget::queue_draw)); #endif - + if (!persistent_folder.empty()) { chooser.set_current_folder (persistent_folder); } notebook.append_page (chooser, _("Browse Files")); - + hpacker.set_spacing (6); hpacker.pack_start (notebook, true, true); hpacker.pack_start (preview, false, false); @@ -620,52 +689,53 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi VBox* vbox; HBox* hbox; - - + + hbox = manage(new HBox); hbox->pack_start (found_entry); hbox->pack_start (found_search_btn); - + Gtk::ScrolledWindow *scroll = manage(new ScrolledWindow); scroll->add(found_list_view); scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - + vbox = manage(new VBox); vbox->pack_start (*hbox, PACK_SHRINK); vbox->pack_start (*scroll); - + found_list_view.append_column(_("Paths"), found_list_columns.pathname); - + found_list_view.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SoundFileBrowser::found_list_view_selected)); - + found_list_view.signal_row_activated().connect (sigc::mem_fun (*this, &SoundFileBrowser::found_list_view_activated)); - + found_search_btn.signal_clicked().connect(sigc::mem_fun(*this, &SoundFileBrowser::found_search_clicked)); found_entry.signal_activate().connect(sigc::mem_fun(*this, &SoundFileBrowser::found_search_clicked)); - + notebook.append_page (*vbox, _("Search Tags")); //add freesound search +#ifdef FREESOUND_GOT_FIXED HBox* passbox; Label* label; - + passbox = manage(new HBox); passbox->set_spacing (6); - + label = manage (new Label); label->set_text (_("Tags:")); passbox->pack_start (*label, false, false); passbox->pack_start (freesound_entry, true, true); - + label = manage (new Label); label->set_text (_("Sort:")); passbox->pack_start (*label, false, false); passbox->pack_start (freesound_sort, false, false); freesound_sort.clear_items(); - + // Order of the following must correspond with enum sortMethod - // in sfdb_freesound_mootcher.h + // in sfdb_freesound_mootcher.h freesound_sort.append_text(_("None")); freesound_sort.append_text(_("Longest")); freesound_sort.append_text(_("Shortest")); @@ -676,7 +746,7 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi freesound_sort.append_text(_("Highest rated")); freesound_sort.append_text(_("Lowest rated")); freesound_sort.set_active(0); - + passbox->pack_start (freesound_search_btn, false, false); passbox->pack_start (freesound_more_btn, false, false); freesound_more_btn.set_label(_("More")); @@ -685,11 +755,11 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi passbox->pack_start (freesound_similar_btn, false, false); freesound_similar_btn.set_label(_("Similar")); freesound_similar_btn.set_sensitive(false); - + scroll = manage(new ScrolledWindow); scroll->add(freesound_list_view); scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - + vbox = manage(new VBox); vbox->set_spacing (3); vbox->pack_start (*passbox, PACK_SHRINK); @@ -709,7 +779,7 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi freesound_list_view.get_column(3)->set_alignment(0.5); freesound_list_view.get_column(4)->set_alignment(0.5); freesound_list_view.get_column(5)->set_alignment(0.5); - + freesound_list_view.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SoundFileBrowser::freesound_list_view_selected)); freesound_list_view.set_tooltip_column(1); @@ -720,6 +790,7 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi freesound_more_btn.signal_clicked().connect(sigc::mem_fun(*this, &SoundFileBrowser::freesound_more_clicked)); freesound_similar_btn.signal_clicked().connect(sigc::mem_fun(*this, &SoundFileBrowser::freesound_similar_clicked)); notebook.append_page (*vbox, _("Search Freesound")); +#endif notebook.set_size_request (500, -1); notebook.signal_switch_page().connect (sigc::hide_return (sigc::hide (sigc::hide (sigc::mem_fun (*this, &SoundFileBrowser::reset_options))))); @@ -729,14 +800,11 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi Gtk::HButtonBox* button_box = manage (new HButtonBox); button_box->set_layout (BUTTONBOX_END); - button_box->pack_start (close_button, false, false); - close_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &SoundFileBrowser::do_something), RESPONSE_CLOSE)); button_box->pack_start (import_button, false, false); import_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &SoundFileBrowser::do_something), RESPONSE_OK)); Gtkmm2ext::UI::instance()->set_tip (import_button, _("Press to import selected files")); - Gtkmm2ext::UI::instance()->set_tip (close_button, _("Press to close this window without importing any files")); vpacker.pack_end (*button_box, false, false); @@ -770,6 +838,12 @@ SoundFileBrowser::set_action_sensitive (bool yn) import_button.set_sensitive (yn); } +bool +SoundFileBrowser::get_action_sensitive () const +{ + return import_button.get_sensitive (); +} + void SoundFileBrowser::do_something (int action) { @@ -784,6 +858,22 @@ SoundFileBrowser::on_show () start_metering (); } +bool +SoundFileBrowser::on_key_press_event (GdkEventKey* ev) +{ + if (ev->keyval == GDK_Escape) { + do_something (RESPONSE_CLOSE); + return true; + } + if (ev->keyval == GDK_space && ev->type == GDK_KEY_PRESS) { + if (get_action_sensitive()) { + preview.audition(); + return true; + } + } + return ArdourWindow::on_key_press_event (ev); +} + void SoundFileBrowser::clear_selection () { @@ -794,7 +884,7 @@ SoundFileBrowser::clear_selection () void SoundFileBrowser::chooser_file_activated () { - preview.audition (); + do_something (RESPONSE_OK); } void @@ -831,7 +921,7 @@ SoundFileBrowser::add_gain_meter () boost::shared_ptr r = _session->the_auditioner (); - gm->set_controls (r, r->shared_peak_meter(), r->amp()); + gm->set_controls (r, r->shared_peak_meter(), r->amp(), r->gain_control()); gm->set_fader_name (X_("GainFader")); meter_packer.set_border_width (12); @@ -1022,7 +1112,7 @@ SoundFileBrowser::refresh_display(std::string ID, std::string file) // there's a single item selected in the freesound list //XXX make a function to be used to construct the actual file name both here and in the mootcher Gtk::TreeIter row = freesound_list->get_iter(*rows.begin()); - std::string selected_ID = (*row)[freesound_list_columns.id]; + std::string selected_ID = (*row)[freesound_list_columns.id]; if (ID == selected_ID) { // the selected item in the freesound list is the item that has just finished downloading chooser.set_filename(file); @@ -1066,9 +1156,9 @@ SoundFileBrowser::freesound_similar_clicked () prev_cursor = gdk_window_get_cursor (get_window()->gobj()); gdk_window_set_cursor (get_window()->gobj(), gdk_cursor_new(GDK_WATCH)); gdk_flush(); - + std::string theString = mootcher.searchSimilar(id); - + gdk_window_set_cursor (get_window()->gobj(), prev_cursor); handle_freesound_results(theString); } @@ -1088,9 +1178,9 @@ SoundFileBrowser::freesound_search() gdk_flush(); std::string theString = mootcher.searchText( - search_string, + search_string, freesound_page, -#ifdef GTKOSX +#ifdef __APPLE__ "", // OSX eats anything incl mp3 #else "type:wav OR type:aiff OR type:flac OR type:aif OR type:ogg OR type:oga", @@ -1292,6 +1382,11 @@ SoundFileOmega::reset_options_noret () bool SoundFileOmega::reset_options () { + if (_import_active) { + _reset_post_import = true; + return true; + } + vector paths = get_paths (); if (paths.empty()) { @@ -1315,7 +1410,7 @@ SoundFileOmega::reset_options () to do embedding (or if we are importing a MIDI file). */ - if (ARDOUR_UI::config()->get_only_copy_imported_files()) { + if (UIConfiguration::instance().get_only_copy_imported_files()) { copy_files_btn.set_sensitive (false); } else { copy_files_btn.set_sensitive (false); @@ -1340,6 +1435,12 @@ SoundFileOmega::reset_options () return false; } + if (have_a_midi_file) { + smf_tempo_btn.show (); + } else { + smf_tempo_btn.hide (); + } + string existing_choice; vector action_strings; @@ -1352,28 +1453,28 @@ SoundFileOmega::reset_options () if (selected_audio_track_cnt > 0) { if (channel_combo.get_active_text().length()) { ImportDisposition id = get_channel_disposition(); - + switch (id) { case Editing::ImportDistinctFiles: if (selected_audio_track_cnt == paths.size()) { action_strings.push_back (importmode2string (ImportToTrack)); } break; - + case Editing::ImportDistinctChannels: /* XXX it would be nice to allow channel-per-selected track but its too hard we don't want to deal with all the different per-file + per-track channel configurations. */ break; - + default: action_strings.push_back (importmode2string (ImportToTrack)); break; } } } - + } else { /* MIDI ONLY */ @@ -1385,7 +1486,9 @@ SoundFileOmega::reset_options () action_strings.push_back (importmode2string (ImportAsTrack)); action_strings.push_back (importmode2string (ImportAsRegion)); - action_strings.push_back (importmode2string (ImportAsTapeTrack)); + if (!Profile->get_mixbus()) { + action_strings.push_back (importmode2string (ImportAsTapeTrack)); + } existing_choice = action_combo.get_active_text(); @@ -1420,12 +1523,13 @@ SoundFileOmega::reset_options () vector channel_strings; if (mode == ImportAsTrack || mode == ImportAsTapeTrack || mode == ImportToTrack) { - channel_strings.push_back (_("one track per file")); if (selection_includes_multichannel) { channel_strings.push_back (_("one track per channel")); } + channel_strings.push_back (_("one track per file")); + if (paths.size() > 1) { /* tape tracks are a single region per track, so we cannot sequence multiple files. @@ -1488,8 +1592,8 @@ SoundFileOmega::reset_options () /* We must copy MIDI files or those from Freesound * or any file if we are under nsm control */ bool const must_copy = _session->get_nsm_state() || have_a_midi_file || notebook.get_current_page() == 2; - - if (ARDOUR_UI::config()->get_only_copy_imported_files()) { + + if (UIConfiguration::instance().get_only_copy_imported_files()) { if (selection_can_be_embedded_with_links && !must_copy) { copy_files_btn.set_sensitive (true); @@ -1504,7 +1608,7 @@ SoundFileOmega::reset_options () if (must_copy) { copy_files_btn.set_active (true); - } + } copy_files_btn.set_sensitive (!must_copy); } @@ -1532,7 +1636,7 @@ bool SoundFileOmega::check_info (const vector& paths, bool& same_size, bool& src_needed, bool& multichannel) { SoundFileInfo info; - framepos_t sz = 0; + samplepos_t sz = 0; bool err = false; string errmsg; @@ -1554,21 +1658,30 @@ SoundFileOmega::check_info (const vector& paths, bool& same_size, bool& } } - if (info.samplerate != _session->frame_rate()) { + if (info.samplerate != _session->sample_rate()) { src_needed = true; } } else if (SMFSource::valid_midi_file (*i)) { Evoral::SMF reader; - reader.open(*i); - if (reader.num_tracks() > 1) { - multichannel = true; // "channel" == track here... - } - /* XXX we need err = true handling here in case - we can't check the file - */ + if (reader.open (*i)) { + err = true; + } else { + if (reader.is_type0 ()) { + if (reader.channels().size() > 1) { + /* for type-0 files, we can split + * "one track per channel" + */ + multichannel = true; + } + } else { + if (reader.num_tracks() > 1) { + multichannel = true; + } + } + } } else { err = true; @@ -1654,113 +1767,88 @@ SoundFileChooser::get_filename () return paths.front(); } -SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, - uint32_t selected_audio_tracks, - uint32_t selected_midi_tracks, +SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, + uint32_t selected_audio_tracks, + uint32_t selected_midi_tracks, bool persistent, Editing::ImportMode mode_hint) : SoundFileBrowser (title, s, persistent) , copy_files_btn ( _("Copy files to session")) + , smf_tempo_btn (_("Use MIDI Tempo Map (if defined)")) , selected_audio_track_cnt (selected_audio_tracks) , selected_midi_track_cnt (selected_midi_tracks) + , _import_active (false) + , _reset_post_import (false) { - VBox* vbox; - HBox* hbox; vector str; - set_size_request (-1, 450); + set_size_request (-1, 550); block_two.set_border_width (12); block_three.set_border_width (12); block_four.set_border_width (12); - options.set_spacing (12); - str.clear (); str.push_back (_("file timestamp")); str.push_back (_("edit point")); str.push_back (_("playhead")); str.push_back (_("session start")); set_popdown_strings (where_combo, str); - where_combo.set_active_text (str.front()); + where_combo.set_active_text (str.back()); where_combo.signal_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::where_combo_changed)); Label* l = manage (new Label); - l->set_markup (_("Add files as ...")); - - vbox = manage (new VBox); - vbox->set_border_width (12); - vbox->set_spacing (6); - vbox->pack_start (*l, false, false); - vbox->pack_start (action_combo, false, false); - hbox = manage (new HBox); - hbox->pack_start (*vbox, false, false); - options.pack_start (*hbox, false, false); - - /* dummy entry for action combo so that it doesn't look odd if we - come up with no tracks selected. - */ - - str.clear (); - str.push_back (importmode2string (mode_hint)); - set_popdown_strings (action_combo, str); - action_combo.set_active_text (str.front()); - action_combo.set_sensitive (false); + l->set_markup (_("Add files ...")); + options.attach (*l, 0, 1, 0, 1, FILL, SHRINK, 8, 0); + options.attach (action_combo, 0, 1, 1, 2, FILL, SHRINK, 8, 0); l = manage (new Label); l->set_markup (_("Insert at")); - - vbox = manage (new VBox); - vbox->set_border_width (12); - vbox->set_spacing (6); - vbox->pack_start (*l, false, false); - vbox->pack_start (where_combo, false, false); - hbox = manage (new HBox); - hbox->pack_start (*vbox, false, false); - options.pack_start (*hbox, false, false); - + options.attach (*l, 0, 1, 3, 4, FILL, SHRINK, 8, 0); + options.attach (where_combo, 0, 1, 4, 5, FILL, SHRINK, 8, 0); l = manage (new Label); l->set_markup (_("Mapping")); - - vbox = manage (new VBox); - vbox->set_border_width (12); - vbox->set_spacing (6); - vbox->pack_start (*l, false, false); - vbox->pack_start (channel_combo, false, false); - hbox = manage (new HBox); - hbox->pack_start (*vbox, false, false); - options.pack_start (*hbox, false, false); - - str.clear (); - str.push_back (_("one track per file")); - set_popdown_strings (channel_combo, str); - channel_combo.set_active_text (str.front()); - channel_combo.set_sensitive (false); + options.attach (*l, 1, 2, 0, 1, FILL, SHRINK, 8, 0); + options.attach (channel_combo, 1, 2, 1, 2, FILL, SHRINK, 8, 0); l = manage (new Label); l->set_markup (_("Conversion quality")); + options.attach (*l, 1, 2, 3, 4, FILL, SHRINK, 8, 0); + options.attach (src_combo, 1, 2, 4, 5, FILL, SHRINK, 8, 0); + + l = manage (new Label); + l->set_markup (_("MIDI Track Names")); + options.attach (*l, 2, 3, 0, 1, FILL, SHRINK, 8, 0); + options.attach (midi_track_name_combo, 2, 3, 1, 2, FILL, SHRINK, 8, 0); - vbox = manage (new VBox); - vbox->set_border_width (12); - vbox->set_spacing (6); - vbox->pack_start (*l, false, false); - vbox->pack_start (src_combo, false, false); - hbox = manage (new HBox); - hbox->pack_start (*vbox, false, false); - options.pack_start (*hbox, false, false); + options.attach (smf_tempo_btn, 2, 3, 3, 4, FILL, SHRINK, 8, 0); l = manage (new Label); l->set_markup (_("Instrument")); + options.attach (*l, 3, 4, 0, 1, FILL, SHRINK, 8, 0); + options.attach (instrument_combo, 3, 4, 1, 2, FILL, SHRINK, 8, 0); + + Alignment *hspace = manage (new Alignment ()); + hspace->set_size_request (2, 2); + options.attach (*hspace, 0, 3, 2, 3, FILL, SHRINK, 0, 8); + + Alignment *vspace = manage (new Alignment ()); + vspace->set_size_request (2, 2); + options.attach (*vspace, 2, 3, 0, 3, EXPAND, SHRINK, 0, 0); - 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 (_("by track number")); + str.push_back (_("by track name")); + str.push_back (_("by instrument name")); + set_popdown_strings (midi_track_name_combo, str); + midi_track_name_combo.set_active_text (str.front()); + + str.clear (); + str.push_back (_("one track per file")); + set_popdown_strings (channel_combo, str); + channel_combo.set_active_text (str.front()); + channel_combo.set_sensitive (false); str.clear (); str.push_back (_("Best")); @@ -1774,8 +1862,6 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, src_combo.set_sensitive (false); src_combo.signal_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::src_combo_changed)); - reset_options (); - action_combo.signal_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::reset_options_noret)); channel_combo.signal_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::reset_options_noret)); @@ -1789,10 +1875,9 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, } block_four.pack_start (copy_files_btn, false, false); + options.attach (block_four, 3, 4, 4, 5, FILL, SHRINK, 8, 0); - options.pack_start (block_four, false, false); - - vpacker.pack_start (options, false, false); + vpacker.pack_start (options, false, true); /* setup disposition map */ @@ -1813,19 +1898,22 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, selects a file to import, which in turn prevents the size of the dialog from jumping around. */ - vector t; - t.push_back (_("one track per file")); - t.push_back (_("one track per channel")); - t.push_back (_("sequence files")); - t.push_back (_("all files in one region")); - set_popdown_strings (channel_combo, t); + str.clear (); + str.push_back (_("one track per file")); + str.push_back (_("one track per channel")); + str.push_back (_("sequence files")); + str.push_back (_("all files in one region")); + set_popdown_strings (channel_combo, str); + + str.clear (); + str.push_back (importmode2string (ImportAsTrack)); + str.push_back (importmode2string (ImportToTrack)); + str.push_back (importmode2string (ImportAsRegion)); + str.push_back (importmode2string (ImportAsTapeTrack)); + set_popdown_strings (action_combo, str); + action_combo.set_active_text (importmode2string(mode_hint)); - t.clear (); - t.push_back (importmode2string (ImportAsTrack)); - t.push_back (importmode2string (ImportToTrack)); - t.push_back (importmode2string (ImportAsRegion)); - t.push_back (importmode2string (ImportAsTapeTrack)); - set_popdown_strings (action_combo, t); + reset (selected_audio_tracks, selected_midi_tracks); } void @@ -1895,6 +1983,18 @@ SoundFileOmega::where_combo_changed() preview.set_import_position(get_position()); } +MidiTrackNameSource +SoundFileOmega::get_midi_track_name_source () const +{ + return string2miditracknamesource (midi_track_name_combo.get_active_text()); +} + +bool +SoundFileOmega::get_use_smf_tempo_map () const +{ + return smf_tempo_btn.get_active (); +} + ImportDisposition SoundFileOmega::get_channel_disposition () const { @@ -1960,14 +2060,16 @@ SoundFileOmega::do_something (int action) } /* lets do it */ - + vector paths = get_paths (); ImportPosition pos = get_position (); ImportMode mode = get_mode (); ImportDisposition chns = get_channel_disposition (); PluginInfoPtr instrument = instrument_combo.selected_instrument(); - framepos_t where; - + samplepos_t where; + MidiTrackNameSource mts = get_midi_track_name_source (); + MidiTempoMapDisposition mtd = (get_use_smf_tempo_map () ? SMFTempoUse : SMFTempoIgnore); + switch (pos) { case ImportAtEditPoint: where = PublicEditor::instance().get_preferred_edit_position (); @@ -1976,19 +2078,27 @@ SoundFileOmega::do_something (int action) where = -1; break; case ImportAtPlayhead: - where = _session->transport_frame(); + where = _session->transport_sample(); break; case ImportAtStart: - where = _session->current_start_frame(); + where = _session->current_start_sample(); break; } - + SrcQuality quality = get_src_quality(); - + + _import_active = true; + if (copy_files_btn.get_active()) { - PublicEditor::instance().do_import (paths, chns, mode, quality, where, instrument); + PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument); } else { PublicEditor::instance().do_embed (paths, chns, mode, where, instrument); } + + _import_active = false; + + if (_reset_post_import) { + _reset_post_import = false; + reset_options (); + } } -