1 /*
2 * ladspa_port_dialog.cpp - dialog to test a LADSPA plugin
3 *
4 * Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (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 GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25
26 #include "ladspa_port_dialog.h"
27
28 #include <QLayout>
29 #include <QTableWidget>
30
31 #include "embed.h"
32 #include "Engine.h"
33 #include "Ladspa2LMMS.h"
34 #include "Mixer.h"
35
36
ladspaPortDialog(const ladspa_key_t & _key)37 ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
38 {
39 Ladspa2LMMS * manager = Engine::getLADSPAManager();
40
41 setWindowIcon( embed::getIconPixmap( "ports" ) );
42 setWindowTitle( tr( "Ports" ) );
43 setModal( true );
44
45 QVBoxLayout * vlayout = new QVBoxLayout( this );
46 vlayout->setSpacing( 0 );
47 vlayout->setMargin( 0 );
48
49 int pc = manager->getPortCount( _key );
50
51 QTableWidget * settings = new QTableWidget( pc, 7, this );
52
53 QStringList ports;
54 ports.append( tr( "Name" ) );
55 ports.append( tr( "Rate" ) );
56 ports.append( tr( "Direction" ) );
57 ports.append( tr( "Type" ) );
58 ports.append( tr( "Min < Default < Max" ) );
59 ports.append( tr( "Logarithmic" ) );
60 ports.append( tr( "SR Dependent" ) );
61 settings->setHorizontalHeaderLabels( ports );
62
63 for( int row = 0; row < pc; row++ )
64 {
65 for( int col = 0; col < 7; ++col )
66 {
67 QTableWidgetItem * item = new QTableWidgetItem;
68 item->setFlags( 0 );
69 settings->setItem( row, col, item );
70 }
71
72 int col = 0;
73 settings->item( row, col++ )->setText( manager->getPortName( _key, row ) );
74
75 settings->item( row, col++ )->setText( manager->isPortAudio( _key, row ) ? tr( "Audio" ) : tr( "Control" ) );
76
77 settings->item( row, col++ )->setText( manager->isPortInput( _key, row ) ? tr( "Input" ) : tr( "Output" ) );
78
79 settings->item( row, col++ )->setText( manager->isPortToggled( _key, row ) ? tr( "Toggled" ) : manager->isInteger( _key, row ) ? tr( "Integer" ) : tr( "Float" ) );
80
81 float min = manager->getLowerBound( _key, row );
82 float max = manager->getUpperBound( _key, row );
83 float def = manager->getDefaultSetting( _key, row );
84 QString range = "";
85
86 if( manager->areHintsSampleRateDependent( _key, row ) )
87 {
88 if( min != NOHINT )
89 {
90 min *= Engine::mixer()->processingSampleRate();
91 }
92 if( max != NOHINT )
93 {
94 max *= Engine::mixer()->processingSampleRate();
95 }
96 }
97
98 if( min == NOHINT )
99 {
100 range += "-Inf < ";
101 }
102 else if( manager->isInteger( _key, row ) )
103 {
104 range += QString::number( static_cast<int>( min ) ) +
105 " < ";
106 }
107 else
108 {
109 range += QString::number( min ) + " < ";
110 }
111
112 if( def == NOHINT )
113 {
114 range += "None < ";
115 }
116 else if( manager->isInteger( _key, row ) )
117 {
118 range += QString::number( static_cast<int>( def ) ) +
119 " < ";
120 }
121 else
122 {
123 range += QString::number( def ) + " < ";
124 }
125
126 if( max == NOHINT )
127 {
128 range += "Inf";
129 }
130 else if( manager->isInteger( _key, row ) )
131 {
132 range += QString::number( static_cast<int>( max ) );
133 }
134 else
135 {
136 range += QString::number( max );
137 }
138
139 if( manager->isPortOutput( _key, row ) ||
140 manager->isPortToggled( _key, row ) )
141 {
142 range = "";
143 }
144
145 settings->item( row, col++ )->setText( range );
146
147 if( manager->isLogarithmic( _key, row ) )
148 {
149 settings->item( row, col )->setText( tr( "Yes" ) );
150 }
151 col++;
152
153 if( manager->areHintsSampleRateDependent( _key, row ) )
154 {
155 settings->item( row, col )->setText( tr( "Yes" ) );
156 }
157 }
158
159
160 vlayout->addWidget( settings );
161
162 show();
163 }
164
165
166
167
~ladspaPortDialog()168 ladspaPortDialog::~ladspaPortDialog()
169 {
170 }
171
172
173
174
175
176