hydrogen 1.2.3
MixerLine.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#include <stdio.h>
24
25#include <QPainter>
26
28#include "../HydrogenApp.h"
29#include "../Skin.h"
30#include "../CommonStrings.h"
32#include "../Widgets/Fader.h"
33#include "../Widgets/Rotary.h"
34#include "../Widgets/Button.h"
36#include "../Widgets/LED.h"
38
39#include <core/Hydrogen.h>
41#include <core/MidiAction.h>
42using namespace H2Core;
43
44#include "MixerLine.h"
45
46#define MIXERLINE_WIDTH 56
47#define MIXERLINE_HEIGHT 254
48#define MASTERMIXERLINE_WIDTH 126
49#define MASTERMIXERLINE_HEIGHT 284
50#define MIXERLINE_LABEL_H 115
51#define MASTERMIXERLINE_FADER_H 75
52
53using namespace H2Core;
54
55MixerLine::MixerLine(QWidget* parent, int nInstr)
56 : PixmapWidget( parent )
57{
58//
59
62 m_fMaxPeak = 0.0;
63 m_nActivity = 0;
64 m_bIsSelected = false;
65 m_nPeakTimer = 0;
66
67 std::shared_ptr<Action> pAction;
68
69 resize( m_nWidth, m_nHeight );
70 setFixedSize( m_nWidth, m_nHeight );
71
72 setPixmap( "/mixerPanel/mixerline_background.png" );
73
74 // Play sample button
75 m_pPlaySampleBtn = new Button( this, QSize( 20, 15 ), Button::Type::Push, "play.svg", "", false, QSize( 7, 7 ), tr( "Play sample" ) );
76 m_pPlaySampleBtn->move( 6, 1 );
77 m_pPlaySampleBtn->setObjectName( "PlaySampleButton" );
78 connect(m_pPlaySampleBtn, &Button::clicked,
79 [&]() { emit noteOnClicked(this); });
81 [&]() { emit noteOffClicked(this); });
82
83 // Trigger sample LED
84 m_pTriggerSampleLED = new LED( this, QSize( 5, 13 ) );
85 m_pTriggerSampleLED->move( 26, 2 );
86 m_pTriggerSampleLED->setObjectName( "TriggerSampleLED" );
87
88 // LED indicating that this particular mixerline is selected
89 m_pSelectionLED = new LED( this, QSize( 11, 9 ) );
90 m_pSelectionLED->move( 39, 2 );
91 m_pSelectionLED->setObjectName( "SelectionLED" );
92
93 // Mute button
94
95 m_pMuteBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallMuteButton(), true, QSize(), tr( "Mute" ) );
96 m_pMuteBtn->move( 5, 16 );
97 m_pMuteBtn->setObjectName( "MixerMuteButton" );
98 connect(m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteBtnClicked() ));
99 pAction = std::make_shared<Action>("STRIP_MUTE_TOGGLE");
100 pAction->setParameter1( QString::number(nInstr ));
101 m_pMuteBtn->setAction(pAction);
102
103 // Solo button
104 m_pSoloBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallSoloButton(), false, QSize(), tr( "Solo" ) );
105 m_pSoloBtn->move( 28, 16 );
106 m_pSoloBtn->setObjectName( "MixerSoloButton" );
107 connect(m_pSoloBtn, SIGNAL( clicked() ), this, SLOT( soloBtnClicked() ));
108 pAction = std::make_shared<Action>("STRIP_SOLO_TOGGLE");
109 pAction->setParameter1( QString::number(nInstr ));
110 m_pSoloBtn->setAction(pAction);
111
112 // pan rotary
113 m_pPanRotary = new Rotary( this, Rotary::Type::Center, tr( "Pan" ), false, -1.0, 1.0 );
114 m_pPanRotary->setObjectName( "PanRotary" );
115 m_pPanRotary->move( 6, 32 );
116 connect( m_pPanRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( panChanged( WidgetWithInput* ) ) );
117 pAction = std::make_shared<Action>("PAN_ABSOLUTE");
118 pAction->setParameter1( QString::number(nInstr ));
119 pAction->setValue( QString::number( 0 ));
120 m_pPanRotary->setAction(pAction);
121
122 // FX send
123 uint y = 0;
124 for ( uint i = 0; i < MAX_FX; i++ ) {
125 m_pFxRotary[i] = new Rotary( this, Rotary::Type::Small, tr( "FX %1 send" ).arg( i + 1 ), false );
126 m_pFxRotary[i]->setObjectName( "FXRotary" );
127 pAction = std::make_shared<Action>( "EFFECT_LEVEL_ABSOLUTE" );
128 pAction->setParameter1( QString::number( nInstr ) );
129 pAction->setParameter2( QString::number( i ) );
130 m_pFxRotary[i]->setAction( pAction );
131 if ( (i % 2) == 0 ) {
132 m_pFxRotary[i]->move( 9, 63 + (20 * y) );
133 }
134 else {
135 m_pFxRotary[i]->move( 30, 63 + (20 * y) );
136 y++;
137 }
138 connect( m_pFxRotary[i], SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( knobChanged( WidgetWithInput* ) ) );
139 }
140
142
143 float fFalloffTemp = pPref->getMixerFalloffSpeed();
144 fFalloffTemp = (fFalloffTemp * 20) - 2;
145 m_nFalloff = (int)fFalloffTemp;
146
147 QPixmap textBackground;
148 bool ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
149 if( ok == false ){
150 ERRORLOG( "Error loading pixmap" );
151 }
152
153 // instrument name widget
155 m_pNameWidget->move( 6, 128 );
156 connect( m_pNameWidget, SIGNAL( doubleClicked () ), this, SLOT( nameClicked() ) );
157 connect( m_pNameWidget, SIGNAL( clicked () ), this, SLOT( nameSelected() ) );
158
159 // m_pFader
160 m_pFader = new Fader( this, Fader::Type::Normal, tr( "Volume" ), false, false, 0.0, 1.5 );
161 m_pFader->move( 23, 128 );
162 connect( m_pFader, SIGNAL( valueChanged( WidgetWithInput* ) ),
163 this, SLOT( faderChanged( WidgetWithInput* ) ) );
164
165 pAction = std::make_shared<Action>("STRIP_VOLUME_ABSOLUTE");
166 pAction->setParameter1( QString::number(nInstr) );
167 m_pFader->setAction( pAction );
168
169
170 m_pPeakLCD = new LCDDisplay( this, QSize( 41, 19 ), false, false );
171 m_pPeakLCD->move( 8, 105 );
172 m_pPeakLCD->setText( "0.00" );
173 m_pPeakLCD->setToolTip( tr( "Peak" ) );
174 QPalette lcdPalette;
175 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
176 m_pPeakLCD->setPalette( lcdPalette );
177}
178
181
183{
184 if ( m_nPeakTimer > m_nFalloff ) {
185 if ( m_fMaxPeak > 0.05f ) {
186 m_fMaxPeak = m_fMaxPeak - 0.05f;
187 }
188 else {
189 m_fMaxPeak = 0.0f;
190 m_nPeakTimer = 0;
191 }
192 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
193 if ( m_fMaxPeak > 1.0 ) {
194 m_pPeakLCD->setUseRedFont( true );
195 }
196 else {
197 m_pPeakLCD->setUseRedFont( false );
198 }
199 }
200 m_nPeakTimer++;
201}
202
207
212
214
215 assert( pRef );
216
218 emit volumeChanged(this);
219
220 WidgetWithInput* pFader = static_cast<Fader*>( pRef );
221
222 double value = (double) pFader->getValue();
223
224 QString sMessage = tr( "Set volume [%1] of instrument" )
225 .arg( value, 0, 'f', 2 );
226 sMessage.append( QString( " [%1]" )
227 .arg( m_pNameWidget->text() ) );
228 QString sCaller = QString( "%1:faderChanged:%2" )
229 .arg( class_name() ).arg( m_pNameWidget->text() );
230
232 showStatusBarMessage( sMessage, sCaller );
233}
234
236 return ( ( m_pMuteBtn->isChecked() && ! m_pMuteBtn->isDown() ) ||
237 ( ! m_pMuteBtn->isChecked() && m_pMuteBtn->isDown() ) );
238}
239
240void MixerLine::setMuteClicked(bool isClicked) {
241 if ( ! m_pMuteBtn->isDown() ) {
242 m_pMuteBtn->setChecked(isClicked);
243 }
244}
245
247 return ( ( m_pSoloBtn->isChecked() && ! m_pSoloBtn->isDown() ) || ( ! m_pSoloBtn->isChecked() && m_pSoloBtn->isDown() ) );
248}
249
250void MixerLine::setSoloClicked(bool isClicked) {
251 if ( ! m_pSoloBtn->isDown() ) {
252 m_pSoloBtn->setChecked(isClicked);
253 }
254}
255
257{
258 return m_pFader->getValue();
259}
260
261void MixerLine::setVolume( float value ) {
262 m_pFader->setValue( value );
263}
264
265void MixerLine::setPeak_L( float peak ) {
266 if (peak != getPeak_L() ) {
267 m_pFader->setPeak_L( peak );
268 if (peak > m_fMaxPeak) {
269 if ( peak < 0.1f ) {
270 peak = 0.0f;
271 }
272 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
273 if ( peak > 1.0 ) {
274 m_pPeakLCD->setUseRedFont( true );
275 }
276 else {
277 m_pPeakLCD->setUseRedFont( false );
278 }
279 m_fMaxPeak = peak;
280 m_nPeakTimer = 0;
281 }
282 }
283}
284
286 return m_pFader->getPeak_L();
287}
288
289void MixerLine::setPeak_R( float peak ) {
290 if (peak != getPeak_R() ) {
291 m_pFader->setPeak_R( peak );
292 if (peak > m_fMaxPeak) {
293 if ( peak < 0.1f ) {
294 peak = 0.0f;
295 }
296 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
297 if ( peak > 1.0 ) {
298 m_pPeakLCD->setUseRedFont( true );
299 }
300 else {
301 m_pPeakLCD->setUseRedFont( false );
302 }
303 m_fMaxPeak = peak;
304 m_nPeakTimer = 0;
305 }
306 }
307}
308
310 return m_pFader->getPeak_R();
311}
312
314 emit instrumentNameClicked(this);
315}
316
320
322{
323 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
324 emit panChanged( this );
329}
330
332{
333 return m_pPanRotary->getValue();
334}
335
336void MixerLine::setPan(float fValue)
337{
338 if ( fValue != m_pPanRotary->getValue() ) {
339 m_pPanRotary->setValue( fValue );
344 }
345}
346
347void MixerLine::setPlayClicked( bool clicked ) {
349}
350
352{
353 assert( pRef );
354 Rotary* pRotary = static_cast<Rotary*>( pRef );
355
356 for ( uint i = 0; i < MAX_FX; i++ ) {
357 if ( m_pFxRotary[i] == pRotary ) {
358 emit knobChanged( this, i );
359 break;
360 }
361 }
362}
363
364void MixerLine::setFXLevel( uint nFX, float fValue )
365{
366 if (nFX >= MAX_FX) {
367 ERRORLOG( QString("[setFXLevel] nFX >= MAX_FX (nFX=%1)").arg(nFX) );
368 return;
369 }
370 m_pFxRotary[nFX]->setValue( fValue );
371}
372
374{
375 if (nFX >= MAX_FX) {
376 ERRORLOG( QString("[setFXLevel] nFX >= MAX_FX (nFX=%1)").arg(nFX) );
377 return 0.0f;
378 }
379 return m_pFxRotary[nFX]->getValue();
380}
381
382void MixerLine::setSelected( bool bIsSelected )
383{
384 if ( m_bIsSelected == bIsSelected ) {
385 return;
386 }
387
388 m_bIsSelected = bIsSelected;
389 m_pSelectionLED->setActivated( bIsSelected );
390}
391
392// ::::::::::::::::::::::::::::
393
394
395ComponentMixerLine::ComponentMixerLine(QWidget* parent, int CompoID)
396 : PixmapWidget( parent )
397{
398//
399
400 m_nComponentID = CompoID;
401
404 m_fMaxPeak = 0.0;
405 m_nActivity = 0;
406 m_bIsSelected = false;
407 m_nPeakTimer = 0;
408
409 resize( m_nWidth, m_nHeight );
410 setFixedSize( m_nWidth, m_nHeight );
411
412 setPixmap( "/mixerPanel/componentmixerline_background.png" );
413
414 // Mute button
415 m_pMuteBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallMuteButton(), true, QSize(), tr( "Mute" ) );
416 m_pMuteBtn->move( 5, 16 );
417 connect(m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteBtnClicked() ));
418
419 // Solo button
420 m_pSoloBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallSoloButton(), false, QSize(), tr( "Solo" ) );
421 m_pSoloBtn->move( 28, 16 );
422 connect(m_pSoloBtn, SIGNAL( clicked() ), this, SLOT( soloBtnClicked() ));
423
425
426 float fFalloffTemp = pPref->getMixerFalloffSpeed();
427 fFalloffTemp = (fFalloffTemp * 20) - 2;
428 m_nFalloff = (int)fFalloffTemp;
429
430 QPixmap textBackground;
431 bool ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
432 if( ok == false ){
433 ERRORLOG( "Error loading pixmap" );
434 }
435
436 // instrument name widget
438 m_pNameWidget->move( 6, 128 );
439 m_pNameWidget->setToolTip( tr( "Component name" ) );
440
441 // m_pFader
442 m_pFader = new Fader( this, Fader::Type::Normal, tr( "Volume" ), false, false, 0.0, 1.5 );
443 m_pFader->move( 23, 128 );
444 connect( m_pFader, SIGNAL( valueChanged( WidgetWithInput* ) ),
445 this, SLOT( faderChanged( WidgetWithInput* ) ) );
446
447 //pAction = new MidiAction("STRIP_VOLUME_ABSOLUTE");
448 //pAction->setParameter1( QString::number(nInstr) );
449 //m_pFader->setAction( pAction );
450
451
452 m_pPeakLCD = new LCDDisplay( this, QSize( 41, 19 ), false, false );
453 m_pPeakLCD->move( 8, 105 );
454 m_pPeakLCD->setText( "0.00" );
455 m_pPeakLCD->setToolTip( tr( "Peak" ) );
456 QPalette lcdPalette;
457 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
458 m_pPeakLCD->setPalette( lcdPalette );
459}
460
461
462
465
467{
468 if ( m_nPeakTimer > m_nFalloff ) {
469 if ( m_fMaxPeak > 0.05f ) {
470 m_fMaxPeak = m_fMaxPeak - 0.05f;
471 }
472 else {
473 m_fMaxPeak = 0.0f;
474 m_nPeakTimer = 0;
475 }
476 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
477 if ( m_fMaxPeak > 1.0 ) {
478 m_pPeakLCD->setUseRedFont( true );
479 }
480 else {
481 m_pPeakLCD->setUseRedFont( false );
482 }
483 }
484 m_nPeakTimer++;
485}
486
490
494
496
497 assert( pRef );
498
500 emit volumeChanged(this);
501
502 WidgetWithInput* pFader = static_cast<Fader*>( pRef );
503 double value = (double) pFader->getValue();
504
505 QString sMessage = tr( "Set volume [%1] of component" )
506 .arg( value, 0, 'f', 2 );
507 sMessage.append( QString( " [%1]" )
508 .arg( m_pNameWidget->text() ) );
509 QString sCaller = QString( "%1:faderChanged:%2" )
510 .arg( class_name() ).arg( m_pNameWidget->text() );
511
513 showStatusBarMessage( sMessage, sCaller );
514}
515
517 return ( ( m_pMuteBtn->isChecked() && ! m_pMuteBtn->isDown() ) ||
518 ( ! m_pMuteBtn->isChecked() && m_pMuteBtn->isDown() ) );
519}
520
522 if ( ! m_pMuteBtn->isDown() ) {
523 m_pMuteBtn->setChecked(isClicked);
524 }
525}
526
528 return ( ( m_pSoloBtn->isChecked() && ! m_pSoloBtn->isDown() ) || ( ! m_pSoloBtn->isChecked() && m_pSoloBtn->isDown() ) );
529}
530
532 if ( ! m_pSoloBtn->isDown() ) {
533 m_pSoloBtn->setChecked(isClicked);
534 }
535}
536
538{
539 return m_pFader->getValue();
540}
541
542void ComponentMixerLine::setVolume( float value ) {
543 m_pFader->setValue( value );
544}
545
547 if (peak != getPeak_L() ) {
548 m_pFader->setPeak_L( peak );
549 if (peak > m_fMaxPeak) {
550 if ( peak < 0.1f ) {
551 peak = 0.0f;
552 }
553 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
554 if ( peak > 1.0 ) {
555 m_pPeakLCD->setUseRedFont( true );
556 }
557 else {
558 m_pPeakLCD->setUseRedFont( false );
559 }
560 m_fMaxPeak = peak;
561 m_nPeakTimer = 0;
562 }
563 }
564}
565
569
571 if (peak != getPeak_R() ) {
572 m_pFader->setPeak_R( peak );
573 if (peak > m_fMaxPeak) {
574 if ( peak < 0.1f ) {
575 peak = 0.0f;
576 }
577 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
578 if ( peak > 1.0 ) {
579 m_pPeakLCD->setUseRedFont( true );
580 }
581 else {
582 m_pPeakLCD->setUseRedFont( false );
583 }
584 m_fMaxPeak = peak;
585 m_nPeakTimer = 0;
586 }
587 }
588}
589
593
594
595// ::::::::::::::::::::::::::::
596
598 : PixmapWidget( parent )
599{
602 m_fMaxPeak = 0.0f;
603 m_nPeakTimer = 0;
604
605 setMinimumSize( m_nWidth, m_nHeight );
606 setMaximumSize( m_nWidth, m_nHeight );
607 resize( m_nWidth, m_nHeight );
608 QPalette defaultPalette;
609 defaultPalette.setColor( QPalette::Window, QColor( 58, 62, 72 ) );
610 this->setPalette( defaultPalette );
611
612 // Background image
613 setPixmap( "/mixerPanel/masterMixerline_background.png" );
614
616
617 float fFalloffTemp = pPref->getMixerFalloffSpeed();
618 fFalloffTemp = (fFalloffTemp * 20) - 2;
619 m_nFalloff = (int)fFalloffTemp;
620
621 m_pMasterFader = new Fader( this, Fader::Type::Master, tr( "Master volume" ), false, false, 0.0, 1.5 );
623 connect( m_pMasterFader, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( faderChanged( WidgetWithInput* ) ) );
624
625 std::shared_ptr<Action> pAction = std::make_shared<Action>("MASTER_VOLUME_ABSOLUTE");
626 m_pMasterFader->setAction( pAction );
627
628 m_pPeakLCD = new LCDDisplay( this, QSize( 38, 18 ), false, false );
629 m_pPeakLCD->move( 22, 51 );
630 m_pPeakLCD->setText( "0.00" );
631 m_pPeakLCD->setToolTip( tr( "Peak" ) );
632 QPalette lcdPalette;
633 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
634 m_pPeakLCD->setPalette( lcdPalette );
635
636 m_pHumanizeVelocityRotary = new Rotary( this, Rotary::Type::Normal, tr( "Humanize velocity" ), false );
637 m_pHumanizeVelocityRotary->move( 66, 88 );
638 connect( m_pHumanizeVelocityRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
639
640 m_pHumanizeTimeRotary = new Rotary( this, Rotary::Type::Normal, tr( "Humanize time" ), false );
641 m_pHumanizeTimeRotary->move( 66, 125 );
642 connect( m_pHumanizeTimeRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
643
644 m_pSwingRotary = new Rotary( this, Rotary::Type::Normal, tr( "16th-note Swing" ), false );
645 m_pSwingRotary->move( 66, 162 );
646 connect( m_pSwingRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
647
648 // Mute btn
649 m_pMuteBtn = new Button( this, QSize( 42, 17 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getBigMuteButton(), true );
650 m_pMuteBtn->setObjectName( "MixerMasterMuteButton" );
651 m_pMuteBtn->move( 20, 31 );
652 connect( m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteClicked() ) );
653 pAction = std::make_shared<Action>("MUTE_TOGGLE");
654 m_pMuteBtn->setAction( pAction );
655
656 m_pMasterLbl = new ClickableLabel( this, QSize( 55, 15 ), HydrogenApp::get_instance()->getCommonStrings()->getMasterLabel(), ClickableLabel::Color::Dark );
657 m_pMasterLbl->move( 14, 8 );
658 m_pHumanizeLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getHumanizeLabel(), ClickableLabel::Color::Dark );
659 m_pHumanizeLbl->move( 62, 79 );
660 m_pSwingLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getVelocityLabel(), ClickableLabel::Color::Dark );
661 m_pSwingLbl->move( 62, 116 );
662 m_pTimingLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getTimingLabel(), ClickableLabel::Color::Dark );
663 m_pTimingLbl->move( 62, 153 );
664 m_pVelocityLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getSwingLabel(), ClickableLabel::Color::Dark );
665 m_pVelocityLbl->move( 62, 190 );
666}
667
672
677
679{
680 assert( pRef );
681
682 Fader* pFader = static_cast<Fader*>( pRef );
683 m_pMasterFader->setValue( pFader->getValue() );
684
685 emit volumeChanged(this);
686
688
689 double value = (double) pFader->getValue();
691 showStatusBarMessage( tr( "Set master volume [%1]" )
692 .arg( value, 0, 'f', 2 ),
693 QString( "%1:faderChanged" )
694 .arg( class_name() ) );
695}
696
698{
699 return m_pMasterFader->getValue();
700}
701
702void MasterMixerLine::setVolume( float value ) {
703 m_pMasterFader->setValue( value );
704}
705
707{
708 if ( peak != getPeak_L() ) {
710 if (peak > m_fMaxPeak) {
711 if ( peak < 0.1f ) {
712 peak = 0.0f;
713 }
714 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
715 if ( peak > 1.0 ) {
716 m_pPeakLCD->setUseRedFont( true );
717 }
718 else {
719 m_pPeakLCD->setUseRedFont( false );
720 }
721 m_fMaxPeak = peak;
722 m_nPeakTimer = 0;
723 }
724 }
725}
726
730
732 if ( peak != getPeak_R() ) {
734 if (peak > m_fMaxPeak) {
735 if ( peak < 0.1f ) {
736 peak = 0.0f;
737 }
738 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
739 if ( peak > 1.0 ) {
740 m_pPeakLCD->setUseRedFont( true );
741 }
742 else {
743 m_pPeakLCD->setUseRedFont( false );
744 }
745 m_fMaxPeak = peak;
746 m_nPeakTimer = 0;
747 }
748 }
749}
750
754
756{
757
758 if ( m_nPeakTimer > m_nFalloff ) {
759 if ( m_fMaxPeak > 0.05f ) {
760 m_fMaxPeak = m_fMaxPeak - 0.05f;
761 }
762 else {
763 m_fMaxPeak = 0.0f;
764 m_nPeakTimer = 0;
765 }
766 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
767 if ( m_fMaxPeak > 1.0 ) {
768 m_pPeakLCD->setUseRedFont( true );
769 }
770 else {
771 m_pPeakLCD->setUseRedFont( false );
772 }
773 }
774 m_nPeakTimer++;
775
776 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
777 if ( pSong ) {
778 m_pHumanizeTimeRotary->setValue( pSong->getHumanizeTimeValue() );
779 m_pHumanizeVelocityRotary->setValue( pSong->getHumanizeVelocityValue() );
780 m_pSwingRotary->setValue( pSong->getSwingFactor() );
781 if ( ! m_pMuteBtn->isDown() ) {
782 m_pMuteBtn->setChecked( pSong->getIsMuted() );
783 }
784 }
785 else {
786 WARNINGLOG( "pSong == NULL ");
787 }
788}
789
791{
792 assert( pRef );
793
794 Rotary* pRotary = static_cast<Rotary*>( pRef );
795
796 QString sMsg;
797 QString sCaller = QString( "%1:rotaryChanged" ).arg( class_name() );
798 double fVal = (double) pRotary->getValue();
799
800 Hydrogen *pHydrogen = Hydrogen::get_instance();
801 pHydrogen->getAudioEngine()->lock( RIGHT_HERE );
802
803 if ( pRotary == m_pHumanizeTimeRotary ) {
804 pHydrogen->getSong()->setHumanizeTimeValue( fVal );
805 sMsg = tr( "Set humanize time param [%1]" ).arg( fVal, 0, 'f', 2 ); //not too long for display
806 sCaller.append( ":humanizeTime" );
807 }
808 else if ( pRotary == m_pHumanizeVelocityRotary ) {
809 pHydrogen->getSong()->setHumanizeVelocityValue( fVal );
810 sMsg = tr( "Set humanize vel. param [%1]" ).arg( fVal, 0, 'f', 2 ); //not too long for display
811 sCaller.append( ":humanizeVelocity" );
812 }
813 else if ( pRotary == m_pSwingRotary ) {
814 pHydrogen->getSong()->setSwingFactor( fVal );
815 sMsg = tr( "Set swing factor [%1]").arg( fVal, 0, 'f', 2 );
816 sCaller.append( ":humanizeSwing" );
817 }
818 else {
819 ERRORLOG( "[knobChanged] Unhandled knob" );
820 }
821
822 pHydrogen->getAudioEngine()->unlock();
823
824 ( HydrogenApp::get_instance() )->showStatusBarMessage( sMsg, sCaller );
825}
826
827
829
831 : PixmapWidget( parent )
832{
833// infoLog( "INIT" );
834 m_nWidgetWidth = 17;
835 m_nWidgetHeight = 116;
836
838
839 setPixmap( "/mixerPanel/mixerline_label_background.png" );
840
841 this->resize( m_nWidgetWidth, m_nWidgetHeight );
842}
843
845{
846// infoLog( "DESTROY" );
847}
848
849
850
851void InstrumentNameWidget::paintEvent( QPaintEvent* ev )
852{
853
855
857
858 QPainter p( this );
859
860 QFont font( pPref->getApplicationFontFamily(), getPointSize( pPref->getFontSize() ) );
861
862 p.setPen( QColor(230, 230, 230) );
863 p.setFont( font );
864 p.rotate( -90 );
865 p.drawText( -m_nWidgetHeight + 5, 0, m_nWidgetHeight - 10, m_nWidgetWidth, Qt::AlignVCenter, m_sInstrName );
866}
867
869{
870 if (m_sInstrName != text ) {
872 update();
873 }
874}
875
877{
878 return m_sInstrName;
879}
880
882{
883 UNUSED( e );
884 emit clicked();
885}
886
888{
889 UNUSED( e );
890 emit doubleClicked();
891}
892
898
899// :::::::::::::::::::::
900
901
902
904 : PixmapWidget( parent )
905{
906 resize( 194, 43 );
907 setMinimumSize( width(), height() );
908 setMaximumSize( width(), height() );
909
910 setPixmap( "/mixerPanel/fxline_background.png" );
911
912 // active button
913 m_pBypassBtn = new Button( this, QSize( 34, 14 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getBypassButton(), true, QSize(), tr( "FX bypass") );
914 m_pBypassBtn->setObjectName( "MixerFXBypassButton" );
915 m_pBypassBtn->move( 52, 25 );
916 connect( m_pBypassBtn, SIGNAL( clicked() ), this, SLOT( bypassBtnClicked() ) );
917
918
919 // edit button
920 m_pEditBtn = new Button( this, QSize( 34, 14 ), Button::Type::Push, "", HydrogenApp::get_instance()->getCommonStrings()->getEditButton(), false, QSize(), tr( "Edit FX parameters") );
921 m_pEditBtn->setObjectName( "MixerFXEditButton" );
922 m_pEditBtn->move( 86, 25 );
923 connect( m_pEditBtn, SIGNAL( clicked() ), this, SLOT( editBtnClicked() ) );
924
925 // instrument name widget
926 m_pNameLCD = new LCDDisplay( this, QSize( 108, 15 ), false, false );
927 m_pNameLCD->move( 11, 9 );
928 m_pNameLCD->setText( "No name" );
929 m_pNameLCD->setToolTip( tr( "Ladspa FX name" ) );
930
931 // m_pRotary
932 m_pRotary = new Rotary( this, Rotary::Type::Normal, tr( "Effect return" ), false );
934 m_pRotary->move( 124, 4 );
935 m_pRotary->setIsActive( false );
936 connect( m_pRotary, SIGNAL( valueChanged( WidgetWithInput* ) ),
937 this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
938
939 m_pReturnLbl = new ClickableLabel( this, QSize( 46, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getReturnLabel(), ClickableLabel::Color::Dark );
940 m_pReturnLbl->move( 123, 30 );
941}
942
943
944
946{
947// infoLog( "DESTROY" );
948}
949
951{
952 m_pNameLCD->setText( name );
953}
954
955
960 emit editBtnClicked( this );
961}
962
964{
965 return ( ( m_pBypassBtn->isChecked() && ! m_pBypassBtn->isDown() ) ||
966 ( ! m_pBypassBtn->isChecked() && m_pBypassBtn->isDown() ) );
967}
968
970{
971 if ( ! m_pBypassBtn->isDown() ) {
972 m_pBypassBtn->setChecked( bBypassed );
973 }
974 m_pRotary->setIsActive( ! bBypassed );
975}
976
978{
979 emit volumeChanged( this );
980 UNUSED( ref );
981}
982
983void LadspaFXMixerLine::setPeaks( float fPeak_L, float fPeak_R )
984{
985 UNUSED( fPeak_L );
986 UNUSED( fPeak_R );
987}
988
989void LadspaFXMixerLine::getPeaks( float *fPeak_L, float *fPeak_R )
990{
991 UNUSED( fPeak_L );
992 UNUSED( fPeak_R );
993}
994
996{
997 return m_pRotary->getValue();
998}
999
1000
1002{
1003 m_pRotary->setValue( value );
1004}
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
Definition AudioEngine.h:59
#define MIXERLINE_WIDTH
Definition MixerLine.cpp:46
#define MASTERMIXERLINE_WIDTH
Definition MixerLine.cpp:48
#define MIXERLINE_HEIGHT
Definition MixerLine.cpp:47
#define MASTERMIXERLINE_FADER_H
Definition MixerLine.cpp:51
#define MASTERMIXERLINE_HEIGHT
Definition MixerLine.cpp:49
#define WARNINGLOG(x)
Definition Object.h:238
#define ERRORLOG(x)
Definition Object.h:239
Generic Button with SVG icons or text.
Definition Button.h:60
@ Push
Button is not set checkable.
@ Toggle
Button is set checkable.
void rightClicked()
Custom QLabel that emits a signal when clicked.
void setMuteClicked(bool isClicked)
void setSoloClicked(bool isClicked)
void setVolume(float value)
void faderChanged(WidgetWithInput *ref)
void setPeak_R(float peak)
Button * m_pMuteBtn
Definition MixerLine.h:225
ComponentMixerLine(QWidget *parent, int CompoID)
Button * m_pSoloBtn
Definition MixerLine.h:226
void volumeChanged(ComponentMixerLine *ref)
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:227
InstrumentNameWidget * m_pNameWidget
Definition MixerLine.h:224
void setPeak_L(float peak)
Custom fader widget.
Definition Fader.h:44
float getPeak_L() const
Definition Fader.h:62
float getPeak_R() const
Definition Fader.h:65
void setPeak_R(float peak)
Definition Fader.cpp:338
void setPeak_L(float peak)
Definition Fader.cpp:313
void unlock()
Mutex unlocking of the AudioEngine.
void lock(const char *file, unsigned int line, const char *function)
Mutex locking of the AudioEngine.
virtual const char * class_name() const
Definition Object.h:79
Hydrogen Audio Engine.
Definition Hydrogen.h:54
std::shared_ptr< Song > getSong() const
Get the current song.
Definition Hydrogen.h:122
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
Definition Hydrogen.h:83
AudioEngine * getAudioEngine() const
Definition Hydrogen.h:649
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
CoreActionController * getCoreActionController() const
Definition Hydrogen.h:639
Manager for User Preferences File (singleton)
Definition Preferences.h:78
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
@ Font
Either the font size or font family have changed.
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
void mousePressEvent(QMouseEvent *e) override
InstrumentNameWidget(QWidget *parent)
void onPreferencesChanged(H2Core::Preferences::Changes changes)
void mouseDoubleClickEvent(QMouseEvent *e) override
virtual void paintEvent(QPaintEvent *ev) override
void setText(QString text)
Non-interactive display used for both numerical values and the status display.
Definition LCDDisplay.h:40
void setUseRedFont(bool bUseRedFont)
LED identicating a user selection.
Definition LED.h:43
void setActivated(bool bActivated)
Definition LED.cpp:63
LCDDisplay * m_pNameLCD
Definition MixerLine.h:320
ClickableLabel * m_pReturnLbl
Definition MixerLine.h:321
void setPeaks(float fPeak_L, float fPeak_R)
Rotary * m_pRotary
Definition MixerLine.h:319
void volumeChanged(LadspaFXMixerLine *ref)
void setVolume(float value)
void setName(QString name)
void setFxBypassed(bool active)
void getPeaks(float *fPeak_L, float *fPeak_R)
Button * m_pBypassBtn
Definition MixerLine.h:317
LadspaFXMixerLine(QWidget *parent)
void rotaryChanged(WidgetWithInput *ref)
Button * m_pEditBtn
Definition MixerLine.h:318
Fader * m_pMasterFader
Definition MixerLine.h:268
ClickableLabel * m_pSwingLbl
Definition MixerLine.h:272
void volumeChanged(MasterMixerLine *ref)
void faderChanged(WidgetWithInput *pRef)
ClickableLabel * m_pTimingLbl
Definition MixerLine.h:273
void setVolume(float value)
Rotary * m_pHumanizeTimeRotary
Definition MixerLine.h:279
void setPeak_R(float peak)
Button * m_pMuteBtn
Definition MixerLine.h:282
ClickableLabel * m_pVelocityLbl
Definition MixerLine.h:274
void rotaryChanged(WidgetWithInput *pRef)
ClickableLabel * m_pMasterLbl
Definition MixerLine.h:270
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:276
MasterMixerLine(QWidget *parent)
Rotary * m_pHumanizeVelocityRotary
Definition MixerLine.h:280
Rotary * m_pSwingRotary
Definition MixerLine.h:278
void setPeak_L(float peak)
ClickableLabel * m_pHumanizeLbl
Definition MixerLine.h:271
void updateMixerLine()
void setAction(std::shared_ptr< Action > pAction)
bool isMuteClicked()
void instrumentNameSelected(MixerLine *ref)
bool m_bIsSelected
Definition MixerLine.h:148
void setMuteClicked(bool isClicked)
Button * m_pPlaySampleBtn
Definition MixerLine.h:160
void instrumentNameClicked(MixerLine *ref)
float getPeak_L()
void muteBtnClicked()
void setSelected(bool bIsSelected)
Rotary * m_pPanRotary
Definition MixerLine.h:156
void setSoloClicked(bool isClicked)
void setPlayClicked(bool clicked)
void panChanged(MixerLine *ref)
void setFXLevel(uint nFX, float fValue)
void noteOffClicked(MixerLine *ref)
void noteOnClicked(MixerLine *ref)
void setVolume(float value)
bool isSoloClicked()
void faderChanged(WidgetWithInput *ref)
float getPan()
uint m_nHeight
Definition MixerLine.h:147
MixerLine(QWidget *parent, int nInstr)
Definition MixerLine.cpp:55
float getFXLevel(uint nFX)
void soloBtnClicked()
void setPeak_R(float peak)
uint m_nWidth
Definition MixerLine.h:146
Button * m_pMuteBtn
Definition MixerLine.h:158
float getPeak_R()
Button * m_pSoloBtn
Definition MixerLine.h:159
uint m_nPeakTimer
Definition MixerLine.h:151
Rotary * m_pFxRotary[MAX_FX]
Definition MixerLine.h:163
LED * m_pTriggerSampleLED
Definition MixerLine.h:161
void setPan(float value)
float m_nFalloff
Definition MixerLine.h:153
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:165
void knobChanged(MixerLine *ref, int nKnob)
float getVolume()
InstrumentNameWidget * m_pNameWidget
Definition MixerLine.h:157
void nameSelected()
float m_fMaxPeak
Definition MixerLine.h:152
Fader * m_pFader
Definition MixerLine.h:155
void nameClicked()
void setPeak_L(float peak)
void updateMixerLine()
uint m_nActivity
Definition MixerLine.h:150
void volumeChanged(MixerLine *ref)
LED * m_pSelectionLED
Definition MixerLine.h:162
virtual void paintEvent(QPaintEvent *ev) override
void setPixmap(QString sPixmapPath, bool expand_horiz=false)
Custom rotary widget.
Definition Rotary.h:45
@ Small
No arc will be drawn.
@ Center
The arc features a point at its upmost position.
@ Normal
The arc is of solid red color.
static QString getImagePath()
Definition Skin.h:36
Base class for active user input widget, which are not based on a high-level Qt widget.
virtual void setValue(float fValue, bool bTriggeredByUserInteraction=false)
void setDefaultValue(float fDefaultValue)
void setIsActive(bool bIsActive)
float getValue() const
float getMax() const
constexpr int getPointSize(H2Core::FontTheme::FontSize fontSize) const
#define MAX_FX
Maximum number of effects.
Definition config.dox:83
#define UNUSED(v)
Definition Globals.h:42