~ubuntu-branches/debian/jessie/eq10q/jessie

« back to all changes in this revision

Viewing changes to band_ctl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jaromír Mikeš
  • Date: 2011-01-14 01:27:59 UTC
  • Revision ID: james.westby@ubuntu.com-20110114012759-h9infyqh7810qtza
Tags: upstream-1.1
Import upstream version 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2009 by Pere Ràfols Soler                               *
 
3
 *   sapista2@gmail.com                                                    *
 
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                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "band_ctl.h"
 
22
 
 
23
BandCtl::BandCtl(){
 
24
  //constructor buit
 
25
}
 
26
 
 
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
 
32
   ):
 
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){
 
35
  Glib::ustring text;
 
36
  
 
37
  f=freq;
 
38
  ant_filter = FILTER_OFF;
 
39
 
 
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));
 
43
  
 
44
 
 
45
  text = Glib::ustring::compose("Band %1", band_num);
 
46
  band_label.set_label(text);
 
47
 
 
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 );
 
54
 
 
55
  m_on_button.set_size_request(35,-1);
 
56
  button_align.add(m_on_button);
 
57
  
 
58
  set_spacing(2);
 
59
  set_homogeneous(false);
 
60
  set_size_request(80,-1);
 
61
 
 
62
  m_filter_sel.set_size_request(60,-1);
 
63
  combo_align.add(m_filter_sel);
 
64
  
 
65
  band_label.show();
 
66
  m_on_button.show();
 
67
  m_filter_sel.show();
 
68
  m_gain->show();
 
69
  m_freq->show();
 
70
  m_Q->show();
 
71
  button_align.show();
 
72
  show();
 
73
 
 
74
  m_on_button.set_label("ON");
 
75
  m_on_button.signal_clicked().connect(sigc::mem_fun(*this, &BandCtl::on_button_clicked));
 
76
 
 
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
 
90
  */
 
91
 
 
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
 
94
  //config_sensitive();
 
95
 
 
96
  vic_de_set=false;
 
97
 
 
98
  //connexions externes
 
99
  m_filter_sel.signal_changed().connect(type_slot);
 
100
  m_on_button.signal_clicked().connect(type_slot);
 
101
 
 
102
  
 
103
}
 
104
 
 
105
//Funcions de consulta de parametres
 
106
float BandCtl::get_gain(){
 
107
  return m_gain->get_value();
 
108
}
 
109
 
 
110
float BandCtl::get_freq(){
 
111
  return m_freq->get_value();
 
112
}
 
113
 
 
114
float BandCtl::get_Q(){
 
115
  return m_Q->get_value();
 
116
}
 
117
 
 
118
float BandCtl::get_filter_type(){
 
119
  return (float)filter_type;
 
120
}
 
121
 
 
122
 
 
123
//Funcions de salvar parametres
 
124
void BandCtl::set_gain(float g){
 
125
  m_gain->set_value(g);
 
126
}
 
127
 
 
128
void BandCtl::set_freq(float f){
 
129
  m_freq->set_freq_ptr(f);
 
130
}
 
131
 
 
132
void BandCtl::set_freq_direct(float f){
 
133
  m_freq->set_value(f);
 
134
}
 
135
 
 
136
void BandCtl::set_Q(float q){
 
137
  m_Q->set_value(q);
 
138
}
 
139
 
 
140
void BandCtl::set_filter_type(float t){
 
141
  filter_type = (int)t;
 
142
  vic_de_set=true;
 
143
 
 
144
  if( filter_type == 0)m_on_button.set_active(false);
 
145
  else{
 
146
    m_on_button.set_active(true);
 
147
    }
 
148
 
 
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);
 
151
  vic_de_set=false;
 
152
  config_sensitive();
 
153
 
 
154
}
 
155
 
 
156
void BandCtl::on_button_clicked(){
 
157
  config_type();
 
158
 
 
159
  if(m_on_button.get_active() && ant_filter != FILTER_OFF){
 
160
    m_filter_sel.set_active(ant_filter);
 
161
  }
 
162
}
 
