1
/***************************************************************************
2
* Copyright (C) 2009 by Pere Ràfols Soler *
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. *
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. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
27
BandCtl::BandCtl(float *freq, const int band_num,
28
sigc::slot<void> gain_slot,
29
sigc::slot<void> freq_slot,
30
sigc::slot<void> Q_slot,
31
sigc::slot<void> type_slot, int *semafor
33
button_align(Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 0.0, 0.0),
34
combo_align(Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 0.0, 0.0){
38
ant_filter = FILTER_OFF;
40
m_gain = Gtk::manage(new EQButton(GAIN_TYPE, f, gain_slot, semafor));
41
m_freq = Gtk::manage(new EQButton(FREQ_TYPE, f, freq_slot, semafor));
42
m_Q = Gtk::manage(new EQButton(Q_TYPE, f, Q_slot, semafor));
45
text = Glib::ustring::compose("Band %1", band_num);
46
band_label.set_label(text);
48
pack_start(band_label, Gtk::PACK_SHRINK );
49
pack_start(combo_align, Gtk::PACK_EXPAND_PADDING );
50
pack_start(*m_gain, Gtk::PACK_EXPAND_PADDING );
51
pack_start(*m_freq, Gtk::PACK_EXPAND_PADDING );
52
pack_start(*m_Q, Gtk::PACK_EXPAND_PADDING );
53
pack_start(button_align, Gtk::PACK_EXPAND_PADDING );
55
m_on_button.set_size_request(35,-1);
56
button_align.add(m_on_button);
59
set_homogeneous(false);
60
set_size_request(80,-1);
62
m_filter_sel.set_size_request(60,-1);
63
combo_align.add(m_filter_sel);
74
m_on_button.set_label("ON");
75
m_on_button.signal_clicked().connect(sigc::mem_fun(*this, &BandCtl::on_button_clicked));
77
/*m_filter_sel.append_text("None"); //0
78
m_filter_sel.append_text("LPF 1"); //1
79
m_filter_sel.append_text("LPF 2"); //2
80
m_filter_sel.append_text("LPF 3"); //3
81
m_filter_sel.append_text("LPF 4"); //4
82
m_filter_sel.append_text("HPF 1"); //5
83
m_filter_sel.append_text("HPF 2"); //6
84
m_filter_sel.append_text("HPF 3"); //7
85
m_filter_sel.append_text("HPF 4"); //8
86
m_filter_sel.append_text("LoShelv"); //9
87
m_filter_sel.append_text("HiShelv"); //10
88
m_filter_sel.append_text("Peak"); //11
89
m_filter_sel.append_text("Notch"); //12
92
m_filter_sel.signal_changed().connect(sigc::mem_fun(*this, &BandCtl::on_combo_changed));
93
//posa els buttons com hagin d'estar al principi
99
m_filter_sel.signal_changed().connect(type_slot);
100
m_on_button.signal_clicked().connect(type_slot);
105
//Funcions de consulta de parametres
106
float BandCtl::get_gain(){
107
return m_gain->get_value();
110
float BandCtl::get_freq(){
111
return m_freq->get_value();
114
float BandCtl::get_Q(){
115
return m_Q->get_value();
118
float BandCtl::get_filter_type(){
119
return (float)filter_type;
123
//Funcions de salvar parametres
124
void BandCtl::set_gain(float g){
125
m_gain->set_value(g);
128
void BandCtl::set_freq(float f){
129
m_freq->set_freq_ptr(f);
132
void BandCtl::set_freq_direct(float f){
133
m_freq->set_value(f);
136
void BandCtl::set_Q(float q){
140
void BandCtl::set_filter_type(float t){
141
filter_type = (int)t;
144
if( filter_type == 0)m_on_button.set_active(false);
146
m_on_button.set_active(true);
149
//if(m_on_button.get_active())m_filter_sel.set_active(filter_type); //Modificat per evitar k kuan apaguem el butto es perdi la select <<<<<<<
150
m_filter_sel.set_active(filter_type);
156
void BandCtl::on_button_clicked(){
159
if(m_on_button.get_active() && ant_filter != FILTER_OFF){
160
m_filter_sel.set_active(ant_filter);
164
void BandCtl::on_combo_changed(){
168
void BandCtl::config_type(){
169
if(filter_type != FILTER_OFF) ant_filter = filter_type;
171
if(m_on_button.get_active()) {
172
if(!vic_de_set)filter_type=m_filter_sel.get_active_row_number();
179
void BandCtl::config_sensitive(){
182
m_Q->set_sensitive(false);
183
m_gain->set_sensitive(false);
184
m_freq->set_sensitive(false);
189
m_Q->set_sensitive(false);
190
m_gain->set_sensitive(false);
191
m_freq->set_sensitive(true);
202
reset_Q(HPF_LPF_Q_DEFAULT);
205
reset_Q(NOTCH_Q_DEFAULT);
208
m_gain->set_sensitive(false);
209
m_Q->set_sensitive(true);
210
m_freq->set_sensitive(true);
216
reset_Q(HIGH_LOW_SHELF_Q_DEFAULT);
219
reset_Q(PEAK_Q_DEFAULT);
221
m_gain->set_sensitive(true);
222
m_Q->set_sensitive(true);
223
m_freq->set_sensitive(true);
229
void BandCtl::reset_Q(float q){
230
if(filter_type != ant_filter){
235
void BandCtl::hide_spins(){
245
///////////////////////////////////////////////////////
247
GainCtl::GainCtl(const Glib::ustring title, sigc::slot<void> m_slot){
248
gain_scale.set_digits(1);
249
gain_scale.set_draw_value(true);
250
gain_scale.set_value_pos(Gtk::POS_TOP);
251
gain_scale.set_inverted(true);
252
gain_scale.set_range(GAIN_MIN, GAIN_MAX);
253
gain_scale.set_value(GAIN_DEFAULT);
254
gain_scale.signal_value_changed().connect(m_slot);
257
gain_label.set_label(title);
259
pack_start(gain_label);
260
pack_start(gain_scale);
263
set_homogeneous(false);
265
gain_scale.set_size_request(40,100);
272
void GainCtl::set_gain(float g){
273
gain_scale.set_value((double) g);
276
float GainCtl::get_gain(){
277
return (float)gain_scale.get_value();