Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
26 
27 #include <string>
28 #include <vector>
29 #include <map>
30 
31 #include <sigc++/signal.h>
32 
33 #include <gtkmm/stock.h>
34 #include <gtkmm/box.h>
35 #include <gtkmm/button.h>
36 #include <gtkmm/checkbutton.h>
37 #include <gtkmm/comboboxtext.h>
38 #include <gtkmm/dialog.h>
39 #include <gtkmm/entry.h>
41 #include <gtkmm/frame.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/scale.h>
44 #include <gtkmm/textview.h>
45 #include <gtkmm/table.h>
46 #include <gtkmm/liststore.h>
47 #include <gtkmm/spinbutton.h>
48 #include <gtkmm/notebook.h>
49 
50 
51 #include "ardour/audiofilesource.h"
52 #include "ardour/session_handle.h"
53 
54 #include "ardour_window.h"
55 #include "editing.h"
56 #include "audio_clock.h"
57 #include "instrument_selector.h"
58 
59 namespace ARDOUR {
60  class Session;
61 };
62 
63 class GainMeter;
64 class Mootcher;
65 
67 {
68 public:
69  SoundFileBox (bool persistent);
70  virtual ~SoundFileBox () {};
71 
73  bool setup_labels (const std::string& filename);
74 
75  void audition();
77  bool autoplay () const;
80 
81 protected:
83 
84  std::string path;
85 
87 
89 
96 
100 
104 
107 
109 
113 
119 
121  void audition_active(bool);
123 
126 
128  void tags_changed ();
129  void save_tags (const std::vector<std::string>&);
130  void stop_audition ();
133  bool _seeking;
136 };
137 
139 {
140 private:
142  {
143  public:
145 
147  };
148 
150  {
151  public:
161 
163  add(id);
164  add(filename);
165  add(uri);
166  add(duration);
167  add(filesize);
168  add(smplrate);
169  add(license);
170  add(tooltip);
171  add(downloading);
172  }
173  };
174 
176  Glib::RefPtr<Gtk::ListStore> found_list;
177 
179  Glib::RefPtr<Gtk::ListStore> freesound_list;
180 
183 
184  void handle_freesound_results(std::string theString);
186 public:
187  SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
188  virtual ~SoundFileBrowser ();
189 
190  int run ();
191  int status () const { return _status; }
192 
193  virtual void set_session (ARDOUR::Session*);
194  std::vector<std::string> get_paths ();
195 
197 
199 
201 
205 
209 
213 
215  void refresh_display(std::string ID, std::string file);
216 
217 protected:
219  int matches;
220  int _status;
221  bool _done;
222 
230 
232 
233  static std::string persistent_folder;
234 
237  void add_gain_meter ();
239  void meter ();
240  void start_metering ();
241  void stop_metering ();
242  sigc::connection metering_connection;
243 
244  void update_preview ();
245 
249 
257  std::string freesound_token; // keep oauth token while ardour is running
258 
261 
262  bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
263  bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
265 
266  void set_action_sensitive (bool);
267  bool get_action_sensitive () const;
268 
269  virtual bool reset_options () { return true; }
270 
271  void on_show();
273  virtual void do_something(int action);
274 
275  enum SortOrder {
278  FileMtime
279  };
280 
281  virtual SortOrder sort_order () const {
282  return SelectionOrder;
283  }
284 };
285 
287 {
288 public:
289  SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
290  virtual ~SoundFileChooser () {};
291 
292  std::string get_filename ();
293 
294 protected:
295  void on_hide();
296 };
297 
299 {
300 public:
301  SoundFileOmega (std::string title,
302  ARDOUR::Session* _s,
303  uint32_t selected_audio_tracks,
304  uint32_t selected_midi_tracks,
305  bool persistent,
306  Editing::ImportMode mode_hint = Editing::ImportAsTrack);
307 
308  void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
309 
317 
321 
325  bool get_use_smf_tempo_map () const;
326  bool get_use_smf_markers () const;
330 
331 protected:
332  void on_hide();
333  virtual SortOrder sort_order () const;
334 
335 private:
338 
339  typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
341 
343 
344  bool check_info (const std::vector<std::string>& paths,
345  bool& same_size, bool& src_needed, bool& multichannel, bool& must_copy);
346 
347  static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
348 
350 
352  bool reset_options ();
357 
358  void do_something (int action);
359 
362 };
363 
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:79
Gtk::Label channels_value
Definition: sfdb_ui.h:97
Gtk::Label channels
Definition: sfdb_ui.h:92
Gtk::Label format_text
Definition: sfdb_ui.h:101
Gtk::HBox bottom_box
Definition: sfdb_ui.h:112
Gtk::VBox path_box
Definition: sfdb_ui.h:111
bool setup_labels(const std::string &filename)
AudioClock length_clock
Definition: sfdb_ui.h:102
virtual ~SoundFileBox()
Definition: sfdb_ui.h:70
Gtk::CheckButton autoplay_btn
Definition: sfdb_ui.h:116
Gtk::HScale seek_slider
Definition: sfdb_ui.h:118
Gtk::Label preview_label
Definition: sfdb_ui.h:106
Gtk::Label samplerate_value
Definition: sfdb_ui.h:98
Gtk::Label format
Definition: sfdb_ui.h:91
Gtk::Button stop_btn
Definition: sfdb_ui.h:115
void stop_audition()
bool audition_oneshot()
Gtk::Button apply_btn
Definition: sfdb_ui.h:117
Gtk::Label tempomap
Definition: sfdb_ui.h:95
void audition_progress(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)
Gtk::TextView tags_entry
Definition: sfdb_ui.h:108
Gtk::VBox main_box
Definition: sfdb_ui.h:110
ARDOUR::SoundFileInfo sf_info
Definition: sfdb_ui.h:86
bool _seeking
Definition: sfdb_ui.h:133
void on_size_request(Gtk::Requisition *)
This is a default handler for the signal signal_size_request().
AudioClock timecode_clock
Definition: sfdb_ui.h:103
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:134
Gtk::Label samplerate
Definition: sfdb_ui.h:93
void audition()
Gtk::Button play_btn
Definition: sfdb_ui.h:114
bool seek_button_press(GdkEventButton *)
Gtk::Label timecode
Definition: sfdb_ui.h:94
bool autoplay() const
Gtk::Label length
Definition: sfdb_ui.h:90
Gtk::Table table
Definition: sfdb_ui.h:88
std::string path
Definition: sfdb_ui.h:84
Editing::ImportPosition _import_position
Definition: sfdb_ui.h:135
void set_src_quality(ARDOUR::SrcQuality q)
Definition: sfdb_ui.h:78
SoundFileBox(bool persistent)
Gtk::Label tempomap_value
Definition: sfdb_ui.h:99
PBD::ScopedConnectionList auditioner_connections
Definition: sfdb_ui.h:120
Gtk::Frame border_frame
Definition: sfdb_ui.h:105
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:144
Gtk::TreeModelColumn< std::string > uri
Definition: sfdb_ui.h:153
Gtk::TreeModelColumn< std::string > duration
Definition: sfdb_ui.h:155
Gtk::TreeModelColumn< std::string > filesize
Definition: sfdb_ui.h:156
Gtk::TreeModelColumn< bool > downloading
Definition: sfdb_ui.h:160
Gtk::TreeModelColumn< std::string > filename
Definition: sfdb_ui.h:154
Gtk::TreeModelColumn< std::string > smplrate
Definition: sfdb_ui.h:157
Gtk::TreeModelColumn< std::string > tooltip
Definition: sfdb_ui.h:159
Gtk::TreeModelColumn< std::string > license
Definition: sfdb_ui.h:158
Gtk::TreeModelColumn< std::string > id
Definition: sfdb_ui.h:152
void freesound_search_params_changed()
void handle_freesound_results(std::string theString)
Gtk::Button freesound_similar_btn
Definition: sfdb_ui.h:182
Gtk::Button found_search_btn
Definition: sfdb_ui.h:203
Glib::RefPtr< Gtk::ListStore > freesound_list
Definition: sfdb_ui.h:179
void freesound_similar_clicked()
Gtk::FileFilter custom_filter
Definition: sfdb_ui.h:226
Gtk::FileChooserWidget chooser
Definition: sfdb_ui.h:198
Gtk::HBox hpacker
Definition: sfdb_ui.h:228
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:236
Glib::RefPtr< Gtk::ListStore > found_list
Definition: sfdb_ui.h:176
Gtk::Entry found_entry
Definition: sfdb_ui.h:202
void found_list_view_selected()
Gtk::Notebook notebook
Definition: sfdb_ui.h:212
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:257
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:269
static std::string persistent_folder
Definition: sfdb_ui.h:233
bool resetting_ourselves
Definition: sfdb_ui.h:218
Gtk::FileFilter matchall_filter
Definition: sfdb_ui.h:227
void clear_selection()
SoundFileBrowser(std::string title, ARDOUR::Session *_s, bool persistent)
virtual SortOrder sort_order() const
Definition: sfdb_ui.h:281
virtual void do_something(int action)
bool get_action_sensitive() const
void freesound_search_clicked()
SoundFileBox preview
Definition: sfdb_ui.h:200
Gtk::Entry freesound_entry
Definition: sfdb_ui.h:206
void freesound_search()
Gtk::Button freesound_search_btn
Definition: sfdb_ui.h:210
Gtk::TreeView found_list_view
Definition: sfdb_ui.h:204
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:211
virtual ~SoundFileBrowser()
FreesoundColumns freesound_list_columns
Definition: sfdb_ui.h:178
Gtk::FileFilter audio_and_midi_filter
Definition: sfdb_ui.h:223
GainMeter * gm
Definition: sfdb_ui.h:235
virtual void set_session(ARDOUR::Session *)
bool on_midi_filter(const Gtk::FileFilter::Info &filter_info)
FoundTagColumns found_list_columns
Definition: sfdb_ui.h:175
Gtk::FileFilter midi_filter
Definition: sfdb_ui.h:225
void remove_gain_meter()
Gtk::FileFilter audio_filter
Definition: sfdb_ui.h:224
Gtk::Button import_button
Definition: sfdb_ui.h:231
sigc::connection metering_connection
Definition: sfdb_ui.h:242
void found_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
Gtk::ComboBoxText freesound_sort
Definition: sfdb_ui.h:207
void found_search_clicked()
int status() const
Definition: sfdb_ui.h:191
Gtk::ComboBoxText freesound_licence
Definition: sfdb_ui.h:208
int freesound_page
Definition: sfdb_ui.h:256
void freesound_more_clicked()
Gtk::Button freesound_more_btn
Definition: sfdb_ui.h:181
bool on_audio_filter(const Gtk::FileFilter::Info &filter_info)
Gtk::VBox vpacker
Definition: sfdb_ui.h:229
SoundFileChooser(std::string title, ARDOUR::Session *_s=0)
virtual ~SoundFileChooser()
Definition: sfdb_ui.h:290
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:310
static bool check_link_status(const ARDOUR::Session *, const std::vector< std::string > &paths)
Gtk::Table options
Definition: sfdb_ui.h:342
Gtk::CheckButton copy_files_btn
Definition: sfdb_ui.h:318
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:313
Gtk::ComboBoxText where_combo
Definition: sfdb_ui.h:312
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:316
Gtk::CheckButton smf_marker_btn
Definition: sfdb_ui.h:320
std::map< std::string, Editing::ImportDisposition > DispositionMap
Definition: sfdb_ui.h:339
void reset_options_noret()
DispositionMap disposition_map
Definition: sfdb_ui.h:340
Editing::ImportMode get_mode() const
void file_selection_changed()
Gtk::ComboBoxText midi_track_name_combo
Definition: sfdb_ui.h:315
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:360
uint32_t selected_audio_track_cnt
Definition: sfdb_ui.h:336
Editing::ImportPosition get_position() const
Gtk::CheckButton smf_tempo_btn
Definition: sfdb_ui.h:319
Gtk::ComboBoxText src_combo
Definition: sfdb_ui.h:314
bool _reset_post_import
Definition: sfdb_ui.h:361
uint32_t selected_midi_track_cnt
Definition: sfdb_ui.h:337
void where_combo_changed()
void src_combo_changed()
bool reset_options()
Gtk::ComboBoxText sort_combo
Definition: sfdb_ui.h:311
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:175
ImportMode
Definition: editing.h:155
ImportPosition
Definition: editing.h:165