root/branches/new_fx_rack_and_sample_fun/gui/src/Mixer/MixerLine.cpp @ 1244

Revision 1244, 23.5 KB (checked in by wolke, 4 years ago)

merge 1235:1236 from trunk. the jack zombi stuff from gabriel (: thx :)

Line 
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (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 <stdio.h>
24
25#include <QPainter>
26
27#include "../InstrumentEditor/InstrumentEditor.h"
28#include "../widgets/Fader.h"
29#include "../HydrogenApp.h"
30#include "../Skin.h"
31#include "../widgets/Rotary.h"
32#include "../widgets/Button.h"
33#include "../widgets/LCD.h"
34
35#include <hydrogen/hydrogen.h>
36#include <hydrogen/Preferences.h>
37#include <hydrogen/audio_engine.h>
38using namespace H2Core;
39
40#include "MixerLine.h"
41
42#define MIXERLINE_WIDTH                 56
43#define MIXERLINE_HEIGHT                254
44#define MASTERMIXERLINE_WIDTH   126
45#define MASTERMIXERLINE_HEIGHT  284
46#define MIXERLINE_LABEL_H               115
47#define MASTERMIXERLINE_FADER_H 75
48
49using namespace H2Core;
50
51MixerLine::MixerLine(QWidget* parent)
52 : PixmapWidget( parent, "MixerLine" )
53{
54//      INFOLOG( "INIT" );
55
56        m_nWidth = MIXERLINE_WIDTH;
57        m_nHeight = MIXERLINE_HEIGHT;
58        m_fMaxPeak = 0.0;
59        m_nActivity = 0;
60        m_bIsSelected = false;
61        m_nPeakTimer = 0;
62
63        resize( m_nWidth, m_nHeight );
64        setFixedSize( m_nWidth, m_nHeight );
65
66        setPixmap( "/mixerPanel/mixerline_background.png" );
67
68        // Play sample button
69        m_pPlaySampleBtn = new Button(
70                        this,
71                        "/mixerPanel/btn_play_on.png",
72                        "/mixerPanel/btn_play_off.png",
73                        "/mixerPanel/btn_play_over.png",
74                        QSize( 18, 13 )
75        );
76        m_pPlaySampleBtn->move( 8, 2 );
77        m_pPlaySampleBtn->setToolTip( trUtf8( "Play sample" ) );
78        connect(m_pPlaySampleBtn, SIGNAL(clicked(Button*)), this, SLOT(click(Button*)));
79        connect(m_pPlaySampleBtn, SIGNAL(rightClicked(Button*)), this, SLOT(rightClick(Button*)));
80
81        // Trigger sample LED
82        m_pTriggerSampleLED = new Button(
83                        this,
84                        "/mixerPanel/led_trigger_on.png",
85                        "/mixerPanel/led_trigger_off.png",
86                        "/mixerPanel/led_trigger_off.png",
87                        QSize( 5, 13 )
88        );
89        m_pTriggerSampleLED->move( 26, 2 );
90        connect(m_pTriggerSampleLED, SIGNAL(clicked(Button*)), this, SLOT(click(Button*)));
91
92        // Mute button
93        m_pMuteBtn = new ToggleButton(
94                        this,
95                        "/mixerPanel/btn_mute_on.png",
96                        "/mixerPanel/btn_mute_off.png",
97                        "/mixerPanel/btn_mute_over.png",
98                        QSize( 18, 13 )
99        );
100        m_pMuteBtn->move( 8, 17 );
101        m_pMuteBtn->setToolTip( trUtf8( "Mute" ) );
102        connect(m_pMuteBtn, SIGNAL(clicked(Button*)), this, SLOT(click(Button*)));
103
104        // Solo button
105        m_pSoloBtn = new ToggleButton(
106                        this,
107                        "/mixerPanel/btn_solo_on.png",
108                        "/mixerPanel/btn_solo_off.png",
109                        "/mixerPanel/btn_solo_over.png",
110                        QSize( 18, 13 )
111        );
112        m_pSoloBtn->move( 30, 17);
113        m_pSoloBtn->setToolTip( trUtf8( "Solo" ) );
114        connect(m_pSoloBtn, SIGNAL(clicked(Button*)), this, SLOT(click(Button*)));
115
116        // pan rotary
117        m_pPanRotary = new Rotary( this, Rotary::TYPE_CENTER, trUtf8( "Pan" ), false, true);
118        m_pPanRotary->move( 14, 32 );
119        connect( m_pPanRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( panChanged(Rotary*) ) );
120
121        // FX send
122        uint y = 0;
123        for (uint i = 0; i < MAX_FX; i++) {
124                m_pKnob[i] = new Knob(this);
125                if ( (i % 2) == 0 ) {
126                        m_pKnob[i]->move( 9, 63 + (20 * y) );
127                }
128                else {
129                        m_pKnob[i]->move( 30, 63 + (20 * y) );
130                        y++;
131                }
132                connect( m_pKnob[i], SIGNAL( valueChanged(Knob*) ), this, SLOT( knobChanged(Knob*) ) );
133        }
134
135        Preferences *pref = Preferences::get_instance();
136
137        QString family = pref->getMixerFontFamily();
138        int size = pref->getMixerFontPointSize();
139        QFont mixerFont( family, size );
140        float m_fFalloffTemp = pref->getMixerFalloffSpeed();
141        m_fFalloffTemp = (m_fFalloffTemp * 20) - 2;
142        m_nFalloff = (int)m_fFalloffTemp;
143
144        QPixmap textBackground;
145        bool ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
146        if( ok == false ){
147                ERRORLOG( "Error loading pixmap" );
148        }
149
150        // instrument name widget
151        m_pNameWidget = new InstrumentNameWidget( this );
152        m_pNameWidget->move( 6, 128 );
153        m_pNameWidget->setToolTip( trUtf8( "Instrument name (double click to edit)" ) );
154        connect( m_pNameWidget, SIGNAL( doubleClicked () ), this, SLOT( nameClicked() ) );
155        connect( m_pNameWidget, SIGNAL( clicked () ), this, SLOT( nameSelected() ) );
156
157        // m_pFader
158        m_pFader = new Fader( this, false, false );
159        m_pFader->move( 23, 128 );
160        m_pFader->setMinValue( 0.0 );
161        m_pFader->setMaxValue( 1.5 );
162        connect( m_pFader, SIGNAL( valueChanged(Fader*) ), this, SLOT( faderChanged(Fader*) ) );
163
164
165        m_pPeakLCD = new LCDDisplay( this, LCDDigit::SMALL_BLUE, 4 );
166        m_pPeakLCD->move( 10, 106 );
167        m_pPeakLCD->setText( "0.00" );
168        QPalette lcdPalette;
169        lcdPalette.setColor( QPalette::Background, QColor( 49, 53, 61 ) );
170        m_pPeakLCD->setPalette( lcdPalette );
171}
172
173
174
175MixerLine::~MixerLine()
176{
177//      INFOLOG( "DESTROY" );
178        //delete m_pFader;
179}
180
181
182
183void MixerLine::updateMixerLine()
184{
185        if ( m_nPeakTimer > m_nFalloff ) {
186                if ( m_fMaxPeak > 0.05f ) {
187                        m_fMaxPeak = m_fMaxPeak - 0.05f;
188                }
189                else {
190                        m_fMaxPeak = 0.0f;
191                        m_nPeakTimer = 0;
192                }
193                char tmp[20];
194                sprintf(tmp, "%#.2f", m_fMaxPeak );
195                m_pPeakLCD->setText(tmp);
196                if ( m_fMaxPeak > 1.0 ) {
197                        m_pPeakLCD->setSmallRed();
198                }
199                else {
200                        m_pPeakLCD->setSmallBlue();
201                }
202        }
203        m_nPeakTimer++;
204}
205
206
207
208void MixerLine::click(Button *ref) {
209        Song *song = (Hydrogen::get_instance())->getSong();
210
211        if (ref == m_pMuteBtn) {
212                song->__is_modified = true;
213                emit muteBtnClicked(this);
214        }
215        else if (ref == m_pSoloBtn) {
216                song->__is_modified = true;
217                emit soloBtnClicked(this);
218        }
219        else if (ref == m_pPlaySampleBtn) {
220                emit noteOnClicked(this);
221        }
222}
223
224
225
226void MixerLine::rightClick(Button *ref)
227{
228        if (ref == m_pPlaySampleBtn) {
229                emit noteOffClicked(this);
230        }
231
232}
233
234
235
236void MixerLine::faderChanged(Fader *ref)
237{
238        Song *song = (Hydrogen::get_instance())->getSong();
239        song->__is_modified = true;
240        emit volumeChanged(this);
241
242        char m_pFaderPos[100];
243        float value = ref->getValue();
244        sprintf( m_pFaderPos, "%#.2f",  value);
245        ( HydrogenApp::get_instance() )->setStatusBarMessage( trUtf8( "Set instrument volume [%1]" ).arg( m_pFaderPos ), 2000 );
246}
247
248
249
250bool MixerLine::isMuteClicked() {
251        return m_pMuteBtn->isPressed();
252}
253
254
255
256void MixerLine::setMuteClicked(bool isClicked) {
257        m_pMuteBtn->setPressed(isClicked);
258}
259
260
261
262bool MixerLine::isSoloClicked() {
263        return m_pSoloBtn->isPressed();
264}
265
266
267
268void MixerLine::setSoloClicked(bool isClicked) {
269        m_pSoloBtn->setPressed(isClicked);
270}
271
272
273
274float MixerLine::getVolume()
275{
276        return m_pFader->getValue();
277}
278
279
280
281void MixerLine::setVolume( float value )
282{
283        m_pFader->setValue( value );
284}
285
286
287
288void MixerLine::setPeak_L( float peak ) {
289        if (peak != getPeak_L() ) {
290                m_pFader->setPeak_L( peak );
291                if (peak > m_fMaxPeak) {
292                        if ( peak < 0.1f ) {
293                                peak = 0.0f;
294                        }
295                        char tmp[20];
296                        sprintf(tmp, "%#.2f", peak);
297                        m_pPeakLCD->setText( tmp );
298                        if ( peak > 1.0 ) {
299                                m_pPeakLCD->setSmallRed();
300                        }
301                        else {
302                                m_pPeakLCD->setSmallBlue();
303                        }
304                        m_fMaxPeak = peak;
305                        m_nPeakTimer = 0;
306                }
307        }
308}
309
310
311
312float MixerLine::getPeak_L() {
313        return m_pFader->getPeak_L();
314}
315
316
317
318void MixerLine::setPeak_R( float peak ) {
319        if (peak != getPeak_R() ) {
320                m_pFader->setPeak_R( peak );
321                if (peak > m_fMaxPeak) {
322                        if ( peak < 0.1f ) {
323                                peak = 0.0f;
324                        }
325                        char tmp[20];
326                        sprintf(tmp, "%#.2f", peak);
327                        m_pPeakLCD->setText( tmp );
328                        if ( peak > 1.0 ) {
329                                m_pPeakLCD->setSmallRed();
330                        }
331                        else {
332                                m_pPeakLCD->setSmallBlue();
333                        }
334                        m_fMaxPeak = peak;
335                        m_nPeakTimer = 0;
336                }
337        }
338}
339
340
341
342float MixerLine::getPeak_R() {
343        return m_pFader->getPeak_R();
344}
345
346
347
348
349
350void MixerLine::nameClicked() {
351        emit instrumentNameClicked(this);
352}
353
354
355
356void MixerLine::nameSelected() {
357        emit instrumentNameSelected(this);
358}
359
360
361
362
363
364void MixerLine::panChanged(Rotary *ref)
365{
366        Song *song = Hydrogen::get_instance()->getSong();
367        song->__is_modified = true;
368        emit panChanged( this );
369
370        float panValue = ref->getValue();
371        float pan_L, pan_R;
372        if (panValue > 0.5) {
373                pan_L = (1.0 - panValue) * 2.0;
374                pan_R = 1.0;
375        } else {
376                pan_L = 1.0;
377                pan_R = panValue * 2.0;
378        }
379
380        char m_pFaderPos[100];
381        sprintf( m_pFaderPos, "%#.2fL, %#.2fR",  pan_L, pan_R);
382        HydrogenApp::get_instance()->setStatusBarMessage( trUtf8( "Set instr. pan [%1]" ).arg( m_pFaderPos ), 2000 );
383
384        m_pPanRotary->setToolTip( QString("Pan ") + QString( m_pFaderPos ) );
385}
386
387
388
389float MixerLine::getPan()
390{
391        return m_pPanRotary->getValue();
392}
393
394
395
396void MixerLine::setPan(float fValue)
397{
398        if ( fValue != m_pPanRotary->getValue() ) {
399                m_pPanRotary->setValue( fValue );
400                float pan_L, pan_R;
401                if (fValue > 0.5) {
402                        pan_L = (1.0 - fValue) * 2.0;
403                        pan_R = 1.0;
404                } else {
405                        pan_L = 1.0;
406                        pan_R = fValue * 2.0;
407                }
408                char m_pFaderPos[100];
409                sprintf( m_pFaderPos, "Pan %#.2fL, %#.2fR",  pan_L, pan_R);
410                m_pPanRotary->setToolTip( QString( m_pFaderPos ) );
411        }
412}
413
414
415void MixerLine::setPlayClicked( bool clicked ) {
416        m_pTriggerSampleLED->setPressed( clicked );
417}
418
419
420void MixerLine::knobChanged(Knob* pRef)
421{
422//      infoLog( "knobChanged" );
423        for (uint i = 0; i < MAX_FX; i++) {
424                if (m_pKnob[i] == pRef) {
425                        emit knobChanged( this, i );
426                        break;
427                }
428        }
429}
430
431
432void MixerLine::setFXLevel( uint nFX, float fValue )
433{
434        if (nFX > MAX_FX) {
435                ERRORLOG( QString("[setFXLevel] nFX > MAX_FX (nFX=%1)").arg(nFX) );
436        }
437        m_pKnob[nFX]->setValue( fValue );
438}
439
440float MixerLine::getFXLevel(uint nFX)
441{
442        if (nFX > MAX_FX) {
443                ERRORLOG( QString("[setFXLevel] nFX > MAX_FX (nFX=%1)").arg(nFX) );
444        }
445        return m_pKnob[nFX]->getValue();
446}
447
448
449void MixerLine::setSelected( bool bIsSelected )
450{
451        if (m_bIsSelected == bIsSelected )      return;
452
453        m_bIsSelected = bIsSelected;
454        if (m_bIsSelected) {
455                setPixmap( "/mixerPanel/mixerline_background_on.png" );
456        }
457        else {
458                setPixmap( "/mixerPanel/mixerline_background.png" );
459        }
460
461}
462
463
464
465
466
467// ::::::::::::::::::::::::::::
468
469
470
471
472MasterMixerLine::MasterMixerLine(QWidget* parent)
473 : PixmapWidget( parent, "MasterMixerLine" )
474{
475        m_nWidth = MASTERMIXERLINE_WIDTH;
476        m_nHeight = MASTERMIXERLINE_HEIGHT;
477        m_nPeakTimer = 0;
478
479        setMinimumSize( m_nWidth, m_nHeight );
480        setMaximumSize( m_nWidth, m_nHeight );
481        resize( m_nWidth, m_nHeight );
482        QPalette defaultPalette;
483        defaultPalette.setColor( QPalette::Background, QColor( 58, 62, 72 ) );
484        this->setPalette( defaultPalette );
485
486        // Background image
487        setPixmap( "/mixerPanel/masterMixerline_background.png" );
488
489        Preferences *pref = Preferences::get_instance();
490        int size = pref->getMixerFontPointSize();
491        QString family = pref->getMixerFontFamily();
492        float m_fFalloffTemp = pref->getMixerFalloffSpeed();
493        m_fFalloffTemp = (m_fFalloffTemp * 20) - 2;
494        m_nFalloff = (int)m_fFalloffTemp;
495
496        m_pMasterFader = new MasterFader( this );
497        m_pMasterFader->setMin( 0.0 );
498        m_pMasterFader->setMax( 1.5 );
499        m_pMasterFader->move( 24, MASTERMIXERLINE_FADER_H );
500        connect( m_pMasterFader, SIGNAL( valueChanged(MasterFader*) ), this, SLOT( faderChanged(MasterFader*) ) );
501
502        QFont mixerFont( family, size );
503
504        m_pPeakLCD = new LCDDisplay( this, LCDDigit::SMALL_BLUE, 4 );
505        m_pPeakLCD->move( 23, 53 );
506        m_pPeakLCD->setText( "0.00" );
507        QPalette lcdPalette;
508        lcdPalette.setColor( QPalette::Background, QColor( 49, 53, 61 ) );
509        m_pPeakLCD->setPalette( lcdPalette );
510
511        m_pHumanizeVelocityRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Humanize velocity" ), false, false );
512        m_pHumanizeVelocityRotary->move( 74, 88 );
513        connect( m_pHumanizeVelocityRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
514
515        m_pHumanizeTimeRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Humanize time" ), false, false );
516        m_pHumanizeTimeRotary->move( 74, 125 );
517        connect( m_pHumanizeTimeRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
518
519        m_pSwingRotary = new Rotary( this,  Rotary::TYPE_NORMAL, trUtf8( "Swing" ), false, false );
520        m_pSwingRotary->move( 74, 162 );
521        connect( m_pSwingRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
522
523        // Mute btn
524        m_pMuteBtn = new ToggleButton(
525                        this,
526                        "/mixerPanel/master_mute_on.png",
527                        "/mixerPanel/master_mute_off.png",
528                        "/mixerPanel/master_mute_over.png",
529                        QSize( 42, 13 )
530        );
531        m_pMuteBtn->move( 20, 32 );
532        connect( m_pMuteBtn, SIGNAL( clicked(Button*) ), this, SLOT( muteClicked(Button*) ) );
533
534}
535
536
537
538
539MasterMixerLine::~MasterMixerLine()
540{
541//      cout << "MixerLine destroy" << endl;
542        m_fMaxPeak = 0.0;
543}
544
545
546
547void MasterMixerLine::muteClicked(Button* pBtn)
548{
549        Hydrogen::get_instance()->getSong()->__is_muted = pBtn->isPressed();
550}
551
552
553
554void MasterMixerLine::faderChanged(MasterFader *ref)
555{
556        m_pMasterFader->setValue( ref->getValue() );
557
558        emit volumeChanged(this);
559
560        Song *song = Hydrogen::get_instance()->getSong();
561        song->__is_modified = true;
562
563        char m_pMasterFaderPos[100];
564        float value = ref->getValue();
565        sprintf( m_pMasterFaderPos, "%#.2f",  value);
566        ( HydrogenApp::get_instance() )->setStatusBarMessage( trUtf8( "Set master volume [%1]" ).arg( m_pMasterFaderPos ), 2000 );
567}
568
569
570
571
572float MasterMixerLine::getVolume()
573{
574        return m_pMasterFader->getValue();
575}
576
577
578
579void MasterMixerLine::setVolume( float value )
580{
581        m_pMasterFader->setValue( value );
582}
583
584
585
586void MasterMixerLine::setPeak_L(float peak)
587{
588        if ( peak != getPeak_L() ) {
589                m_pMasterFader->setPeak_L(peak);
590                if (peak > m_fMaxPeak) {
591                        if ( peak < 0.1f ) {
592                                peak = 0.0f;
593                        }
594                        char tmp[20];
595                        sprintf(tmp, "%#.2f", peak);
596                        m_pPeakLCD->setText(tmp);
597                        if ( peak > 1.0 ) {
598                                m_pPeakLCD->setSmallRed();
599                        }
600                        else {
601                                m_pPeakLCD->setSmallBlue();
602                        }
603                        m_fMaxPeak = peak;
604                        m_nPeakTimer = 0;
605                }
606        }
607}
608
609
610
611
612float MasterMixerLine::getPeak_L() {
613        return m_pMasterFader->getPeak_L();
614}
615
616
617
618void MasterMixerLine::setPeak_R(float peak) {
619        if ( peak != getPeak_R() ) {
620                m_pMasterFader->setPeak_R(peak);
621                if (peak > m_fMaxPeak) {
622                        if ( peak < 0.1f ) {
623                                peak = 0.0f;
624                        }
625                        char tmp[20];
626                        sprintf(tmp, "%#.2f", peak);
627                        m_pPeakLCD->setText(tmp);
628                        if ( peak > 1.0 ) {
629                                m_pPeakLCD->setSmallRed();
630                        }
631                        else {
632                                m_pPeakLCD->setSmallBlue();
633                        }
634                        m_fMaxPeak = peak;
635                        m_nPeakTimer = 0;
636                }
637        }
638}
639
640
641
642float MasterMixerLine::getPeak_R() {
643        return m_pMasterFader->getPeak_R();
644}
645
646
647
648void MasterMixerLine::updateMixerLine()
649{
650
651        if ( m_nPeakTimer > m_nFalloff ) {
652                if ( m_fMaxPeak  > 0.05f ) {
653                        m_fMaxPeak = m_fMaxPeak - 0.05f;
654                }
655                else {
656                        m_fMaxPeak = 0.0f;
657                        m_nPeakTimer = 0;
658                }
659                char tmp[20];
660                sprintf(tmp, "%#.2f", m_fMaxPeak );
661                m_pPeakLCD->setText(tmp);
662                if ( m_fMaxPeak > 1.0 ) {
663                        m_pPeakLCD->setSmallRed();
664                }
665                else {
666                        m_pPeakLCD->setSmallBlue();
667                }
668        }
669        m_nPeakTimer++;
670
671        Song *pSong = Hydrogen::get_instance()->getSong();
672        if ( pSong ) {
673                m_pHumanizeTimeRotary->setValue( pSong->get_humanize_time_value() );
674                m_pHumanizeVelocityRotary->setValue( pSong->get_humanize_velocity_value() );
675                m_pSwingRotary->setValue( pSong->get_swing_factor() );
676        }
677        else {
678                WARNINGLOG( "pSong == NULL ");
679        }
680}
681
682
683void MasterMixerLine::rotaryChanged( Rotary *pRef )
684{
685        QString sMsg;
686        float fVal = pRef->getValue();
687        char sVal[100];
688        sprintf( sVal, "%#.2f", fVal);
689
690        Hydrogen *pEngine = Hydrogen::get_instance();
691        AudioEngine::get_instance()->lock( RIGHT_HERE );
692
693        if ( pRef == m_pHumanizeTimeRotary ) {
694                pEngine->getSong()->set_humanize_time_value( fVal );
695                sMsg = trUtf8( "Set humanize time parameter [%1]").arg( sVal );
696        }
697        else if ( pRef == m_pHumanizeVelocityRotary ) {
698                pEngine->getSong()->set_humanize_velocity_value( fVal );
699                sMsg = trUtf8( "Set humanize velocity parameter [%1]").arg( sVal );
700        }
701        else if ( pRef == m_pSwingRotary ) {
702                pEngine->getSong()->set_swing_factor( fVal );
703                sMsg = trUtf8( "Set swing factor [%1]").arg( sVal );
704        }
705        else {
706                ERRORLOG( "[knobChanged] Unhandled knob" );
707        }
708
709        AudioEngine::get_instance()->unlock();
710
711        ( HydrogenApp::get_instance() )->setStatusBarMessage( sMsg, 2000 );
712}
713
714
715
716
717/////////////////////////////////////////
718
719
720FxMixerLine::FxMixerLine(QWidget* parent)
721 : PixmapWidget( parent, "FxMixerLine" )
722{
723        m_nWidth = MIXERLINE_WIDTH;
724        m_nHeight = MIXERLINE_HEIGHT;
725
726        setMinimumSize( m_nWidth, m_nHeight );
727        setMaximumSize( m_nWidth, m_nHeight );
728        resize( m_nWidth, m_nHeight );
729//      QPalette defaultPalette;
730//      defaultPalette.setColor( QPalette::Background, QColor( 58, 62, 72 ) );
731//      this->setPalette( defaultPalette );
732        m_fMaxPeak = 0.0;
733
734        // MixerLine Background image
735        setPixmap( "/mixerPanel/mixerline_background.png" );
736
737        // MixerLine LABEL Background image
738//      QPixmap mixerLineLabelBackground;
739//      ok = mixerLineLabelBackground.load(Skin::getImagePath() + "/mixerPanel/mixerline_label_background.png");
740//      if( ok == false ){
741//              ERRORLOG( "Error loading pixmap" );
742//      }
743
744//      QPixmap textBackground;
745//      ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
746//      if( ok == false ){
747//              ERRORLOG( "Error loading pixmap" );
748//      }
749
750
751        // active button
752        activeBtn = new ToggleButton(
753                        this,
754                        "/mixerPanel/btn_on_on.png",
755                        "/mixerPanel/btn_on_off.png",
756                        "/mixerPanel/btn_on_over.png",
757                        QSize( 18, 12 )
758        );
759        activeBtn->move( 2, 5 );
760        activeBtn->setToolTip( trUtf8( "FX on/off") );
761        connect( activeBtn, SIGNAL( clicked(Button*) ), this, SLOT( click(Button*) ) );
762
763        Preferences *pref = Preferences::get_instance();
764
765        // m_pFader
766        m_pFader = new Fader( this, false, false );
767        m_pFader->move( 22, 106 );
768        connect( m_pFader, SIGNAL( valueChanged(Fader*) ), this, SLOT( faderChanged(Fader*) ) );
769
770        QString family = pref->getMixerFontFamily();
771        int size = pref->getMixerFontPointSize();
772        QFont mixerFont( family, size );
773
774
775        m_pNameWidget = new InstrumentNameWidget( this );
776        m_pNameWidget->move( 2, 106 );
777        m_pNameWidget->setText( trUtf8( "Master output" ) );
778
779        m_pPeakLCD = new LCDDisplay( this, LCDDigit::SMALL_BLUE, 4 );
780        m_pPeakLCD->move( 2, MIXERLINE_LABEL_H );
781        m_pPeakLCD->setText( "0.00" );
782}
783
784
785
786FxMixerLine::~FxMixerLine()
787{
788        delete m_pFader;
789}
790
791
792
793void FxMixerLine::click(Button *ref) {
794        Song *song = Hydrogen::get_instance()->getSong();
795
796        if (ref == activeBtn ) {
797                song->__is_modified = true;
798                emit activeBtnClicked( this );
799        }
800}
801
802
803
804void FxMixerLine::faderChanged(Fader *ref)
805{
806        UNUSED( ref );
807
808        m_fMaxPeak = 0.0;
809        char tmp[20];
810        sprintf( tmp, "%#.2f", m_fMaxPeak );
811        m_pPeakLCD->setText( tmp );
812        if ( m_fMaxPeak > 1.0 ) {
813                m_pPeakLCD->setSmallRed();
814        }
815        else {
816                m_pPeakLCD->setSmallBlue();
817        }
818
819
820        Song *song = Hydrogen::get_instance()->getSong();
821        song->__is_modified = true;
822        emit volumeChanged( this );
823
824}
825
826
827
828float FxMixerLine::getVolume()
829{
830        return m_pFader->getValue();
831}
832
833
834
835void FxMixerLine::setVolume( float value )
836{
837        m_pFader->setValue( value );
838}
839
840
841
842void FxMixerLine::setPeak_L( float peak )
843{
844        if (peak != getPeak_L() ) {
845                m_pFader->setPeak_L( peak );
846                if (peak > m_fMaxPeak) {
847                        char tmp[20];
848                        sprintf(tmp, "%#.2f", peak);
849                        m_pPeakLCD->setText(tmp);
850                        if ( peak > 1.0 ) {
851                                m_pPeakLCD->setSmallRed();
852                        }
853                        else {
854                                m_pPeakLCD->setSmallBlue();
855                        }
856
857                        m_fMaxPeak = peak;
858                }
859        }
860}
861
862
863
864float FxMixerLine::getPeak_L()
865{
866        return m_pFader->getPeak_L();
867}
868
869
870
871
872void FxMixerLine::setPeak_R(float peak)
873{
874        if (peak != getPeak_R() ) {
875                m_pFader->setPeak_R( peak );
876                if (peak > m_fMaxPeak) {
877                        char tmp[20];
878                        sprintf(tmp, "%#.2f", peak);
879                        m_pPeakLCD->setText(tmp);
880                        if ( peak > 1.0 ) {
881                                m_pPeakLCD->setSmallRed();
882                        }
883                        else {
884                                m_pPeakLCD->setSmallBlue();
885                        }
886
887                        m_fMaxPeak = peak;
888                }
889        }
890}
891
892
893
894
895float FxMixerLine::getPeak_R()
896{
897        return m_pFader->getPeak_R();
898}
899
900
901
902
903bool FxMixerLine::isFxActive()
904{
905        return activeBtn->isPressed();
906}
907
908
909
910
911void FxMixerLine::setFxActive( bool active )
912{
913        activeBtn->setPressed( active );
914}
915
916
917
918
919
920
921////////////////////////////////
922
923//QPixmap* InstrumentNameWidget::m_pBackground = NULL;
924
925
926InstrumentNameWidget::InstrumentNameWidget(QWidget* parent)
927 : PixmapWidget( parent, "InstrumentNameWidget" )
928{
929//      infoLog( "INIT" );
930        m_nWidgetWidth = 17;
931        m_nWidgetHeight = 116;
932
933        Preferences *pref = Preferences::get_instance();
934        QString family = pref->getMixerFontFamily();
935        int size = pref->getMixerFontPointSize();
936        m_mixerFont.setFamily( family );
937        m_mixerFont.setPointSize( size );
938//      m_mixerFont.setBold( true );
939//      m_mixerFont.setItalic( true );
940
941        setPixmap( "/mixerPanel/mixerline_label_background.png" );
942
943        this->resize( m_nWidgetWidth, m_nWidgetHeight );
944}
945
946
947
948
949InstrumentNameWidget::~InstrumentNameWidget()
950{
951//      infoLog( "DESTROY" );
952}
953
954
955
956void InstrumentNameWidget::paintEvent( QPaintEvent* ev )
957{
958        PixmapWidget::paintEvent( ev );
959
960        QPainter p( this );
961
962        p.setPen( QColor(230, 230, 230) );
963        p.setFont( m_mixerFont );
964        p.rotate( -90 );
965        p.drawText( -m_nWidgetHeight + 5, 0, m_nWidgetHeight - 10, m_nWidgetWidth, Qt::AlignVCenter, m_sInstrName );
966}
967
968
969
970
971void InstrumentNameWidget::setText( QString text )
972{
973        if (m_sInstrName != text ) {
974                m_sInstrName = text;
975                update();
976        }
977}
978
979
980
981QString InstrumentNameWidget::text()
982{
983        return m_sInstrName;
984}
985
986
987
988void InstrumentNameWidget::mousePressEvent( QMouseEvent * e )
989{
990        UNUSED( e );
991        emit clicked();
992}
993
994
995
996void InstrumentNameWidget::mouseDoubleClickEvent( QMouseEvent * e )
997{
998        UNUSED( e );
999        emit doubleClicked();
1000}
1001
1002
1003
1004// :::::::::::::::::::::
1005
1006
1007
1008LadspaFXMixerLine::LadspaFXMixerLine(QWidget* parent)
1009 : PixmapWidget( parent, "LadspaFXMixerLine" )
1010{
1011        resize( 194, 43 );
1012        setMinimumSize( width(), height() );
1013        setMaximumSize( width(), height() );
1014
1015        setPixmap( "/mixerPanel/fxline_background.png" );
1016
1017        // active button
1018        m_pActiveBtn = new ToggleButton(
1019                        this,
1020                        "/mixerPanel/bypass_on.png",
1021                        "/mixerPanel/bypass_off.png",
1022                        "/mixerPanel/bypass_over.png",
1023                        QSize( 30, 13 )
1024        );
1025        m_pActiveBtn->move( 55, 25 );
1026        m_pActiveBtn->setToolTip( trUtf8( "FX bypass") );
1027        connect( m_pActiveBtn, SIGNAL( clicked(Button*) ), this, SLOT( click(Button*) ) );
1028
1029        // edit button
1030        m_pEditBtn = new Button(
1031                        this,
1032                        "/mixerPanel/edit_on.png",
1033                        "/mixerPanel/edit_off.png",
1034                        "/mixerPanel/edit_over.png",
1035                        QSize( 30, 13 )
1036        );
1037        m_pEditBtn->move( 87, 25 );
1038        m_pEditBtn->setToolTip( trUtf8( "Edit FX parameters") );
1039        connect( m_pEditBtn, SIGNAL( clicked(Button*) ), this, SLOT( click(Button*) ) );
1040
1041        // instrument name widget
1042        m_pNameLCD = new LCDDisplay( this, LCDDigit::SMALL_BLUE, 13 );
1043        m_pNameLCD->move( 11, 9 );
1044        m_pNameLCD->setText( "No name" );
1045        m_pNameLCD->setToolTip( trUtf8( "Ladspa FX name" ) );
1046
1047        // m_pRotary
1048        m_pRotary = new Rotary( this,  Rotary::TYPE_NORMAL, trUtf8( "Effect return" ), false, false );
1049        m_pRotary->move( 132, 4 );
1050        connect( m_pRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
1051}
1052
1053
1054
1055LadspaFXMixerLine::~LadspaFXMixerLine()
1056{
1057//      infoLog( "DESTROY" );
1058}
1059
1060
1061
1062void LadspaFXMixerLine::setName(QString name)
1063{
1064        m_pNameLCD->setText( name );
1065}
1066
1067void LadspaFXMixerLine::click(Button *ref)
1068{
1069        if ( ref == m_pActiveBtn ) {
1070                emit activeBtnClicked( this );
1071        }
1072        else if( ref == m_pEditBtn ) {
1073                emit editBtnClicked( this );
1074        }
1075}
1076
1077
1078
1079bool LadspaFXMixerLine::isFxActive()
1080{
1081        return !m_pActiveBtn->isPressed();
1082}
1083
1084
1085
1086
1087void LadspaFXMixerLine::setFxActive( bool active )
1088{
1089        m_pActiveBtn->setPressed( !active );
1090}
1091
1092
1093
1094void LadspaFXMixerLine::rotaryChanged(Rotary *ref)
1095{
1096        UNUSED( ref );
1097        m_fMaxPeak = 0.0;
1098//      char tmp[20];
1099//      sprintf(tmp, "%#.1f", fMaxPeak);
1100//      m_pVolumeLbl->setText(tmp);
1101
1102        Song *song = Hydrogen::get_instance()->getSong();
1103        song->__is_modified = true;
1104        emit volumeChanged(this);
1105}
1106
1107
1108
1109void LadspaFXMixerLine::setPeaks( float fPeak_L, float fPeak_R )
1110{
1111        UNUSED( fPeak_L );
1112        UNUSED( fPeak_R );
1113/*
1114        m_pPeakmeter->setPeak_L( fPeak_L );
1115        m_pPeakmeter->setPeak_R( fPeak_R );
1116        m_pPeakmeter->updateFader();
1117*/
1118}
1119
1120
1121
1122void LadspaFXMixerLine::getPeaks( float *fPeak_L, float *fPeak_R )
1123{
1124        UNUSED( fPeak_L );
1125        UNUSED( fPeak_R );
1126/*
1127        (*fPeak_L) = m_pFader->getPeak_L();
1128        (*fPeak_R) = m_pFader->getPeak_R();
1129*/
1130}
1131
1132
1133
1134float LadspaFXMixerLine::getVolume()
1135{
1136        return m_pRotary->getValue();
1137}
1138
1139
1140
1141void LadspaFXMixerLine::setVolume(float value)
1142{
1143        m_pRotary->setValue( value );
1144//      m_pRotary->updateRotary();
1145}
Note: See TracBrowser for help on using the browser.