hydrogen 1.2.3
MixerSettingsDialog.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 <cstring>
24
25#include "MixerSettingsDialog.h"
26#include "HydrogenApp.h"
27#include "MainForm.h"
28
29#include "qmessagebox.h"
30#include "qstylefactory.h"
31
32#include <QPixmap>
33#include <QFontDialog>
34
35#include <core/MidiMap.h>
36#include <core/Hydrogen.h>
43
44
45using namespace H2Core;
46
48 : QDialog( parent )
49 {
50 setupUi( this );
51
52 setWindowTitle( tr( "Mixer Settings" ) );
53
54 setMinimumSize( width(), height() );
55
56 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
57
58 /* insert the items here so they work consistently no matter of their order in the menu (except the headings)
59 */
60
61 // heading
62 panLawComboBox->addItem( tr("------ Linear pan parameter ------"), QVariant( -10000 ) );
63 qobject_cast< QStandardItemModel * >( panLawComboBox->model() )->item( 0 )->setEnabled( false );
64 panLawComboBox->addItem( tr("Balance Law (0dB)"), QVariant( Sampler::LINEAR_STRAIGHT_POLYGONAL ) );
65 panLawComboBox->addItem( tr("Constant Power (-3dB)"), QVariant( Sampler::LINEAR_CONST_POWER ) );
66 panLawComboBox->addItem( tr("Constant Sum (-6dB)"), QVariant( Sampler::LINEAR_CONST_SUM ) );
67 panLawComboBox->addItem( tr("Constant k-Norm (Custom dB compensation)"),
68 QVariant( Sampler::LINEAR_CONST_K_NORM ) );
69 panLawComboBox->insertSeparator(100);
70
71 // heading
72 panLawComboBox->addItem( tr("------ Polar pan parameter ------"), QVariant( -10000 ) );
73 qobject_cast< QStandardItemModel * >( panLawComboBox->model() )->item( 6 )->setEnabled( false );
74 panLawComboBox->addItem( tr("Balance Law (0dB)"), QVariant( Sampler::POLAR_STRAIGHT_POLYGONAL ) );
75 panLawComboBox->addItem( tr("Constant Power (-3dB)"), QVariant( Sampler::POLAR_CONST_POWER ) );
76 panLawComboBox->addItem( tr("Constant Sum (-6dB)"), QVariant( Sampler::POLAR_CONST_SUM ) );
77 panLawComboBox->addItem( tr("Constant k-Norm (Custom dB compensation)"),
78 QVariant( Sampler::POLAR_CONST_K_NORM ) );
79 panLawComboBox->insertSeparator(100);
80
81 // heading
82 panLawComboBox->addItem( tr("------ Ratio pan parameter ------"), QVariant( -10000 ) );
83 qobject_cast< QStandardItemModel * >( panLawComboBox->model() )->item( 12 )->setEnabled( false );
84 panLawComboBox->addItem( tr("Balance Law (0dB)"), QVariant( Sampler::RATIO_STRAIGHT_POLYGONAL ) );
85 panLawComboBox->addItem( tr("Constant Power (-3dB)"), QVariant( Sampler::RATIO_CONST_POWER ) );
86 panLawComboBox->addItem( tr("Constant Sum (-6dB)"), QVariant( Sampler::RATIO_CONST_SUM ) );
87 panLawComboBox->addItem( tr("Constant k-Norm (Custom dB compensation)"),
88 QVariant( Sampler::RATIO_CONST_K_NORM ) );
89 panLawComboBox->insertSeparator(100);
90
91 // heading
92 panLawComboBox->addItem( tr("------ Quadratic pan parameter ------"), QVariant( -10000 ) );
93 qobject_cast< QStandardItemModel * >( panLawComboBox->model() )->item( 18 )->setEnabled( false );
94 panLawComboBox->addItem( tr("Balance Law (0dB)"), QVariant( Sampler::QUADRATIC_STRAIGHT_POLYGONAL ) );
95 panLawComboBox->addItem( tr("Constant Power (-3dB)"), QVariant( Sampler::QUADRATIC_CONST_POWER ) );
96 panLawComboBox->addItem( tr("Constant Sum (-6dB)"), QVariant( Sampler::QUADRATIC_CONST_SUM ) );
97 panLawComboBox->addItem( tr("Constant k-Norm (Custom dB compensation)"),
99
100 panLawComboBox->setCurrentIndex( panLawComboBox->findData( pSong->getPanLawType() ) );
101 panLawChanged(); // to hide custom dB SPL compensation
102 panLawComboBox->setToolTip( tr("Relationship between the sound's apparent image position and the pan knob control"
103 ) );
104
105 connect(panLawComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT( panLawChanged() ));
106
110 QValidator *validator = new QDoubleValidator( -10000., 0., 20, this );
111 dBCompensationLineEdit->setValidator( validator );
112 dBCompensationLineEdit->setText( QString( "%1" ).arg( -6.0206 / pSong->getPanLawKNorm() ) );
113
114 adjustSize();
115 setFixedSize( width(), height() );
116}
117
118
119
120
122{
123 INFOLOG("~MIXER_SETTINGS_DIALOG");
124}
125
126
127
129{
130 reject();
131}
132
133
135 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
136 bool bOk;
137
138 // Pan Law settings
139 pSong->setPanLawType( ( panLawComboBox->currentData() ).toInt( &bOk ) );
140
141 // allowing both point or comma decimal separator
142 float fdBCenterCompensation = ( dBCompensationLineEdit->text() ).replace( ",", "." ).toFloat( &bOk );
143 if ( !bOk ) { // this should not happen
144 QMessageBox::information( this, "Hydrogen", tr( "dB Center Compensation rejected" ) );
145 return;
146 } else if ( fdBCenterCompensation > -0.01 ) {
150 QMessageBox::information( this, "Hydrogen", tr( "dB Center Compensation must be less than -0.01" ) );
151 return;
152 }
156 pSong->setPanLawKNorm( - 6.0206 / fdBCenterCompensation );
157
159
160 accept();
161}
162
163void MixerSettingsDialog::panLawChanged(){ // hide/show some widgets
164 bool bOk;
165 int nPanLawType = ( panLawComboBox->currentData() ).toInt( &bOk);
166 if ( nPanLawType == Sampler::LINEAR_CONST_K_NORM
167 || nPanLawType == Sampler::POLAR_CONST_K_NORM
168 || nPanLawType == Sampler::RATIO_CONST_K_NORM
169 || nPanLawType == Sampler::QUADRATIC_CONST_K_NORM
170 )
171 {
172 dBCompensationLineEdit->show();
173 dBCompensationLbl->show();
174 } else {
175 dBCompensationLineEdit->hide();
176 dBCompensationLbl->hide();
177 }
178}
#define INFOLOG(x)
Definition Object.h:237
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
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
@ QUADRATIC_CONST_K_NORM
Definition Sampler.h:120
@ LINEAR_STRAIGHT_POLYGONAL
Definition Sampler.h:108
@ RATIO_STRAIGHT_POLYGONAL
Definition Sampler.h:105
@ POLAR_STRAIGHT_POLYGONAL
Definition Sampler.h:111
@ QUADRATIC_CONST_POWER
Definition Sampler.h:115
@ QUADRATIC_STRAIGHT_POLYGONAL
Definition Sampler.h:114
MixerSettingsDialog(QWidget *parent)