File: linepanel.ui.h

package info (click to toggle)
djplay 0.5.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,432 kB
  • ctags: 1,388
  • sloc: cpp: 13,382; sh: 7,454; makefile: 810; sed: 16
file content (217 lines) | stat: -rw-r--r-- 4,581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/

#include "config.h"
#include "linepanel-background.xpm"
#include "plugins/bitmapbutton/bitmapbutton.h"
#include "plugins/bitmapslider/bitmapslider.h" 

void LinePanel::init()
{
    background=new QPixmap((const char **)linepanel_background_xpm);
    eq=0;
    pfl_mix=0;
    mic_mix=0;
    processor=0;
    Gain->setValue(30);
}

void LinePanel::destroy()
{
    client->removeProcessor(processor);
    delete in_left;
    delete in_right;
    delete out_left;
    delete out_right;
#ifdef HAVE_LADSPA
    if(eq)
    {
	processor->removeEffect(eq);
	delete eq;
    }
#endif
    if(pfl_mix)
    {
	processor->removeEffect(pfl_mix);
	delete pfl_mix;
    }
    if(main_mix)
    {
	processor->removeEffect(main_mix);
	delete main_mix;
    }
    if(mic_mix)
    {
	processor->removePostFaderEffect(mic_mix);
	delete mic_mix;
    }
    delete processor;
    delete background;
}

void LinePanel::setInfo(Frame *f, Client *c, Port *mix_l, Port *mix_r, int channel_number)
{
    frame=f;
    client=c;
    
    QString title;
    title.sprintf("Line %d", channel_number);
//    Box->setTitle(title);
    
    QString left_name;
    left_name.sprintf("line_in_%d_left", channel_number);
    QString right_name;
    right_name.sprintf("line_in_%d_right", channel_number);
    
    in_left=new Port(client, left_name, -1, Port::Input);
    in_right=new Port(client, right_name, -1, Port::Input);
    
    left_name.sprintf("line_out_%d_left", channel_number);
    right_name.sprintf("line_out_%d_right", channel_number);
    
    out_left=new Port(client, left_name, -1, Port::Output);
    out_right=new Port(client, right_name, -1, Port::Output);
    
    processor=new LineProcessor(in_left, in_right, out_left, out_right);
    
    client->addProcessor(processor);
    
    Gain_valueChanged(Gain->value());
    
    pfl_mix=new MixEffect;
    pfl_mix->left()->setPort(frame->pfl_left);
    pfl_mix->right()->setPort(frame->pfl_right);
    pfl_mix->setControl(0, 0.0);
    processor->addEffect(pfl_mix);
    main_mix=new MixEffect;
    main_mix->left()->setPort(mix_l);
    main_mix->right()->setPort(mix_r);
    main_mix->setControl(2, 0.0);
    processor->addPostFaderEffect(main_mix);
    mic_mix=new MixEffect;
    mic_mix->left()->setPort(0);
    mic_mix->right()->setPort(0);
    processor->addPostFaderEffect(mic_mix);
    
#ifdef HAVE_LADSPA
    eq=new LadspaEffect;
    eq->loadEffect(client->rate(), 1901, "dj_eq");
    if(!eq || eq->ports() == 0)
    {
	if(eq)
		delete eq;
	eq=0;
	Low->hide();
	Mid->hide();
	High->hide();
    }
    else
    {
	processor->addEffect(eq);
	connect(Low, SIGNAL(valueChanged(int)), this, SLOT(lowChanged(int)));
	connect(Mid, SIGNAL(valueChanged(int)), this, SLOT(midChanged(int)));
	connect(High, SIGNAL(valueChanged(int)), this, SLOT(highChanged(int)));
    }
#else
	Low->hide();
	Mid->hide();
	High->hide();
#endif
}



void LinePanel::lowChanged( int val )
{
    portChanged(0, val);
}


void LinePanel::midChanged( int val )
{
    portChanged(1, val);
}


void LinePanel::highChanged( int val )
{
    portChanged(2, val);
}


void LinePanel::portChanged( int port, int val )
{
#ifdef HAVE_LADSPA
    float v;
    if(val <= 0)
	v=(float)val/100.0*70.0;
    else
	v=(float)val/100.0*24.0;
    eq->setControl(port, v);
#endif
}


void LinePanel::Reset_clicked()
{
    if(eq)
    {
	Low->setValue(0);
	Mid->setValue(0);
	High->setValue(0);
    }
}


void LinePanel::Gain_valueChanged( int val )
{
    val=100-val;
    double gain;
    if(val <= 70)
	gain=(double)val/70;
    else
	gain=1.0+(double)(val-70)/20;
    if(processor)
	processor->setGain(gain);
}


void LinePanel::Pfl_toggled( bool on)
{
    if(pfl_mix)
	pfl_mix->setControl(0, on ? 1.0 : 0.0);
}


Effect * LinePanel::effect()
{
    return pfl_mix;
}



void LinePanel::pflCrossfaderValueChanged( int val )
{
    pfl_mix->setControl(2, (100.0-(float)val)/100.0);
    main_mix->setControl(2, (float)val/100.0);
}


void LinePanel::paintEvent( QPaintEvent *e )
{
    bitBlt(this, 0, 0, background);
}


void LinePanel::setMicMixGain( float val )
{
    if(!mic_mix)
	return;
    mic_mix->setControl(0, val);
}