Ardour  8.12
sfdb_ui.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2007 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2012-2017 Robin Gareus <robin@gareus.org>
7  * Copyright (C) 2013 Colin Fletcher <colin.m.fletcher@googlemail.com>
8  * Copyright (C) 2015-2017 Tim Mayberry <mojofunk@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #ifndef __ardour_sfdb_ui_h__
26 #define __ardour_sfdb_ui_h__
27 
28 #include <string>
29 #include <vector>
30 #include <map>
31 
32 #include <sigc++/signal.h>
33 
34 #include <gtkmm/stock.h>
35 #include <gtkmm/box.h>
36 #include <gtkmm/button.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/comboboxtext.h>
39 #include <gtkmm/dialog.h>
40 #include <gtkmm/entry.h>
42 #include <gtkmm/frame.h>
43 #include <gtkmm/label.h>
44 #include <gtkmm/scale.h>
45 #include <gtkmm/textview.h>
46 #include <gtkmm/table.h>
47 #include <gtkmm/liststore.h>
48 #include <gtkmm/spinbutton.h>
49 #include <gtkmm/notebook.h>
50 
51 
52 #include "ardour/audiofilesource.h"
53 #include "ardour/session_handle.h"
54 
55 #include "ardour_window.h"
56 #include "editing.h"
57 #include "audio_clock.h"
58 #include "instrument_selector.h"
59 
60 namespace ARDOUR {
61  class Session;
62 };
63 
64 class GainMeter;
65 class Mootcher;
66 
68 {
69 public:
70  SoundFileBox (bool persistent);
71  virtual ~SoundFileBox () {};
72 
74  bool setup_labels (const std::string& filename);
75 
76  void audition();
78  bool autoplay () const;
81 
82 protected:
84 
85  std::string path;
86 
88 
90 
97 
101 
105 
108 
110 
114 
120 
122  void audition_active(bool);
124 
127 
129  void tags_changed ();
130  void save_tags (const std::vector<std::string>&);
131  void stop_audition ();
134  bool _seeking;
137 };
138 
140 {
141 private:
143  {
144  public:
146 
148  };
149 
151  {
152  public:
162 
164  add(id);
165  add(filename);
166  add(uri);
167  add(duration);
168  add(filesize);
169  add(smplrate);
170  add(license);
171  add(tooltip);
172  add(downloading);
173  }
174  };
175 
177  Glib::RefPtr<Gtk::ListStore> found_list;
178 
180  Glib::RefPtr<Gtk::ListStore> freesound_list;
181 
184 
185  void handle_freesound_results(std::string theString);
187 public:
188  SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
189  virtual ~SoundFileBrowser ();
190 
191  int run ();
192  int status () const { return _status; }
193 
194  virtual void set_session (ARDOUR::Session*);
195  std::vector<std::string> get_paths ();
196 
198 
200 
202 
206 
210 
214 
216  void refresh_display(std::string ID, std::string file);
217 
218 protected:
220  int matches;
221  int _status;
222  bool _done;
223 
231 
233 
234  static std::string persistent_folder;
235 
238  void add_gain_meter ();
240  void meter ();
241  void start_metering ();
242  void stop_metering ();
243  sigc::connection metering_connection;
244 
245  void update_preview ();
246 
250 
258  std::string freesound_token; // keep oauth token while ardour is running
259 
262 
263  bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
264  bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
266 
267  void set_action_sensitive (bool);
268  bool get_action_sensitive () const;
269 
270  virtual bool reset_options () { return true; }
271 
272  void on_show();
274  virtual void do_something(int action);
275 
276  enum SortOrder {
279  FileMtime
280  };
281 
282  virtual SortOrder sort_order () const {
283  return SelectionOrder;
284  }
285 };
286 
288 {
289 public:
290  SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
291  virtual ~SoundFileChooser () {};
292 
293  std::string get_filename ();
294 
295 protected:
296  void on_hide();
297 };
298 
300 {
301 public:
302  SoundFileOmega (std::string title,
303  ARDOUR::Session* _s,
304  uint32_t selected_audio_tracks,
305  uint32_t selected_midi_tracks,
306  bool persistent,
307  Editing::ImportMode mode_hint = Editing::ImportAsTrack);
308 
309  void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
310 
318 
322 
326  bool get_use_smf_tempo_map () const;
327  bool get_use_smf_markers () const;
331 
332 protected:
333  void on_hide();
334  virtual SortOrder sort_order () const;
335 
336 private:
339 
340  typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
342 
344 
345  bool check_info (const std::vector<std::string>& paths,
346  bool& same_size, bool& src_needed, bool& multichannel, bool& must_copy);
347 
348  static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
349 
351 
353  bool reset_options ();
358 
359  void do_something (int action);
360 
363 };
364 
365 #endif // __ardour_sfdb_ui_h__
void add(TreeModelColumnBase &column)
void path(Glib::ustring &path, Glib::ustring &path_reversed)
Compute a widget's path of the form "GtkWindow.MyLabel".
bool event(GdkEvent *event)
void set_import_position(Editing::ImportPosition p)
Definition: sfdb_ui.h:80
Gtk::Label channels_value
Definition: sfdb_ui.h:98
Gtk::Label channels
Definition: sfdb_ui.h:93
Gtk::Label format_text
Definition: sfdb_ui.h:102
Gtk::HBox bottom_box
Definition: sfdb_ui.h:113
Gtk::VBox path_box
Definition: sfdb_ui.h:112
bool setup_labels(const std::string &filename)
AudioClock length_clock
Definition: sfdb_ui.h:103
virtual ~SoundFileBox()
Definition: sfdb_ui.h:71
Gtk::CheckButton autoplay_btn
Definition: sfdb_ui.h:117
Gtk::HScale seek_slider
Definition: sfdb_ui.h:119
Gtk::Label preview_label
Definition: sfdb_ui.h:107
Gtk::Label samplerate_value
Definition: sfdb_ui.h:99
Gtk::Label format
Definition: sfdb_ui.h:92
Gtk::Button stop_btn
Definition: sfdb_ui.h:116
void stop_audition()
bool audition_oneshot()
Gtk::Button apply_btn
Definition: sfdb_ui.h:118
Gtk::Label tempomap
Definition: sfdb_ui.h:96
void audition_progress(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)
Gtk::TextView tags_entry
Definition: sfdb_ui.h:109
Gtk::VBox main_box
Definition: sfdb_ui.h:111
ARDOUR::SoundFileInfo sf_info
Definition: sfdb_ui.h:87
bool _seeking
Definition: sfdb_ui.h:134
void on_size_request(Gtk::Requisition *)
This is a default handler for the signal signal_size_request().
AudioClock timecode_clock
Definition: sfdb_ui.h:104
bool tags_entry_left(GdkEventFocus *event)
bool seek_button_release(GdkEventButton *)
void save_tags(const std::vector< std::string > &)
ARDOUR::SrcQuality _src_quality
Definition: sfdb_ui.h:135
Gtk::Label samplerate
Definition: sfdb_ui.h:94
void audition()
Gtk::Button play_btn
Definition: sfdb_ui.h:115
bool seek_button_press(GdkEventButton *)
Gtk::Label timecode
Definition: sfdb_ui.h:95
bool autoplay() const
Gtk::Label length
Definition: sfdb_ui.h:91
Gtk::Table table
Definition: sfdb_ui.h:89
std::string path
Definition: sfdb_ui.h:85
Editing::ImportPosition _import_position
Definition: sfdb_ui.h:136
void set_src_quality(ARDOUR::SrcQuality q)
Definition: sfdb_ui.h:79
SoundFileBox(bool persistent)
Gtk::Label tempomap_value
Definition: sfdb_ui.h:100
PBD::ScopedConnectionList auditioner_connections
Definition: sfdb_ui.h:121
Gtk::Frame border_frame
Definition: sfdb_ui.h:106
void update_autoplay()
void audition_active(bool)
void tags_changed()
void autoplay_toggled()
void set_session(ARDOUR::Session *s)
Gtk::TreeModelColumn< std::string > pathname
Definition: sfdb_ui.h:145
Gtk::TreeModelColumn< std::string > uri
Definition: sfdb_ui.h:154
Gtk::TreeModelColumn< std::string > duration
Definition: sfdb_ui.h:156
Gtk::TreeModelColumn< std::string > filesize
Definition: sfdb_ui.h:157
Gtk::TreeModelColumn< bool > downloading
Definition: sfdb_ui.h:161
Gtk::TreeModelColumn< std::string > filename
Definition: sfdb_ui.h:155
Gtk::TreeModelColumn< std::string > smplrate
Definition: sfdb_ui.h:158
Gtk::TreeModelColumn< std::string > tooltip
Definition: sfdb_ui.h:160
Gtk::TreeModelColumn< std::string > license
Definition: sfdb_ui.h:159
Gtk::TreeModelColumn< std::string > id
Definition: sfdb_ui.h:153
void freesound_search_params_changed()
void handle_freesound_results(std::string theString)
Gtk::Button freesound_similar_btn
Definition: sfdb_ui.h:183
Gtk::Button found_search_btn
Definition: sfdb_ui.h:204
Glib::RefPtr< Gtk::ListStore > freesound_list
Definition: sfdb_ui.h:180
void freesound_similar_clicked()
Gtk::FileFilter custom_filter
Definition: sfdb_ui.h:227
Gtk::FileChooserWidget chooser
Definition: sfdb_ui.h:199
Gtk::HBox hpacker
Definition: sfdb_ui.h:229
void chooser_file_activated()
void refresh_display(std::string ID, std::string file)
bool on_audio_and_midi_filter(const Gtk::FileFilter::Info &filter_info)
void set_action_sensitive(bool)
std::string freesound_licence_filter()
std::string freesound_get_audio_file(Gtk::TreeIter iter)
Gtk::VBox meter_packer
Definition: sfdb_ui.h:237
Glib::RefPtr< Gtk::ListStore > found_list
Definition: sfdb_ui.h:177
Gtk::Entry found_entry
Definition: sfdb_ui.h:203
void found_list_view_selected()
Gtk::Notebook notebook
Definition: sfdb_ui.h:213
bool on_key_press_event(GdkEventKey *)
This is a default handler for the signal signal_key_press_event().
std::string freesound_token
Definition: sfdb_ui.h:258
std::vector< std::string > get_paths()
void on_show()
This is a default handler for the signal signal_show().
virtual bool reset_options()
Definition: sfdb_ui.h:270
static std::string persistent_folder
Definition: sfdb_ui.h:234
bool resetting_ourselves
Definition: sfdb_ui.h:219
Gtk::FileFilter matchall_filter
Definition: sfdb_ui.h:228
void clear_selection()
SoundFileBrowser(std::string title, ARDOUR::Session *_s, bool persistent)
virtual SortOrder sort_order() const
Definition: sfdb_ui.h:282
virtual void do_something(int action)
bool get_action_sensitive() const
void freesound_search_clicked()
SoundFileBox preview
Definition: sfdb_ui.h:201
Gtk::Entry freesound_entry
Definition: sfdb_ui.h:207
void freesound_search()
Gtk::Button freesound_search_btn
Definition: sfdb_ui.h:211
Gtk::TreeView found_list_view
Definition: sfdb_ui.h:205
void freesound_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
void freesound_list_view_selected()
Gtk::TreeView freesound_list_view
Definition: sfdb_ui.h:212
virtual ~SoundFileBrowser()
FreesoundColumns freesound_list_columns
Definition: sfdb_ui.h:179
Gtk::FileFilter audio_and_midi_filter
Definition: sfdb_ui.h:224
GainMeter * gm
Definition: sfdb_ui.h:236
virtual void set_session(ARDOUR::Session *)
bool on_midi_filter(const Gtk::FileFilter::Info &filter_info)
FoundTagColumns found_list_columns
Definition: sfdb_ui.h:176
Gtk::FileFilter midi_filter
Definition: sfdb_ui.h:226
void remove_gain_meter()
Gtk::FileFilter audio_filter
Definition: sfdb_ui.h:225
Gtk::Button import_button
Definition: sfdb_ui.h:232
sigc::connection metering_connection
Definition: sfdb_ui.h:243
void found_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
Gtk::ComboBoxText freesound_sort
Definition: sfdb_ui.h:208
void found_search_clicked()
int status() const
Definition: sfdb_ui.h:192
Gtk::ComboBoxText freesound_licence
Definition: sfdb_ui.h:209
int freesound_page
Definition: sfdb_ui.h:257
void freesound_more_clicked()
Gtk::Button freesound_more_btn
Definition: sfdb_ui.h:182
bool on_audio_filter(const Gtk::FileFilter::Info &filter_info)
Gtk::VBox vpacker
Definition: sfdb_ui.h:230
SoundFileChooser(std::string title, ARDOUR::Session *_s=0)
virtual ~SoundFileChooser()
Definition: sfdb_ui.h:291
std::string get_filename()
void on_hide()
This is a default handler for the signal signal_hide().
Gtk::ComboBoxText action_combo
Definition: sfdb_ui.h:311
static bool check_link_status(const ARDOUR::Session *, const std::vector< std::string > &paths)
Gtk::Table options
Definition: sfdb_ui.h:343
Gtk::CheckButton copy_files_btn
Definition: sfdb_ui.h:319
bool check_info(const std::vector< std::string > &paths, bool &same_size, bool &src_needed, bool &multichannel, bool &must_copy)
bool get_use_smf_markers() const
Gtk::ComboBoxText channel_combo
Definition: sfdb_ui.h:314
Gtk::ComboBoxText where_combo
Definition: sfdb_ui.h:313
bool bad_file_message()
Editing::ImportDisposition get_channel_disposition() const
virtual SortOrder sort_order() const
void do_something(int action)
void set_mode(Editing::ImportMode)
InstrumentSelector instrument_combo
Definition: sfdb_ui.h:317
Gtk::CheckButton smf_marker_btn
Definition: sfdb_ui.h:321
std::map< std::string, Editing::ImportDisposition > DispositionMap
Definition: sfdb_ui.h:340
void reset_options_noret()
DispositionMap disposition_map
Definition: sfdb_ui.h:341
Editing::ImportMode get_mode() const
void file_selection_changed()
Gtk::ComboBoxText midi_track_name_combo
Definition: sfdb_ui.h:316
bool get_use_smf_tempo_map() const
void on_hide()
This is a default handler for the signal signal_hide().
ARDOUR::MidiTrackNameSource get_midi_track_name_source() const
void reset(uint32_t selected_audio_tracks, uint32_t selected_midi_tracks)
bool _import_active
Definition: sfdb_ui.h:361
uint32_t selected_audio_track_cnt
Definition: sfdb_ui.h:337
Editing::ImportPosition get_position() const
Gtk::CheckButton smf_tempo_btn
Definition: sfdb_ui.h:320
Gtk::ComboBoxText src_combo
Definition: sfdb_ui.h:315
bool _reset_post_import
Definition: sfdb_ui.h:362
uint32_t selected_midi_track_cnt
Definition: sfdb_ui.h:338
void where_combo_changed()
void src_combo_changed()
bool reset_options()
Gtk::ComboBoxText sort_combo
Definition: sfdb_ui.h:312
SoundFileOmega(std::string title, ARDOUR::Session *_s, uint32_t selected_audio_tracks, uint32_t selected_midi_tracks, bool persistent, Editing::ImportMode mode_hint=Editing::ImportAsTrack)
ARDOUR::SrcQuality get_src_quality() const
void instrument_combo_changed()
Temporal::samplecnt_t samplecnt_t
ImportDisposition
Definition: editing.h:176
ImportMode
Definition: editing.h:156
ImportPosition
Definition: editing.h:166