X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fsfdb_ui.cc;h=c9788c8314fcb79a341e433ac42461e53c5570b0;hb=b115a04babe8435eeaba36469eeb6145250c70cd;hp=5a8de6c5508789dadb46de51fd7d8053d1b61c57;hpb=eb58c4108f9ab7ab04fda7913042a0350dff68c7;p=ardour.git diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 5a8de6c550..c9788c8314 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -31,15 +31,16 @@ #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,11 +58,11 @@ #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" @@ -84,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; @@ -120,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")); @@ -152,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); @@ -169,12 +190,14 @@ 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()); timecode_clock.set_mode (AudioClock::Timecode); @@ -214,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); @@ -304,18 +330,37 @@ SoundFileBox::setup_labels (const string& filename) if (ms) { if (ms->is_type0()) { - channels_value.set_text (to_string(ms->channels().size(), std::dec)); + channels_value.set_text (to_string(ms->channels().size())); } else { if (ms->num_tracks() > 1) { - channels_value.set_text (to_string(ms->num_tracks(), std::dec) + _("(Tracks)")); + channels_value.set_text (to_string(ms->num_tracks()) + _("(Tracks)")); } else { - channels_value.set_text (to_string(ms->num_tracks(), std::dec)); + 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) { @@ -350,7 +395,7 @@ 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()) { samplerate.set_markup (string_compose ("%1", _("Sample rate:"))); @@ -391,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 { @@ -564,7 +625,6 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s, bool persi , _status (0) , _done (false) , import_button (_("Import")) - , close_button (Stock::CLOSE) , gm (0) { @@ -740,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); @@ -781,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) { @@ -795,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 () { @@ -805,7 +884,7 @@ SoundFileBrowser::clear_selection () void SoundFileBrowser::chooser_file_activated () { - preview.audition (); + do_something (RESPONSE_OK); } void @@ -1356,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; @@ -1401,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(); @@ -1437,12 +1524,12 @@ SoundFileOmega::reset_options () 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. @@ -1687,6 +1774,7 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, 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) @@ -1729,6 +1817,13 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, 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); + + 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); @@ -1742,6 +1837,13 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, vspace->set_size_request (2, 2); options.attach (*vspace, 2, 3, 0, 3, EXPAND, SHRINK, 0, 0); + 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); @@ -1881,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 { @@ -1953,6 +2067,8 @@ SoundFileOmega::do_something (int action) ImportDisposition chns = get_channel_disposition (); PluginInfoPtr instrument = instrument_combo.selected_instrument(); framepos_t where; + MidiTrackNameSource mts = get_midi_track_name_source (); + MidiTempoMapDisposition mtd = (get_use_smf_tempo_map () ? SMFTempoUse : SMFTempoIgnore); switch (pos) { case ImportAtEditPoint: @@ -1974,7 +2090,7 @@ SoundFileOmega::do_something (int action) _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); } @@ -1986,4 +2102,3 @@ SoundFileOmega::do_something (int action) reset_options (); } } -