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:
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;
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);
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();
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();
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;
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 
119  Gtk::Window *wHelp;
120 
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 
131  class ModelColumns : public Gtk::TreeModel::ColumnRecord {
132  public:
134  Gtk::TreeModelColumn<Glib::ustring> displayname;
135  Gtk::TreeModelColumn<std::string> filename;
136  };
137  Gtk::ComboBox *wcombo;
139  Glib::RefPtr<Gtk::TreeStore> model;
140  std::string current_combo_dir;
143  Gtk::ComboBox *dircombo;
144 public:
146  static IRWindow *create(const std::string& unit_id,
147  Glib::RefPtr<Gdk::Pixbuf> icon, gx_engine::GxMachineBase& machine,
148  Glib::RefPtr<Gtk::AccelGroup> accels, int nchan);
149  ~IRWindow();
150 };
151 
152 } /* end of gx_jconv namespace*/
153 #endif // SRC_HEADERS_GX_JCONV_SETTINGS_H_
gx_jconv::IRWindow
Definition: gx_jconv_settings.h:37
gx_jconv::IRWindow::audio_buffer
float * audio_buffer
Definition: gx_jconv_settings.h:45
gx_jconv::IRWindow::on_open
void on_open()
gx_jconv::IRWindow::gtk_window
Gtk::Window * gtk_window
Definition: gx_jconv_settings.h:49
gx_jconv::IRWindow::wApply
Gtk::Button * wApply
Definition: gx_jconv_settings.h:109
gx_jconv::IRWindow::on_m_offset_changed
void on_m_offset_changed()
gx_jconv::IRWindow::on_ok_button_clicked
void on_ok_button_clicked()
gx_jconv::IRWindow::ModelColumns::ModelColumns
ModelColumns()
Definition: gx_jconv_settings.h:135
gx_jconv::IRWindow::current_combo_dir
std::string current_combo_dir
Definition: gx_jconv_settings.h:142
gx_jconv::IRWindow::IRWindow
IRWindow(const Glib::RefPtr< gx_gui::GxBuilder > &builder, gx_engine::JConvParameter *jcp, Glib::RefPtr< Gdk::Pixbuf > icon, gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::AccelGroup > accels, int nchan)
gx_jconv::IRWindow::on_dircombo_changed
void on_dircombo_changed()
gx_engine::GxMachineBase
Definition: machine.h:55
gx_jconv::IRWindow::wSamples
Gtk::Label * wSamples
Definition: gx_jconv_settings.h:117
gx_jconv::IRWindow::wChan
Gtk::Label * wChan
Definition: gx_jconv_settings.h:117
gx_jconv::IRWindow::ModelColumns::filename
Gtk::TreeModelColumn< std::string > filename
Definition: gx_jconv_settings.h:137
gx_jconv::IRWindow::nchan
int nchan
Definition: gx_jconv_settings.h:51
gx_jconv::IRWindow::dircombo
Gtk::ComboBox * dircombo
Definition: gx_jconv_settings.h:145
gx_jconv::IRWindow::wDecr
Gtk::Button * wDecr
Definition: gx_jconv_settings.h:99
gx_jconv::IRWindow::gain0
static Gainline gain0
Definition: gx_jconv_settings.h:61
gx_jconv::IRWindow::wOffset
Gxw::ValueDisplay * wOffset
Definition: gx_jconv_settings.h:88
gx_engine::ParameterV< GxJConvSettings >
Definition: gx_internal_plugins.h:305
gx_jconv::IRWindow::set_val
int set_val(Gxw::ControlParameter *sample_display, Gxw::ControlParameter *ms_display, double value, int fs)
gx_jconv::IRWindow::on_preset_popup_clicked
void on_preset_popup_clicked()
gx_jconv::IRWindow::on_sum
void on_sum()
gx_jconv::IRWindow::model
Glib::RefPtr< Gtk::TreeStore > model
Definition: gx_jconv_settings.h:141
gx_jconv::IRWindow::wIredit
Gxw::IREdit * wIredit
Definition: gx_jconv_settings.h:73
gx_jconv::IRWindow::on_length_changed
void on_length_changed(int length, int fs)
gx_jconv::IRWindow::on_linear
void on_linear()
gx_jconv::IRWindow::reload_impresp_list
void reload_impresp_list()
gx_jconv::IRWindow::jcp
gx_engine::JConvParameter * jcp
Definition: gx_jconv_settings.h:48
gx_jconv::IRWindow::columns
ModelColumns columns
Definition: gx_jconv_settings.h:140
gx_jconv::IRWindow::autogain_conn
sigc::connection autogain_conn
Definition: gx_jconv_settings.h:50
gx_jconv::IRWindow::wOffset_ms
Gxw::ValueDisplay * wOffset_ms
Definition: gx_jconv_settings.h:88
gx_jconv::IRWindow::save_state
void save_state()
gx_jconv::IRWindow::reload_and_show
void reload_and_show()
gx_jconv::IRWindow::wLog
Gxw::RadioButton * wLog
Definition: gx_jconv_settings.h:85
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)
gx_jconv::IRWindow::on_delay_changed
void on_delay_changed(int delay, int fs)
gx_jconv::IRWindow::make_state
void make_state(gx_engine::GxJConvSettings &jc)
gx_jconv::IRWindow::on_ms_offset_changed
void on_ms_offset_changed()
gx_jconv::IRWindow::wReset
Gtk::Button * wReset
Definition: gx_jconv_settings.h:105
gx_jconv::IRWindow::wFormat
Gtk::Label * wFormat
Definition: gx_jconv_settings.h:117
gx_jconv::IRWindow::wLength
Gxw::ValueDisplay * wLength
Definition: gx_jconv_settings.h:88
gx_jconv::IRWindow::on_combo_changed
void on_combo_changed()
gx_jconv::IRWindow::wHelp
Gtk::Window * wHelp
Definition: gx_jconv_settings.h:121
gx_jconv::IRWindow::wcombo
Gtk::ComboBox * wcombo
Definition: gx_jconv_settings.h:139
gx_jconv::IRWindow::calc_normalized_gain
double calc_normalized_gain(int offset, int length, const Gainline &points)
gx_jconv::IRWindow::on_right
void on_right()
gx_jconv::IRWindow::on_key_press_event
bool on_key_press_event(GdkEventKey *event)
gx_jconv::IRWindow::wDelay_delta
Gxw::Regler * wDelay_delta
Definition: gx_jconv_settings.h:96
gx_jconv::IRWindow::on_ms_delay_changed
void on_ms_delay_changed()
gx_jconv::IRWindow::load_state
void load_state(const gx_engine::GxJConvSettings *jcp)
gx_jconv::IRWindow::on_min_scale_reached
void on_min_scale_reached(bool v)
gx_jconv::IRWindow::on_left
void on_left()
gx_jconv::IRWindow::wGain_correction
Gtk::ToggleButton * wGain_correction
Definition: gx_jconv_settings.h:114
gx_jconv::IRWindow::ModelColumns
Definition: gx_jconv_settings.h:133
gx_jconv::IRWindow::on_window_hide
void on_window_hide()
gx_jconv::IRWindow::wLinear
Gxw::RadioButton * wLinear
Definition: gx_jconv_settings.h:85
gx_jconv::IRWindow::on_help_clicked
void on_help_clicked()
gx_jconv::IRWindow::wDelay
Gxw::ValueDisplay * wDelay
Definition: gx_jconv_settings.h:88
gx_jconv::IRWindow::wDelay_ms
Gxw::ValueDisplay * wDelay_ms
Definition: gx_jconv_settings.h:88
gx_jconv::IRWindow::wChannelbox
Gtk::Widget * wChannelbox
Definition: gx_jconv_settings.h:118
gx_jconv::IRWindow::on_jump_zoom_mark
void on_jump_zoom_mark()
gx_jconv::IRWindow::wCancel
Gtk::Button * wCancel
Definition: gx_jconv_settings.h:109
gx_jconv::IRWindow::file_changed
void file_changed(Glib::ustring filename, int rate, int length, int channels, Glib::ustring format)
gx_jconv::IRWindow::on_cancel_button_clicked
void on_cancel_button_clicked()
gx_jconv::IRWindow::get_ms
int get_ms(Gxw::ControlParameter *w)
Definition: gx_jconv_settings.h:56
gx_jconv::IRWindow::on_home
void on_home()
gx_jconv::IRWindow::wLength_ms
Gxw::ValueDisplay * wLength_ms
Definition: gx_jconv_settings.h:88
gx_jconv
Definition: gx_jconv_settings.h:31
gx_jconv::IRWindow::on_ms_length_changed
void on_ms_length_changed()
gx_jconv::IRWindow::init_connect
void init_connect()
gx_jconv::IRWindow::wOk
Gtk::Button * wOk
Definition: gx_jconv_settings.h:109
gx_jconv::IRWindow::wSampleRate
Gtk::Label * wSampleRate
Definition: gx_jconv_settings.h:117
gx_jconv::IRWindow::on_gain_button_toggled
void on_gain_button_toggled()
gx_jconv::IRWindow::wIncr
Gtk::Button * wIncr
Definition: gx_jconv_settings.h:99
gx_jconv::IRWindow::wLeft
Gxw::RadioButton * wLeft
Definition: gx_jconv_settings.h:80
gx_jconv::IRWindow::wRight
Gxw::RadioButton * wRight
Definition: gx_jconv_settings.h:80
gx_jconv::IRWindow::on_m_delay_changed
void on_m_delay_changed()
gx_jconv::IRWindow::on_reset_clicked
void on_reset_clicked()
gx_jconv::IRWindow::filename
Glib::ustring filename
Definition: gx_jconv_settings.h:43
gx_jconv::IRWindow::ModelColumns::displayname
Gtk::TreeModelColumn< Glib::ustring > displayname
Definition: gx_jconv_settings.h:136
gx_jconv::IRWindow::on_decr
void on_decr()
gx_jconv::IRWindow::on_offset_changed
void on_offset_changed(int offset, int fs)
gx_jconv::IRWindow::wSum
Gxw::RadioButton * wSum
Definition: gx_jconv_settings.h:80
gx_jconv::IRWindow::on_m_length_changed
void on_m_length_changed()
gx_jconv::IRWindow::machine
gx_engine::GxMachineBase & machine
Definition: gx_jconv_settings.h:41
gx_jconv::IRWindow::audio_size
unsigned int audio_size
Definition: gx_jconv_settings.h:46
gx_jconv::IRWindow::wHome
Gtk::Button * wHome
Definition: gx_jconv_settings.h:99
gx_engine::GxJConvSettings
Definition: gx_internal_plugins.h:258
gx_jconv::IRWindow::wOpen
Gtk::Button * wOpen
Definition: gx_jconv_settings.h:105
gx_jconv::IRWindow::builder
Glib::RefPtr< gx_gui::GxBuilder > builder
Definition: gx_jconv_settings.h:42
gx_jconv::IRWindow::~IRWindow
~IRWindow()
gx_jconv::IRWindow::wJump_zoom_mark
Gtk::Button * wJump_zoom_mark
Definition: gx_jconv_settings.h:99
gx_jconv::IRWindow::destroy_self
void destroy_self()
gx_jconv::IRWindow::on_delay_delta_format_value
Glib::ustring on_delay_delta_format_value(double v)
gx_jconv::IRWindow::on_enumerate
void on_enumerate(const std::string &path, const std::vector< gx_system::FileName > &l)
gx_jconv::IRWindow::wFilename
Gtk::Label * wFilename
Definition: gx_jconv_settings.h:117
gx_jconv::IRWindow::ms
double ms
Definition: gx_jconv_settings.h:44
gx_jconv::IRWindow::on_incr
void on_incr()
gx_jconv::IRWindow::on_apply_button_clicked
void on_apply_button_clicked()
gx_jconv::IRWindow::audio_chan
int audio_chan
Definition: gx_jconv_settings.h:47
gx_jconv::IRWindow::on_max_scale_reached
void on_max_scale_reached(bool v)
gx_jconv::IRWindow::set_GainCor
void set_GainCor()
gx_jconv::IRWindow::load_data
bool load_data(Glib::ustring filename, int offset=0, int delay=0, int length=0, const Gainline &gain=gain0)