163
 
 
164
void BandCtl::on_combo_changed(){
 
165
config_type();
 
166
}
 
167
 
 
168
void BandCtl::config_type(){
 
169
  if(filter_type != FILTER_OFF) ant_filter = filter_type;
 
170
 
 
171
  if(m_on_button.get_active()) {
 
172
    if(!vic_de_set)filter_type=m_filter_sel.get_active_row_number();
 
173
   }
 
174
  else filter_type=0;
 
175
 
 
176
  config_sensitive();
 
177
}
 
178
 
 
179
void BandCtl::config_sensitive(){
 
180
  switch(filter_type){
 
181
    case FILTER_OFF:
 
182
       m_Q->set_sensitive(false);
 
183
       m_gain->set_sensitive(false);
 
184
       m_freq->set_sensitive(false);
 
185
    break;
 
186
    
 
187
    case LPF_ORDER_1:
 
188
    case HPF_ORDER_1:
 
189
      m_Q->set_sensitive(false);
 
190
      m_gain->set_sensitive(false);
 
191
      m_freq->set_sensitive(true);
 
192
 
 
193
      set_gain(0.0);
 
194
    break;
 
195
    
 
196
    case LPF_ORDER_2:
 
197
    case LPF_ORDER_3:
 
198
    case LPF_ORDER_4:
 
199
    case HPF_ORDER_2:
 
200
    case HPF_ORDER_3:
 
201
    case HPF_ORDER_4:
 
202
      reset_Q(HPF_LPF_Q_DEFAULT);
 
203
      goto hpf_lpf;
 
204
    case NOTCH:
 
205
      reset_Q(NOTCH_Q_DEFAULT);
 
206
 
 
207
hpf_lpf:
 
208
      m_gain->set_sensitive(false);
 
209
      m_Q->set_sensitive(true);
 
210
      m_freq->set_sensitive(true);
 
211
      set_gain(0.0);
 
212
    break;
 
213
 
 
214
    case LOW_SHELF:
 
215
    case HIGH_SHELF:
 
216
      reset_Q(HIGH_LOW_SHELF_Q_DEFAULT);
 
217
      goto shelvings;
 
218
    case PEAK:
 
219
     reset_Q(PEAK_Q_DEFAULT);
 
220
shelvings:
 
221
      m_gain->set_sensitive(true);
 
222
      m_Q->set_sensitive(true);
 
223
      m_freq->set_sensitive(true);
 
224
    break;
 
225
   }
 
226
 
 
227
}
 
228
 
 
229
void  BandCtl::reset_Q(float q){
 
230
  if(filter_type != ant_filter){
 
231
    set_Q(q);
 
232
  }
 
233
}
 
234
 
 
235
void BandCtl::hide_spins(){
 
236
  m_gain->hide_spin();
 
237
  m_freq->hide_spin();
 
238
  m_Q->hide_spin();
 
239
}
 
240
 
 
241
BandCtl::~BandCtl(){
 
242
 
 
243
}
 
244
 
 
245
///////////////////////////////////////////////////////
 
246
 
 
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);
 
255
 
 
256
  
 
257
  gain_label.set_label(title);
 
258
  
 
259
  pack_start(gain_label);
 
260
  pack_start(gain_scale);
 
261
  
 
262
  set_spacing(2);
 
263
  set_homogeneous(false);
 
264
  
 
265
  gain_scale.set_size_request(40,100); 
 
266
 
 
267
  gain_label.show();
 
268
  gain_scale.show();
 
269
  show();
 
270
}
 
271
 
 
272
void GainCtl::set_gain(float g){
 
273
  gain_scale.set_value((double) g);
 
274
}
 
275
 
 
276
float GainCtl::get_gain(){
 
277
  return (float)gain_scale.get_value();
 
278
}
 
279
 
 
280
GainCtl::~GainCtl(){
 
281
 
 
282
}
 
283