hydrogen 1.2.6
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-2025 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
46using namespace H2Core;
47
48MixerLine::MixerLine(QWidget* parent, int nInstr)
49 : PixmapWidget( parent )
50{
51
52 m_fMaxPeak = 0.0;
53 m_nActivity = 0;
54 m_bIsSelected = false;
55 m_nPeakTimer = 0;
56
57 std::shared_ptr<Action> pAction;
58
59 resize( nWidth, nHeight );
60 setFixedSize( nWidth, nHeight );
61
62 setPixmap( "/mixerPanel/mixerline_background.png" );
63
64 // Play sample button
65 m_pPlaySampleBtn = new Button( this, QSize( 20, 15 ), Button::Type::Push, "play.svg", "", false, QSize( 7, 7 ), tr( "Play sample" ) );
66 m_pPlaySampleBtn->move( 6, 1 );
67 m_pPlaySampleBtn->setObjectName( "PlaySampleButton" );
68 connect(m_pPlaySampleBtn, &Button::clicked,
69 [&]() { emit noteOnClicked(this); });
71 [&]() { emit noteOffClicked(this); });
72
73 // Trigger sample LED
74 m_pTriggerSampleLED = new LED( this, QSize( 5, 13 ) );
75 m_pTriggerSampleLED->move( 26, 2 );
76 m_pTriggerSampleLED->setObjectName( "TriggerSampleLED" );
77
78 // LED indicating that this particular mixerline is selected
79 m_pSelectionLED = new LED( this, QSize( 11, 9 ) );
80 m_pSelectionLED->move( 39, 2 );
81 m_pSelectionLED->setObjectName( "SelectionLED" );
82
83 // Mute button
84
85 m_pMuteBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallMuteButton(), true, QSize(), tr( "Mute" ) );
86 m_pMuteBtn->move( 5, 16 );
87 m_pMuteBtn->setObjectName( "MixerMuteButton" );
88 connect(m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteBtnClicked() ));
89 pAction = std::make_shared<Action>("STRIP_MUTE_TOGGLE");
90 pAction->setParameter1( QString::number(nInstr ));
91 m_pMuteBtn->setAction(pAction);
92
93 // Solo button
94 m_pSoloBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallSoloButton(), false, QSize(), tr( "Solo" ) );
95 m_pSoloBtn->move( 28, 16 );
96 m_pSoloBtn->setObjectName( "MixerSoloButton" );
97 connect(m_pSoloBtn, SIGNAL( clicked() ), this, SLOT( soloBtnClicked() ));
98 pAction = std::make_shared<Action>("STRIP_SOLO_TOGGLE");
99 pAction->setParameter1( QString::number(nInstr ));
100 m_pSoloBtn->setAction(pAction);
101
102 // pan rotary
103 m_pPanRotary = new Rotary( this, Rotary::Type::Center, tr( "Pan" ), false, -1.0, 1.0 );
104 m_pPanRotary->setObjectName( "PanRotary" );
105 m_pPanRotary->move( 6, 32 );
106 connect( m_pPanRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( panChanged( WidgetWithInput* ) ) );
107 pAction = std::make_shared<Action>("PAN_ABSOLUTE");
108 pAction->setParameter1( QString::number(nInstr ));
109 pAction->setValue( QString::number( 0 ));
110 m_pPanRotary->setAction(pAction);
111
112 // FX send
113 uint y = 0;
114 for ( uint i = 0; i < MAX_FX; i++ ) {
115 m_pFxRotary[i] = new Rotary( this, Rotary::Type::Small, tr( "FX %1 send" ).arg( i + 1 ), false );
116 m_pFxRotary[i]->setObjectName( "FXRotary" );
117 pAction = std::make_shared<Action>( "EFFECT_LEVEL_ABSOLUTE" );
118 pAction->setParameter1( QString::number( nInstr ) );
119 pAction->setParameter2( QString::number( i ) );
120 m_pFxRotary[i]->setAction( pAction );
121 if ( (i % 2) == 0 ) {
122 m_pFxRotary[i]->move( 9, 63 + (20 * y) );
123 }
124 else {
125 m_pFxRotary[i]->move( 30, 63 + (20 * y) );
126 y++;
127 }
128 connect( m_pFxRotary[i], SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( knobChanged( WidgetWithInput* ) ) );
129 }
130
132
133 float fFalloffTemp = pPref->getMixerFalloffSpeed();
134 fFalloffTemp = (fFalloffTemp * 20) - 2;
135 m_nFalloff = (int)fFalloffTemp;
136
137 QPixmap textBackground;
138 bool ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
139 if( ok == false ){
140 ERRORLOG( "Error loading pixmap" );
141 }
142
143 // instrument name widget
145 m_pNameWidget->move( 6, 128 );
146 connect( m_pNameWidget, SIGNAL( doubleClicked () ), this, SLOT( nameClicked() ) );
147 connect( m_pNameWidget, SIGNAL( clicked () ), this, SLOT( nameSelected() ) );
148
149 // m_pFader
150 m_pFader = new Fader( this, Fader::Type::Normal, tr( "Volume" ), false, false, 0.0, 1.5 );
151 m_pFader->move( 23, 128 );
152 connect( m_pFader, SIGNAL( valueChanged( WidgetWithInput* ) ),
153 this, SLOT( faderChanged( WidgetWithInput* ) ) );
154
155 pAction = std::make_shared<Action>("STRIP_VOLUME_ABSOLUTE");
156 pAction->setParameter1( QString::number(nInstr) );
157 m_pFader->setAction( pAction );
158
159
160 m_pPeakLCD = new LCDDisplay( this, QSize( 41, 19 ), false, false );
161 m_pPeakLCD->move( 8, 105 );
162 m_pPeakLCD->setText( "0.00" );
163 m_pPeakLCD->setToolTip( tr( "Peak" ) );
164 QPalette lcdPalette;
165 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
166 m_pPeakLCD->setPalette( lcdPalette );
167}
168
171
173{
174 if ( m_nPeakTimer > m_nFalloff ) {
175 if ( m_fMaxPeak > 0.05f ) {
176 m_fMaxPeak = m_fMaxPeak - 0.05f;
177 }
178 else {
179 m_fMaxPeak = 0.0f;
180 m_nPeakTimer = 0;
181 }
182 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
183 if ( m_fMaxPeak > 1.0 ) {
184 m_pPeakLCD->setUseRedFont( true );
185 }
186 else {
187 m_pPeakLCD->setUseRedFont( false );
188 }
189 }
190 m_nPeakTimer++;
191}
192
197
202
204
205 assert( pRef );
206
208 emit volumeChanged(this);
209
210 WidgetWithInput* pFader = static_cast<Fader*>( pRef );
211
212 double value = (double) pFader->getValue();
213
214 QString sMessage = tr( "Set volume [%1] of instrument" )
215 .arg( value, 0, 'f', 2 );
216 sMessage.append( QString( " [%1]" )
217 .arg( m_pNameWidget->text() ) );
218 QString sCaller = QString( "%1:faderChanged:%2" )
219 .arg( class_name() ).arg( m_pNameWidget->text() );
220
222 showStatusBarMessage( sMessage, sCaller );
223}
224
226 return ( ( m_pMuteBtn->isChecked() && ! m_pMuteBtn->isDown() ) ||
227 ( ! m_pMuteBtn->isChecked() && m_pMuteBtn->isDown() ) );
228}
229
230void MixerLine::setMuteClicked(bool isClicked) {
231 if ( ! m_pMuteBtn->isDown() ) {
232 m_pMuteBtn->setChecked(isClicked);
233 }
234}
235
237 return ( ( m_pSoloBtn->isChecked() && ! m_pSoloBtn->isDown() ) || ( ! m_pSoloBtn->isChecked() && m_pSoloBtn->isDown() ) );
238}
239
240void MixerLine::setSoloClicked(bool isClicked) {
241 if ( ! m_pSoloBtn->isDown() ) {
242 m_pSoloBtn->setChecked(isClicked);
243 }
244}
245
247{
248 return m_pFader->getValue();
249}
250
251void MixerLine::setVolume( float value ) {
252 m_pFader->setValue( value );
253}
254
255void MixerLine::setPeak_L( float peak ) {
256 if (peak != getPeak_L() ) {
257 m_pFader->setPeak_L( peak );
258 if (peak > m_fMaxPeak) {
259 if ( peak < 0.1f ) {
260 peak = 0.0f;
261 }
262 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
263 if ( peak > 1.0 ) {
264 m_pPeakLCD->setUseRedFont( true );
265 }
266 else {
267 m_pPeakLCD->setUseRedFont( false );
268 }
269 m_fMaxPeak = peak;
270 m_nPeakTimer = 0;
271 }
272 }
273}
274
276 return m_pFader->getPeak_L();
277}
278
279void MixerLine::setPeak_R( float peak ) {
280 if (peak != getPeak_R() ) {
281 m_pFader->setPeak_R( peak );
282 if (peak > m_fMaxPeak) {
283 if ( peak < 0.1f ) {
284 peak = 0.0f;
285 }
286 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
287 if ( peak > 1.0 ) {
288 m_pPeakLCD->setUseRedFont( true );
289 }
290 else {
291 m_pPeakLCD->setUseRedFont( false );
292 }
293 m_fMaxPeak = peak;
294 m_nPeakTimer = 0;
295 }
296 }
297}
298
300 return m_pFader->getPeak_R();
301}
302
304 emit instrumentNameClicked(this);
305}
306
310
312{
313 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
314 emit panChanged( this );
319}
320
322{
323 return m_pPanRotary->getValue();
324}
325
326void MixerLine::setPan(float fValue)
327{
328 if ( fValue != m_pPanRotary->getValue() ) {
329 m_pPanRotary->setValue( fValue );
334 }
335}
336
337void MixerLine::setPlayClicked( bool clicked ) {
338 m_pTriggerSampleLED->setActivated( clicked );
339}
340
342{
343 assert( pRef );
344 Rotary* pRotary = static_cast<Rotary*>( pRef );
345
346 for ( uint i = 0; i < MAX_FX; i++ ) {
347 if ( m_pFxRotary[i] == pRotary ) {
348 emit knobChanged( this, i );
349 break;
350 }
351 }
352}
353
354void MixerLine::setFXLevel( uint nFX, float fValue )
355{
356 if (nFX >= MAX_FX) {
357 ERRORLOG( QString("[setFXLevel] nFX >= MAX_FX (nFX=%1)").arg(nFX) );
358 return;
359 }
360 m_pFxRotary[nFX]->setValue( fValue );
361}
362
364{
365 if (nFX >= MAX_FX) {
366 ERRORLOG( QString("[setFXLevel] nFX >= MAX_FX (nFX=%1)").arg(nFX) );
367 return 0.0f;
368 }
369 return m_pFxRotary[nFX]->getValue();
370}
371
372void MixerLine::setSelected( bool bIsSelected )
373{
374 if ( m_bIsSelected == bIsSelected ) {
375 return;
376 }
377
378 m_bIsSelected = bIsSelected;
379 m_pSelectionLED->setActivated( bIsSelected );
380}
381
382// ::::::::::::::::::::::::::::
383
384
385ComponentMixerLine::ComponentMixerLine(QWidget* parent, int CompoID)
386 : PixmapWidget( parent )
387{
388//
389
390 m_nComponentID = CompoID;
391
392 m_fMaxPeak = 0.0;
393 m_nActivity = 0;
394 m_bIsSelected = false;
395 m_nPeakTimer = 0;
396
397 resize( nWidth, nHeight );
398 setFixedSize( nWidth, nHeight );
399
400 setPixmap( "/mixerPanel/componentmixerline_background.png" );
401
402 // Mute button
403 m_pMuteBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallMuteButton(), true, QSize(), tr( "Mute" ) );
404 m_pMuteBtn->move( 5, 16 );
405 connect(m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteBtnClicked() ));
406
407 // Solo button
408 m_pSoloBtn = new Button( this, QSize( 22, 15 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSmallSoloButton(), false, QSize(), tr( "Solo" ) );
409 m_pSoloBtn->move( 28, 16 );
410 connect(m_pSoloBtn, SIGNAL( clicked() ), this, SLOT( soloBtnClicked() ));
411
413
414 float fFalloffTemp = pPref->getMixerFalloffSpeed();
415 fFalloffTemp = (fFalloffTemp * 20) - 2;
416 m_nFalloff = (int)fFalloffTemp;
417
418 QPixmap textBackground;
419 bool ok = textBackground.load( Skin::getImagePath() + "/mixerPanel/mixerline_text_background.png" );
420 if( ok == false ){
421 ERRORLOG( "Error loading pixmap" );
422 }
423
424 // instrument name widget
426 m_pNameWidget->move( 6, 128 );
427 m_pNameWidget->setToolTip( tr( "Component name" ) );
428
429 // m_pFader
430 m_pFader = new Fader( this, Fader::Type::Normal, tr( "Volume" ), false, false, 0.0, 1.5 );
431 m_pFader->move( 23, 128 );
432 connect( m_pFader, SIGNAL( valueChanged( WidgetWithInput* ) ),
433 this, SLOT( faderChanged( WidgetWithInput* ) ) );
434
435 //pAction = new MidiAction("STRIP_VOLUME_ABSOLUTE");
436 //pAction->setParameter1( QString::number(nInstr) );
437 //m_pFader->setAction( pAction );
438
439
440 m_pPeakLCD = new LCDDisplay( this, QSize( 41, 19 ), false, false );
441 m_pPeakLCD->move( 8, 105 );
442 m_pPeakLCD->setText( "0.00" );
443 m_pPeakLCD->setToolTip( tr( "Peak" ) );
444 QPalette lcdPalette;
445 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
446 m_pPeakLCD->setPalette( lcdPalette );
447}
448
449
450
453
455{
456 if ( m_nPeakTimer > m_nFalloff ) {
457 if ( m_fMaxPeak > 0.05f ) {
458 m_fMaxPeak = m_fMaxPeak - 0.05f;
459 }
460 else {
461 m_fMaxPeak = 0.0f;
462 m_nPeakTimer = 0;
463 }
464 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
465 if ( m_fMaxPeak > 1.0 ) {
466 m_pPeakLCD->setUseRedFont( true );
467 }
468 else {
469 m_pPeakLCD->setUseRedFont( false );
470 }
471 }
472 m_nPeakTimer++;
473}
474
478
482
484
485 assert( pRef );
486
488 emit volumeChanged(this);
489
490 WidgetWithInput* pFader = static_cast<Fader*>( pRef );
491 double value = (double) pFader->getValue();
492
493 QString sMessage = tr( "Set volume [%1] of component" )
494 .arg( value, 0, 'f', 2 );
495 sMessage.append( QString( " [%1]" )
496 .arg( m_pNameWidget->text() ) );
497 QString sCaller = QString( "%1:faderChanged:%2" )
498 .arg( class_name() ).arg( m_pNameWidget->text() );
499
501 showStatusBarMessage( sMessage, sCaller );
502}
503
505 return ( ( m_pMuteBtn->isChecked() && ! m_pMuteBtn->isDown() ) ||
506 ( ! m_pMuteBtn->isChecked() && m_pMuteBtn->isDown() ) );
507}
508
510 if ( ! m_pMuteBtn->isDown() ) {
511 m_pMuteBtn->setChecked(isClicked);
512 }
513}
514
516 return ( ( m_pSoloBtn->isChecked() && ! m_pSoloBtn->isDown() ) || ( ! m_pSoloBtn->isChecked() && m_pSoloBtn->isDown() ) );
517}
518
520 if ( ! m_pSoloBtn->isDown() ) {
521 m_pSoloBtn->setChecked(isClicked);
522 }
523}
524
526{
527 return m_pFader->getValue();
528}
529
530void ComponentMixerLine::setVolume( float value ) {
531 m_pFader->setValue( value );
532}
533
535 if (peak != getPeak_L() ) {
536 m_pFader->setPeak_L( peak );
537 if (peak > m_fMaxPeak) {
538 if ( peak < 0.1f ) {
539 peak = 0.0f;
540 }
541 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
542 if ( peak > 1.0 ) {
543 m_pPeakLCD->setUseRedFont( true );
544 }
545 else {
546 m_pPeakLCD->setUseRedFont( false );
547 }
548 m_fMaxPeak = peak;
549 m_nPeakTimer = 0;
550 }
551 }
552}
553
555 return m_pFader->getPeak_L();
556}
557
559 if (peak != getPeak_R() ) {
560 m_pFader->setPeak_R( peak );
561 if (peak > m_fMaxPeak) {
562 if ( peak < 0.1f ) {
563 peak = 0.0f;
564 }
565 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
566 if ( peak > 1.0 ) {
567 m_pPeakLCD->setUseRedFont( true );
568 }
569 else {
570 m_pPeakLCD->setUseRedFont( false );
571 }
572 m_fMaxPeak = peak;
573 m_nPeakTimer = 0;
574 }
575 }
576}
577
579 return m_pFader->getPeak_R();
580}
581
582
583// ::::::::::::::::::::::::::::
584
586 : PixmapWidget( parent )
587{
588 m_fMaxPeak = 0.0f;
589 m_nPeakTimer = 0;
590
591 setMinimumSize( nWidth, nHeight );
592 setMaximumSize( nWidth, nHeight );
593 resize( nWidth, nHeight );
594 QPalette defaultPalette;
595 defaultPalette.setColor( QPalette::Window, QColor( 58, 62, 72 ) );
596 this->setPalette( defaultPalette );
597
598 // Background image
599 setPixmap( "/mixerPanel/masterMixerline_background.png" );
600
602
603 float fFalloffTemp = pPref->getMixerFalloffSpeed();
604 fFalloffTemp = (fFalloffTemp * 20) - 2;
605 m_nFalloff = (int)fFalloffTemp;
606
607 m_pMasterFader = new Fader( this, Fader::Type::Master, tr( "Master volume" ), false, false, 0.0, 1.5 );
608 m_pMasterFader->move( 24, 75 );
609 connect( m_pMasterFader, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( faderChanged( WidgetWithInput* ) ) );
610
611 std::shared_ptr<Action> pAction = std::make_shared<Action>("MASTER_VOLUME_ABSOLUTE");
612 m_pMasterFader->setAction( pAction );
613
614 m_pPeakLCD = new LCDDisplay( this, QSize( 38, 18 ), false, false );
615 m_pPeakLCD->move( 22, 51 );
616 m_pPeakLCD->setText( "0.00" );
617 m_pPeakLCD->setToolTip( tr( "Peak" ) );
618 QPalette lcdPalette;
619 lcdPalette.setColor( QPalette::Window, QColor( 49, 53, 61 ) );
620 m_pPeakLCD->setPalette( lcdPalette );
621
622 m_pHumanizeVelocityRotary = new Rotary( this, Rotary::Type::Normal, tr( "Humanize velocity" ), false );
623 m_pHumanizeVelocityRotary->move( 66, 88 );
624 connect( m_pHumanizeVelocityRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
625
626 m_pHumanizeTimeRotary = new Rotary( this, Rotary::Type::Normal, tr( "Humanize time" ), false );
627 m_pHumanizeTimeRotary->move( 66, 125 );
628 connect( m_pHumanizeTimeRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
629
630 m_pSwingRotary = new Rotary( this, Rotary::Type::Normal, tr( "16th-note Swing" ), false );
631 m_pSwingRotary->move( 66, 162 );
632 connect( m_pSwingRotary, SIGNAL( valueChanged( WidgetWithInput* ) ), this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
633
634 // Mute btn
635 m_pMuteBtn = new Button( this, QSize( 42, 17 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getBigMuteButton(), true );
636 m_pMuteBtn->setObjectName( "MixerMasterMuteButton" );
637 m_pMuteBtn->move( 20, 31 );
638 connect( m_pMuteBtn, SIGNAL( clicked() ), this, SLOT( muteClicked() ) );
639 pAction = std::make_shared<Action>("MUTE_TOGGLE");
640 m_pMuteBtn->setAction( pAction );
641
642 m_pMasterLbl = new ClickableLabel( this, QSize( 55, 15 ), HydrogenApp::get_instance()->getCommonStrings()->getMasterLabel(), ClickableLabel::Color::Dark );
643 m_pMasterLbl->move( 14, 8 );
644 m_pHumanizeLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getHumanizeLabel(), ClickableLabel::Color::Dark );
645 m_pHumanizeLbl->move( 62, 79 );
646 m_pSwingLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getVelocityLabel(), ClickableLabel::Color::Dark );
647 m_pSwingLbl->move( 62, 116 );
648 m_pTimingLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getTimingLabel(), ClickableLabel::Color::Dark );
649 m_pTimingLbl->move( 62, 153 );
650 m_pVelocityLbl = new ClickableLabel( this, QSize( 51, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getSwingLabel(), ClickableLabel::Color::Dark );
651 m_pVelocityLbl->move( 62, 190 );
652}
653
658
663
665{
666 assert( pRef );
667
668 Fader* pFader = static_cast<Fader*>( pRef );
669 m_pMasterFader->setValue( pFader->getValue() );
670
671 emit volumeChanged(this);
672
674
675 double value = (double) pFader->getValue();
677 showStatusBarMessage( tr( "Set master volume [%1]" )
678 .arg( value, 0, 'f', 2 ),
679 QString( "%1:faderChanged" )
680 .arg( class_name() ) );
681}
682
684{
685 return m_pMasterFader->getValue();
686}
687
688void MasterMixerLine::setVolume( float value ) {
689 m_pMasterFader->setValue( value );
690}
691
693{
694 if ( peak != getPeak_L() ) {
695 m_pMasterFader->setPeak_L(peak);
696 if (peak > m_fMaxPeak) {
697 if ( peak < 0.1f ) {
698 peak = 0.0f;
699 }
700 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
701 if ( peak > 1.0 ) {
702 m_pPeakLCD->setUseRedFont( true );
703 }
704 else {
705 m_pPeakLCD->setUseRedFont( false );
706 }
707 m_fMaxPeak = peak;
708 m_nPeakTimer = 0;
709 }
710 }
711}
712
714 return m_pMasterFader->getPeak_L();
715}
716
718 if ( peak != getPeak_R() ) {
719 m_pMasterFader->setPeak_R(peak);
720 if (peak > m_fMaxPeak) {
721 if ( peak < 0.1f ) {
722 peak = 0.0f;
723 }
724 m_pPeakLCD->setText( QString( "%1" ).arg( peak, 0, 'f', 2 ) );
725 if ( peak > 1.0 ) {
726 m_pPeakLCD->setUseRedFont( true );
727 }
728 else {
729 m_pPeakLCD->setUseRedFont( false );
730 }
731 m_fMaxPeak = peak;
732 m_nPeakTimer = 0;
733 }
734 }
735}
736
738 return m_pMasterFader->getPeak_R();
739}
740
742{
743
744 if ( m_nPeakTimer > m_nFalloff ) {
745 if ( m_fMaxPeak > 0.05f ) {
746 m_fMaxPeak = m_fMaxPeak - 0.05f;
747 }
748 else {
749 m_fMaxPeak = 0.0f;
750 m_nPeakTimer = 0;
751 }
752 m_pPeakLCD->setText( QString( "%1" ).arg( m_fMaxPeak, 0, 'f', 2 ) );
753 if ( m_fMaxPeak > 1.0 ) {
754 m_pPeakLCD->setUseRedFont( true );
755 }
756 else {
757 m_pPeakLCD->setUseRedFont( false );
758 }
759 }
760 m_nPeakTimer++;
761
762 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
763 if ( pSong ) {
764 m_pHumanizeTimeRotary->setValue( pSong->getHumanizeTimeValue() );
765 m_pHumanizeVelocityRotary->setValue( pSong->getHumanizeVelocityValue() );
766 m_pSwingRotary->setValue( pSong->getSwingFactor() );
767 if ( ! m_pMuteBtn->isDown() ) {
768 m_pMuteBtn->setChecked( pSong->getIsMuted() );
769 }
770 }
771 else {
772 WARNINGLOG( "pSong == NULL ");
773 }
774}
775
777{
778 assert( pRef );
779
780 Rotary* pRotary = static_cast<Rotary*>( pRef );
781
782 QString sMsg;
783 QString sCaller = QString( "%1:rotaryChanged" ).arg( class_name() );
784 double fVal = (double) pRotary->getValue();
785
786 Hydrogen *pHydrogen = Hydrogen::get_instance();
787 pHydrogen->getAudioEngine()->lock( RIGHT_HERE );
788
789 if ( pRotary == m_pHumanizeTimeRotary ) {
790 pHydrogen->getSong()->setHumanizeTimeValue( fVal );
791 sMsg = tr( "Set humanize time param [%1]" ).arg( fVal, 0, 'f', 2 ); //not too long for display
792 sCaller.append( ":humanizeTime" );
793 }
794 else if ( pRotary == m_pHumanizeVelocityRotary ) {
795 pHydrogen->getSong()->setHumanizeVelocityValue( fVal );
796 sMsg = tr( "Set humanize vel. param [%1]" ).arg( fVal, 0, 'f', 2 ); //not too long for display
797 sCaller.append( ":humanizeVelocity" );
798 }
799 else if ( pRotary == m_pSwingRotary ) {
800 pHydrogen->getSong()->setSwingFactor( fVal );
801 sMsg = tr( "Set swing factor [%1]").arg( fVal, 0, 'f', 2 );
802 sCaller.append( ":humanizeSwing" );
803 }
804 else {
805 ERRORLOG( "[knobChanged] Unhandled knob" );
806 }
807
808 pHydrogen->getAudioEngine()->unlock();
809
810 ( HydrogenApp::get_instance() )->showStatusBarMessage( sMsg, sCaller );
811}
812
813
815
817 : PixmapWidget( parent )
818{
819// infoLog( "INIT" );
820 m_nWidgetWidth = 17;
821 m_nWidgetHeight = 116;
822
824
825 setPixmap( "/mixerPanel/mixerline_label_background.png" );
826
827 this->resize( m_nWidgetWidth, m_nWidgetHeight );
828}
829
831{
832// infoLog( "DESTROY" );
833}
834
835
836
837void InstrumentNameWidget::paintEvent( QPaintEvent* ev )
838{
839
841
843
844 QPainter p( this );
845
846 QFont font( pPref->getApplicationFontFamily(), getPointSize( pPref->getFontSize() ) );
847
848 p.setPen( QColor(230, 230, 230) );
849 p.setFont( font );
850 p.rotate( -90 );
851 p.drawText( -m_nWidgetHeight + 5, 0, m_nWidgetHeight - 10, m_nWidgetWidth, Qt::AlignVCenter, m_sInstrName );
852}
853
855{
856 if (m_sInstrName != text ) {
858 update();
859 }
860}
861
863{
864 return m_sInstrName;
865}
866
868{
869 UNUSED( e );
870 emit clicked();
871}
872
874{
875 UNUSED( e );
876 emit doubleClicked();
877}
878
884
885// :::::::::::::::::::::
886
887
888
890 : PixmapWidget( parent )
891{
892 resize( 194, 43 );
893 setMinimumSize( width(), height() );
894 setMaximumSize( width(), height() );
895
896 setPixmap( "/mixerPanel/fxline_background.png" );
897
898 // active button
899 m_pBypassBtn = new Button( this, QSize( 34, 14 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getBypassButton(), true, QSize(), tr( "FX bypass") );
900 m_pBypassBtn->setObjectName( "MixerFXBypassButton" );
901 m_pBypassBtn->move( 52, 25 );
902 connect( m_pBypassBtn, SIGNAL( clicked() ), this, SLOT( bypassBtnClicked() ) );
903
904
905 // edit button
906 m_pEditBtn = new Button( this, QSize( 34, 14 ), Button::Type::Push, "", HydrogenApp::get_instance()->getCommonStrings()->getEditButton(), false, QSize(), tr( "Edit FX parameters") );
907 m_pEditBtn->setObjectName( "MixerFXEditButton" );
908 m_pEditBtn->move( 86, 25 );
909 connect( m_pEditBtn, SIGNAL( clicked() ), this, SLOT( editBtnClicked() ) );
910
911 // instrument name widget
912 m_pNameLCD = new LCDDisplay( this, QSize( 108, 15 ), false, false );
913 m_pNameLCD->move( 11, 9 );
914 m_pNameLCD->setText( "No name" );
915 m_pNameLCD->setToolTip( tr( "Ladspa FX name" ) );
916
917 // m_pRotary
918 m_pRotary = new Rotary( this, Rotary::Type::Normal, tr( "Effect return" ), false );
919 m_pRotary->setDefaultValue( m_pRotary->getMax() );
920 m_pRotary->move( 124, 4 );
921 m_pRotary->setIsActive( false );
922 connect( m_pRotary, SIGNAL( valueChanged( WidgetWithInput* ) ),
923 this, SLOT( rotaryChanged( WidgetWithInput* ) ) );
924
925 m_pReturnLbl = new ClickableLabel( this, QSize( 46, 9 ), HydrogenApp::get_instance()->getCommonStrings()->getReturnLabel(), ClickableLabel::Color::Dark );
926 m_pReturnLbl->move( 123, 30 );
927}
928
929
930
932{
933// infoLog( "DESTROY" );
934}
935
937{
938 m_pNameLCD->setText( name );
939}
940
941
946 emit editBtnClicked( this );
947}
948
950{
951 return ( ( m_pBypassBtn->isChecked() && ! m_pBypassBtn->isDown() ) ||
952 ( ! m_pBypassBtn->isChecked() && m_pBypassBtn->isDown() ) );
953}
954
956{
957 if ( ! m_pBypassBtn->isDown() ) {
958 m_pBypassBtn->setChecked( bBypassed );
959 }
960 m_pRotary->setIsActive( ! bBypassed );
961}
962
964{
965 emit volumeChanged( this );
966 UNUSED( ref );
967}
968
969void LadspaFXMixerLine::setPeaks( float fPeak_L, float fPeak_R )
970{
971 UNUSED( fPeak_L );
972 UNUSED( fPeak_R );
973}
974
975void LadspaFXMixerLine::getPeaks( float *fPeak_L, float *fPeak_R )
976{
977 UNUSED( fPeak_L );
978 UNUSED( fPeak_R );
979}
980
982{
983 return m_pRotary->getValue();
984}
985
986
988{
989 m_pRotary->setValue( value );
990}
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
Definition AudioEngine.h:61
#define WARNINGLOG(x)
Definition Object.h:241
#define ERRORLOG(x)
Definition Object.h:242
Generic Button with SVG icons or text.
Definition Button.h:60
@ Push
Button is not set checkable.
Definition Button.h:68
@ Toggle
Button is set checkable.
Definition Button.h:70
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:231
ComponentMixerLine(QWidget *parent, int CompoID)
Button * m_pSoloBtn
Definition MixerLine.h:232
void volumeChanged(ComponentMixerLine *ref)
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:233
static constexpr int nWidth
Definition MixerLine.h:203
InstrumentNameWidget * m_pNameWidget
Definition MixerLine.h:230
void setPeak_L(float peak)
static constexpr int nHeight
Definition MixerLine.h:204
Custom fader widget.
Definition Fader.h:44
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:123
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
Definition Hydrogen.h:84
AudioEngine * getAudioEngine() const
Definition Hydrogen.h:663
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
CoreActionController * getCoreActionController() const
Definition Hydrogen.h:653
Manager for User Preferences File (singleton)
Definition Preferences.h:79
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
LED identicating a user selection.
Definition LED.h:43
LCDDisplay * m_pNameLCD
Definition MixerLine.h:329
ClickableLabel * m_pReturnLbl
Definition MixerLine.h:330
void setPeaks(float fPeak_L, float fPeak_R)
Rotary * m_pRotary
Definition MixerLine.h:328
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:326
LadspaFXMixerLine(QWidget *parent)
void rotaryChanged(WidgetWithInput *ref)
Button * m_pEditBtn
Definition MixerLine.h:327
Fader * m_pMasterFader
Definition MixerLine.h:277
ClickableLabel * m_pSwingLbl
Definition MixerLine.h:281
void volumeChanged(MasterMixerLine *ref)
void faderChanged(WidgetWithInput *pRef)
ClickableLabel * m_pTimingLbl
Definition MixerLine.h:282
void setVolume(float value)
Rotary * m_pHumanizeTimeRotary
Definition MixerLine.h:288
void setPeak_R(float peak)
Button * m_pMuteBtn
Definition MixerLine.h:291
ClickableLabel * m_pVelocityLbl
Definition MixerLine.h:283
void rotaryChanged(WidgetWithInput *pRef)
ClickableLabel * m_pMasterLbl
Definition MixerLine.h:279
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:285
MasterMixerLine(QWidget *parent)
static constexpr int nWidth
Definition MixerLine.h:257
Rotary * m_pHumanizeVelocityRotary
Definition MixerLine.h:289
Rotary * m_pSwingRotary
Definition MixerLine.h:287
void setPeak_L(float peak)
static constexpr int nHeight
Definition MixerLine.h:258
ClickableLabel * m_pHumanizeLbl
Definition MixerLine.h:280
void updateMixerLine()
bool isMuteClicked()
void instrumentNameSelected(MixerLine *ref)
bool m_bIsSelected
Definition MixerLine.h:151
void setMuteClicked(bool isClicked)
Button * m_pPlaySampleBtn
Definition MixerLine.h:163
void instrumentNameClicked(MixerLine *ref)
float getPeak_L()
void muteBtnClicked()
void setSelected(bool bIsSelected)
Rotary * m_pPanRotary
Definition MixerLine.h:159
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()
MixerLine(QWidget *parent, int nInstr)
Definition MixerLine.cpp:48
float getFXLevel(uint nFX)
void soloBtnClicked()
void setPeak_R(float peak)
Button * m_pMuteBtn
Definition MixerLine.h:161
float getPeak_R()
Button * m_pSoloBtn
Definition MixerLine.h:162
uint m_nPeakTimer
Definition MixerLine.h:154
Rotary * m_pFxRotary[MAX_FX]
Definition MixerLine.h:166
LED * m_pTriggerSampleLED
Definition MixerLine.h:164
void setPan(float value)
float m_nFalloff
Definition MixerLine.h:156
LCDDisplay * m_pPeakLCD
Definition MixerLine.h:168
void knobChanged(MixerLine *ref, int nKnob)
float getVolume()
static constexpr int nWidth
Definition MixerLine.h:125
InstrumentNameWidget * m_pNameWidget
Definition MixerLine.h:160
void nameSelected()
float m_fMaxPeak
Definition MixerLine.h:155
Fader * m_pFader
Definition MixerLine.h:158
void nameClicked()
void setPeak_L(float peak)
static constexpr int nHeight
Definition MixerLine.h:126
void updateMixerLine()
uint m_nActivity
Definition MixerLine.h:153
void volumeChanged(MixerLine *ref)
LED * m_pSelectionLED
Definition MixerLine.h:165
virtual void paintEvent(QPaintEvent *ev) override
void setPixmap(QString sPixmapPath, bool expand_horiz=false)
PixmapWidget(QWidget *pParent)
Custom rotary widget.
Definition Rotary.h:45
@ Small
No arc will be drawn.
Definition Rotary.h:57
@ Center
The arc features a point at its upmost position.
Definition Rotary.h:55
@ Normal
The arc is of solid red color.
Definition Rotary.h:51
static QString getImagePath()
Definition Skin.h:36
Base class for active user input widget, which are not based on a high-level Qt widget.
float getValue() 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