ladspa_port_dialog.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include "ladspa_port_dialog.h"
  25. #include <QLayout>
  26. #include <QTableWidget>
  27. #include "embed.h"
  28. #include "Engine.h"
  29. #include "Ladspa2LMMS.h"
  30. #include "Mixer.h"
  31. ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
  32. {
  33. Ladspa2LMMS * manager = Engine::getLADSPAManager();
  34. setWindowIcon( embed::getIconPixmap( "ports" ) );
  35. setWindowTitle( tr( "Ports" ) );
  36. setModal( true );
  37. QVBoxLayout * vlayout = new QVBoxLayout( this );
  38. vlayout->setSpacing( 0 );
  39. vlayout->setMargin( 0 );
  40. int pc = manager->getPortCount( _key );
  41. QTableWidget * settings = new QTableWidget( pc, 7, this );
  42. QStringList ports;
  43. ports.append( tr( "Name" ) );
  44. ports.append( tr( "Rate" ) );
  45. ports.append( tr( "Direction" ) );
  46. ports.append( tr( "Type" ) );
  47. ports.append( tr( "Min < Default < Max" ) );
  48. ports.append( tr( "Logarithmic" ) );
  49. ports.append( tr( "SR Dependent" ) );
  50. settings->setHorizontalHeaderLabels( ports );
  51. for( int row = 0; row < pc; row++ )
  52. {
  53. for( int col = 0; col < 7; ++col )
  54. {
  55. QTableWidgetItem * item = new QTableWidgetItem;
  56. item->setFlags(QFlag(0));
  57. settings->setItem( row, col, item );
  58. }
  59. int col = 0;
  60. settings->item( row, col++ )->setText( manager->getPortName( _key, row ) );
  61. settings->item( row, col++ )->setText( manager->isPortAudio( _key, row ) ? tr( "Audio" ) : tr( "Control" ) );
  62. settings->item( row, col++ )->setText( manager->isPortInput( _key, row ) ? tr( "Input" ) : tr( "Output" ) );
  63. settings->item( row, col++ )->setText( manager->isPortToggled( _key, row ) ? tr( "Toggled" ) : manager->isInteger( _key, row ) ? tr( "Integer" ) : tr( "Float" ) );
  64. float min = manager->getLowerBound( _key, row );
  65. float max = manager->getUpperBound( _key, row );
  66. float def = manager->getDefaultSetting( _key, row );
  67. QString range = "";
  68. if( manager->areHintsSampleRateDependent( _key, row ) )
  69. {
  70. if( min != NOHINT )
  71. {
  72. min *= Engine::mixer()->processingSampleRate();
  73. }
  74. if( max != NOHINT )
  75. {
  76. max *= Engine::mixer()->processingSampleRate();
  77. }
  78. }
  79. if( min == NOHINT )
  80. {
  81. range += "-Inf < ";
  82. }
  83. else if( manager->isInteger( _key, row ) )
  84. {
  85. range += QString::number( static_cast<int>( min ) ) +
  86. " < ";
  87. }
  88. else
  89. {
  90. range += QString::number( min ) + " < ";
  91. }
  92. if( def == NOHINT )
  93. {
  94. range += "None < ";
  95. }
  96. else if( manager->isInteger( _key, row ) )
  97. {
  98. range += QString::number( static_cast<int>( def ) ) +
  99. " < ";
  100. }
  101. else
  102. {
  103. range += QString::number( def ) + " < ";
  104. }
  105. if( max == NOHINT )
  106. {
  107. range += "Inf";
  108. }
  109. else if( manager->isInteger( _key, row ) )
  110. {
  111. range += QString::number( static_cast<int>( max ) );
  112. }
  113. else
  114. {
  115. range += QString::number( max );
  116. }
  117. if( manager->isPortOutput( _key, row ) ||
  118. manager->isPortToggled( _key, row ) )
  119. {
  120. range = "";
  121. }
  122. settings->item( row, col++ )->setText( range );
  123. if( manager->isLogarithmic( _key, row ) )
  124. {
  125. settings->item( row, col )->setText( tr( "Yes" ) );
  126. }
  127. col++;
  128. if( manager->areHintsSampleRateDependent( _key, row ) )
  129. {
  130. settings->item( row, col )->setText( tr( "Yes" ) );
  131. }
  132. }
  133. vlayout->addWidget( settings );
  134. show();
  135. }
  136. ladspaPortDialog::~ladspaPortDialog()
  137. {
  138. }