/[svn]/qsampler/trunk/src/qsamplerChannelStrip.ui.h
ViewVC logotype

Annotation of /qsampler/trunk/src/qsamplerChannelStrip.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 388 - (hide annotations) (download) (as text)
Thu Feb 17 17:27:59 2005 UTC (19 years, 2 months ago) by capela
File MIME type: text/x-c++hdr
File size: 8969 byte(s)
* Drag-and-drop of either session files (LSCP scripts) or
  instrument files (GIG) are now supported. Multiple files
  drop is allowed, but it only makes sense for instrument
  files, each one prompting to create a new sampler channel.

1 capela 109 // qsamplerChannelStrip.ui.h
2     //
3     // ui.h extension file, included from the uic-generated form implementation.
4     /****************************************************************************
5 capela 341 Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
6 capela 109
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20    
21     *****************************************************************************/
22    
23     #include <qvalidator.h>
24     #include <qmessagebox.h>
25     #include <qfileinfo.h>
26     #include <qtooltip.h>
27 capela 118 #include <qpopupmenu.h>
28 capela 267 #include <qobjectlist.h>
29 capela 109
30     #include <math.h>
31    
32     #include "qsamplerMainForm.h"
33     #include "qsamplerChannelForm.h"
34    
35     #include "config.h"
36    
37    
38     // Kind of constructor.
39     void qsamplerChannelStrip::init (void)
40     {
41     // Initialize locals.
42 capela 264 m_pChannel = NULL;
43 capela 109 m_iDirtyChange = 0;
44    
45     // Try to restore normal window positioning.
46     adjustSize();
47     }
48    
49    
50     // Kind of destructor.
51     void qsamplerChannelStrip::destroy (void)
52     {
53 capela 264 // Destroy existing channel descriptor.
54     if (m_pChannel)
55     delete m_pChannel;
56     m_pChannel = NULL;
57 capela 109 }
58    
59    
60     // Channel strip setup formal initializer.
61 capela 303 void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
62 capela 109 {
63 capela 303 // Destroy any previous channel descriptor;
64     // (remember that once setup we own it!)
65 capela 264 if (m_pChannel)
66     delete m_pChannel;
67 capela 109
68 capela 303 // Set the new one...
69     m_pChannel = pChannel;
70 capela 302
71 capela 265 // Stabilize this around.
72     updateChannelInfo();
73 capela 109 }
74    
75 capela 264 // Channel secriptor accessor.
76     qsamplerChannel *qsamplerChannelStrip::channel (void)
77 capela 109 {
78 capela 264 return m_pChannel;
79 capela 109 }
80    
81    
82     // Messages view font accessors.
83     QFont qsamplerChannelStrip::displayFont (void)
84     {
85     return EngineNameTextLabel->font();
86     }
87    
88     void qsamplerChannelStrip::setDisplayFont ( const QFont & font )
89     {
90     EngineNameTextLabel->setFont(font);
91 capela 145 MidiPortChannelTextLabel->setFont(font);
92 capela 109 InstrumentNameTextLabel->setFont(font);
93 capela 145 InstrumentStatusTextLabel->setFont(font);
94 capela 109 }
95    
96 capela 263
97 capela 267 // Channel display background effect.
98     void qsamplerChannelStrip::setDisplayEffect ( bool bDisplayEffect )
99     {
100     QPixmap pm;
101     if (bDisplayEffect)
102     pm = QPixmap::fromMimeSource("displaybg1.png");
103     setDisplayBackground(pm);
104     }
105    
106    
107     // Update main display background pixmap.
108     void qsamplerChannelStrip::setDisplayBackground ( const QPixmap& pm )
109     {
110     // Set the main origin...
111     ChannelInfoFrame->setPaletteBackgroundPixmap(pm);
112    
113     // Iterate for every child text label...
114     QObjectList *pList = ChannelInfoFrame->queryList("QLabel");
115     if (pList) {
116     for (QLabel *pLabel = (QLabel *) pList->first(); pLabel; pLabel = (QLabel *) pList->next())
117     pLabel->setPaletteBackgroundPixmap(pm);
118     delete pList;
119     }
120    
121     // And this standalone too.
122     StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);
123     }
124    
125    
126 capela 263 // Channel setup dialog slot.
127 capela 295 bool qsamplerChannelStrip::channelSetup (void)
128 capela 263 {
129 capela 303 bool bResult = m_pChannel->channelSetup(this);
130 capela 263
131 capela 296 if (bResult)
132 capela 295 emit channelChanged(this);
133    
134     return bResult;
135 capela 109 }
136    
137    
138 capela 371 // Update the channel instrument name.
139     bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )
140     {
141     if (m_pChannel == NULL)
142     return false;
143    
144     // Do we refersh the actual name?
145     if (bForce)
146     m_pChannel->updateInstrumentName();
147    
148     // Instrument name...
149     if (m_pChannel->instrumentName().isEmpty())
150 capela 388 InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());
151 capela 371 else
152     InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());
153    
154     return true;
155     }
156    
157    
158 capela 109 // Update whole channel info state.
159 capela 297 bool qsamplerChannelStrip::updateChannelInfo (void)
160 capela 109 {
161 capela 264 if (m_pChannel == NULL)
162 capela 297 return false;
163 capela 264
164 capela 109 // Update strip caption.
165 capela 295 QString sText = m_pChannel->channelName();
166 capela 109 setCaption(sText);
167     ChannelSetupPushButton->setText(sText);
168    
169     // Check if we're up and connected.
170 capela 264 if (m_pChannel->client() == NULL)
171 capela 297 return false;
172 capela 109
173 capela 264 // Read actual channel information.
174     m_pChannel->updateChannelInfo();
175 capela 109
176     // Engine name...
177 capela 264 if (m_pChannel->engineName().isEmpty())
178 capela 388 EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());
179 capela 109 else
180 capela 371 EngineNameTextLabel->setText(' ' + m_pChannel->engineName());
181 capela 109
182 capela 371 // Instrument name...
183     updateInstrumentName(false);
184 capela 109
185 capela 145 // Instrument status...
186 capela 264 int iInstrumentStatus = m_pChannel->instrumentStatus();
187     if (iInstrumentStatus < 0) {
188 capela 145 InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
189 capela 264 InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
190 capela 145 } else {
191 capela 264 InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
192     InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");
193 capela 145 }
194    
195 capela 109 // MIDI Port/Channel...
196 capela 280 if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
197     MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
198 capela 261 else
199 capela 280 MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));
200 capela 261
201 capela 109 // And update the both GUI volume elements.
202 capela 297 return updateChannelVolume();
203 capela 109 }
204    
205    
206     // Do the dirty volume change.
207 capela 297 bool qsamplerChannelStrip::updateChannelVolume (void)
208 capela 109 {
209 capela 264 if (m_pChannel == NULL)
210 capela 297 return false;
211 capela 264
212 capela 109 // Convert...
213     #ifdef CONFIG_ROUND
214 capela 264 int iVolume = (int) ::round(100.0 * m_pChannel->volume());
215 capela 109 #else
216     double fIPart = 0.0;
217 capela 264 double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);
218 capela 109 int iVolume = (int) fIPart;
219     if (fFPart >= +0.5)
220     iVolume++;
221     else
222     if (fFPart <= -0.5)
223     iVolume--;
224     #endif
225    
226     // And clip...
227 capela 119 if (iVolume < 0)
228 capela 109 iVolume = 0;
229    
230     // Flag it here, to avoid infinite recursion.
231     m_iDirtyChange++;
232     VolumeSlider->setValue(iVolume);
233     VolumeSpinBox->setValue(iVolume);
234     m_iDirtyChange--;
235 capela 297
236     return true;
237 capela 109 }
238    
239    
240     // Update whole channel usage state.
241 capela 297 bool qsamplerChannelStrip::updateChannelUsage (void)
242 capela 109 {
243 capela 264 if (m_pChannel == NULL)
244 capela 297 return false;
245 capela 264 if (m_pChannel->client() == NULL)
246 capela 297 return false;
247 capela 109
248 capela 302 // Update whole channel status info,
249     // if instrument load is still pending...
250     if (m_pChannel->instrumentStatus() < 100) {
251 capela 145 updateChannelInfo();
252 capela 302 // Check (updated) status again...
253     if (m_pChannel->instrumentStatus() < 100)
254     return false;
255     // Once we get a complete instrument load,
256     // we'll try an implied channel reset...
257     m_pChannel->resetChannel();
258 capela 176 }
259 capela 302
260     // Check again that we're clean.
261 capela 264 if (m_pChannel->instrumentStatus() < 100)
262 capela 297 return false;
263 capela 145
264 capela 109 // Get current channel voice count.
265 capela 264 int iVoiceCount = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
266 capela 109 // Get current stream count.
267 capela 264 int iStreamCount = ::lscp_get_channel_stream_count(m_pChannel->client(), m_pChannel->channelID());
268 capela 109 // Get current channel buffer fill usage.
269     // As benno has suggested this is the percentage usage
270     // of the least filled buffer stream...
271 capela 264 int iStreamUsage = ::lscp_get_channel_stream_usage(m_pChannel->client(), m_pChannel->channelID());;
272 capela 176
273 capela 109 // Update the GUI elements...
274     StreamUsageProgressBar->setProgress(iStreamUsage);
275     StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
276 capela 297
277     // We're clean.
278     return true;
279 capela 109 }
280    
281    
282     // Volume change slot.
283     void qsamplerChannelStrip::volumeChanged ( int iVolume )
284     {
285 capela 264 if (m_pChannel == NULL)
286     return;
287    
288 capela 109 // Avoid recursion.
289     if (m_iDirtyChange > 0)
290     return;
291    
292     // Convert and clip.
293     float fVolume = (float) iVolume / 100.0;
294 capela 119 if (fVolume < 0.001)
295 capela 109 fVolume = 0.0;
296    
297     // Update the GUI elements.
298 capela 264 if (m_pChannel->setVolume(fVolume)) {
299 capela 109 updateChannelVolume();
300     emit channelChanged(this);
301     }
302     }
303    
304    
305 capela 118 // Context menu event handler.
306     void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
307     {
308 capela 303 if (m_pChannel == NULL)
309 capela 264 return;
310    
311 capela 303 // We'll just show up the main form's edit menu (thru qsamplerChannel).
312     m_pChannel->contextMenuEvent(pEvent);
313 capela 118 }
314    
315    
316 capela 119 // Maximum volume slider accessors.
317     void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
318     {
319     m_iDirtyChange++;
320     VolumeSlider->setRange(0, iMaxVolume);
321     VolumeSpinBox->setRange(0, iMaxVolume);
322     m_iDirtyChange--;
323     }
324    
325    
326 capela 109 // end of qsamplerChannelStrip.ui.h

  ViewVC Help
Powered by ViewVC