#include "gtk2ardour-config.h"
#endif
-#include "i18n.h"
+#include "pbd/i18n.h"
#include <map>
#include <cerrno>
#include "pbd/gstdio_compat.h"
#include <glibmm/fileutils.h>
-#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 <gtkmm2ext/utils.h>
#include "ardour/session.h"
#include "ardour/session_directory.h"
#include "ardour/srcfilesource.h"
+#include "ardour/profile.h"
#include "ardour_ui.h"
#include "editing.h"
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;
}
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"));
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);
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);
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<uint32_t>(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) {
return false;
}
- preview_label.set_markup (string_compose ("<b>%1</b>", Glib::Markup::escape_text (Glib::path_get_basename (filename)).c_str()));
+ preview_label.set_markup (string_compose ("<b>%1</b>", Glib::Markup::escape_text (Glib::path_get_basename (filename))));
std::string n = sf_info.format_name;
if (n.substr (0, 8) == X_("Format: ")) {
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 ("<b>%1</b>", _("Sample rate:")));
, 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.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
notebook.append_page (*vbox, _("Search Tags"));
//add freesound search
+#ifdef FREESOUND_GOT_FIXED
HBox* passbox;
Label* label;
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)))));
boost::shared_ptr<Route> 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);
std::string theString = mootcher.searchText(
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",
bool
SoundFileOmega::reset_options ()
{
+ if (_import_active) {
+ _reset_post_import = true;
+ return true;
+ }
+
vector<string> paths = get_paths ();
if (paths.empty()) {
return false;
}
+ if (have_a_midi_file) {
+ smf_tempo_btn.show ();
+ } else {
+ smf_tempo_btn.hide ();
+ }
+
string existing_choice;
vector<string> action_strings;
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();
vector<string> 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.
} 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;
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<string> 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 (_("<b>Add files ...</b>"));
-
- 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);
+ 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 (_("<b>Insert at</b>"));
-
- 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 (_("<b>Mapping</b>"));
-
- 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 (_("<b>Conversion quality</b>"));
+ 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 (_("<b>MIDI Track Names</b>"));
+ 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 (_("<b>Instrument</b>"));
+ 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);
+
+ 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());
- 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 (_("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"));
}
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 */
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
{
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:
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 ();
+ }
+}