Guitarix
gx_jconv_settings.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #pragma once
21 
22 #ifndef SRC_HEADERS_GX_JCONV_SETTINGS_H_
23 #define SRC_HEADERS_GX_JCONV_SETTINGS_H_
24 
25 #include <gxwmm/gainline.h>
26 #include <gxwmm/radiobutton.h>
27 #include <gxwmm/iredit.h>
28 
29 #include <string>
30 
31 namespace gx_jconv {
32 
33 /****************************************************************
34  ** Convolver Parameter Window
35  */
36 
37 class IRWindow: public sigc::trackable {
38  private:
39  gx_engine::GxMachineBase& machine;
40  Glib::RefPtr<gx_gui::GxBuilder> builder;
41  Glib::ustring filename;
42  double ms; // samples per millisecond
43  float *audio_buffer;
44  unsigned int audio_size;
45  int audio_chan;
47  Gtk::Window* gtk_window;
48  sigc::connection autogain_conn;
49  int nchan;
50 
51  // helper functions
52  int set_val(Gxw::ControlParameter *sample_display, Gxw::ControlParameter *ms_display,
53  double value, int fs);
54  inline int get_ms(Gxw::ControlParameter *w) {
55  return static_cast<int>(round(w->cp_get_value()*ms));
56  }
57  void file_changed(Glib::ustring filename, int rate, int length,
58  int channels, Glib::ustring format);
59  static Gainline gain0;
60  bool load_data(Glib::ustring filename, int offset = 0, int delay = 0, int length = 0, const Gainline& gain = gain0);
61  void load_state(const gx_engine::GxJConvSettings* jcp);
62  void make_state(gx_engine::GxJConvSettings& jc);
63  void save_state();
64  void set_GainCor();
65  double calc_normalized_gain(int offset, int length, const Gainline& points);
66  void destroy_self();
67 
68  // signal functions and widget pointers
69  void on_window_hide();
70 
71  Gxw::IREdit *wIredit;
72  void on_delay_changed(int delay, int fs);
73  void on_offset_changed(int offset, int fs);
74  void on_length_changed(int length, int fs);
75  void on_max_scale_reached(bool v);
76  void on_min_scale_reached(bool v);
77 
78  Gxw::RadioButton *wLeft, *wRight, *wSum;
79  void on_left();
80  void on_right();
81  void on_sum();
82 
83  Gxw::RadioButton *wLinear, *wLog;
84  void on_linear();
85 
86  Gxw::ValueDisplay *wDelay, *wDelay_ms, *wOffset, *wOffset_ms, *wLength, *wLength_ms;
87  void on_m_delay_changed();
88  void on_ms_delay_changed();
89  void on_m_offset_changed();
90  void on_ms_offset_changed();
91  void on_m_length_changed();
92  void on_ms_length_changed();
93 
94  Gxw::Regler *wDelay_delta;
95  Glib::ustring on_delay_delta_format_value(double v);
96 
97  Gtk::Button *wHome, *wJump_zoom_mark, *wIncr, *wDecr;
98  void on_home();
99  void on_jump_zoom_mark();
100  void on_decr();
101  void on_incr();
102 
103  Gtk::Button *wReset, *wOpen;
104  void on_reset_clicked();
105  void on_open();
106 
107  Gtk::Button *wOk, *wApply, *wCancel;
108  void on_apply_button_clicked();
109  void on_cancel_button_clicked();
110  void on_ok_button_clicked();
111 
112  Gtk::ToggleButton *wGain_correction;
113  void on_gain_button_toggled();
114 
115  Gtk::Label *wSamples, *wSampleRate, *wFormat, *wChan, *wFilename;
116  Gtk::Widget *wChannelbox;
117 
118  void on_help_clicked();
119  Gtk::Window *wHelp;
120 
121  void on_preset_popup_clicked();
122  void reload_impresp_list();
123  void on_enumerate(const std::string& path, const std::vector<gx_system::FileName>& l);
124  bool on_key_press_event(GdkEventKey *event);
125 
126  void init_connect();
127  IRWindow(const Glib::RefPtr<gx_gui::GxBuilder>& builder, gx_engine::JConvParameter *jcp,
128  Glib::RefPtr<Gdk::Pixbuf> icon, gx_engine::GxMachineBase& machine,
129  Glib::RefPtr<Gtk::AccelGroup> accels, int nchan);
130  ~IRWindow();
131 
132  class ModelColumns : public Gtk::TreeModel::ColumnRecord {
133  public:
134  ModelColumns() { add(displayname); add(filename); }
135  Gtk::TreeModelColumn<Glib::ustring> displayname;
136  Gtk::TreeModelColumn<std::string> filename;
137  };
138  Gtk::ComboBox *wcombo;
139  ModelColumns columns;
140  Glib::RefPtr<Gtk::TreeStore> model;
141  std::string current_combo_dir;
142  void on_combo_changed();
143  void on_dircombo_changed();
144  Gtk::ComboBox *dircombo;
145 public:
146  void reload_and_show();
147  static IRWindow *create(const std::string& unit_id,
148  Glib::RefPtr<Gdk::Pixbuf> icon, gx_engine::GxMachineBase& machine,
149  Glib::RefPtr<Gtk::AccelGroup> accels, int nchan);
150  friend class JConvPopup;
151 };
152 
153 } /* end of gx_jconv namespace*/
154 #endif // SRC_HEADERS_GX_JCONV_SETTINGS_H_
gx_jconv::IRWindow
Definition: gx_jconv_settings.h:37
gx_jconv::IRWindow::create
static IRWindow * create(const std::string &unit_id, Glib::RefPtr< Gdk::Pixbuf > icon, gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::AccelGroup > accels, int nchan)
Definition: gx_jconv_settings.cpp:33
Gxw::IREdit
Definition: iredit.h:44
gx_engine::GxMachineBase
Definition: machine.h:53
Gxw::RadioButton
Definition: radiobutton.h:42
gx_engine::ParameterV< GxJConvSettings >
Definition: gx_internal_plugins.h:351
gx_jconv::IRWindow::reload_and_show
void reload_and_show()
Definition: gx_jconv_settings.cpp:686
Gxw::ControlParameter
Definition: controlparameter.h:48
Gxw::ValueDisplay
Definition: valuedisplay.h:43
gx_jconv
Definition: gx_jconv_settings.h:31
Gxw::ControlParameter::cp_get_value
double cp_get_value()
Definition: controlparameter.cc:136
gx_jconv::IRWindow::JConvPopup
friend class JConvPopup
Definition: gx_jconv_settings.h:152
Gxw::Regler
Definition: regler.h:45
gx_engine::GxJConvSettings
Definition: gx_internal_plugins.h:304