mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-15 01:48:08 -05:00
* clang-tidy: Apply cppcoreguidelines-init-variables everywhere (treating NaNs as zeros) * Initialize msec and tick outside switch * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Use initialization with = * Use tabs * Use static_cast * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Do not use tabs for alignment in src/core/DrumSynth.cpp Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com> * Move x variable inside loop * Use ternary operator for b variable * Revert "Use tabs" This reverts commit 07afd8a83f58b539c3673310b2aad4b63c9198a0. * Remove unnecessary variables in XpressiveView * Simplify initialization in Plugin * Combine declaration and initialization in EqCurve * Combine declaration and initialization in Song * Combine declaration and initialization in AudioAlsa * Combine declaration and initialization in EqCurve (again) * Missed some * Undo changes made to non-LMMS files * Undo indentation changes in SidInstrument.cpp * Combine declaration with assignment in IoHelper * Combine declaration with assignment using auto in Carla * Combine declaration with assignment * Combine declaration with assignment in BasicFilters * Simplify assignments in AudioFileProcessorWaveView::zoom * Simplify out sample variable in BitInvader * Remove sampleLength variable in DelayEffect * Move gain variable in DynamicsProcessor * Combine peak variable declaration with assignment in EqSpectrumView * Move left/right lfo variables in for loop in FlangerEffect * Use ternary operator for group variable in LadspaControlDialog * Combine declaration with assignment in Lb302 * Combine declaration with assignment in MidiExport * Combine declaration with assignment in MidiFile * Combine declaration with assignment in MidiImport * Use ternary operator for vel_adjusted variable in OpulenZ * Move tmpL and dcblkL variables in for loop in ReverbSC * Combine declaration with initialization in SlicerT * Combine declaration with assignment in SaSpectrumView * Combine declaration with assignment in SaWaterfallView * Combine declaration with assignment in StereoEnhancerEffect * Combine declaration with assignment in VibratingString * Combine declaration with assignment in VstEffectControls * Combine declaration with assignment in Xpressive * Combine declaration with assignment in AutomatableModel * Combine declaration with assignment in AutomationClip * Move sample variable in for loop in BandLimitedWave * Combine declaration with assignment in DataFile * Combine declaration with assignment in DrumSynth * Combine declaration with assignment in Effect * Remove redundant assignment to nphsLeft in InstrumentPlayHandle * Combine declaration with assignment in LadspaManager * Combine declaration with assignment in LinkedModelGroups * Combine declaration with assignment in MemoryHelper * Combine declaration with assignment in AudioAlsa * Combine declaration with assignment in AudioFileOgg * Combine declaration with assignment in AudioPortAudio * Combine declaration with assignment in AudioSoundIo * Combine declaration with assignment in Lv2Evbuf * Combine declaration with assignment in Lv2Proc * Combine declaration with assignment in main * Combine declaration with assignment in MidiAlsaRaw * Combine declaration with assignment in MidiAlsaSeq * Combine declaration with assignment in MidiController * Combine declaration with assignment in MidiJack * Combine declaration with assignment in MidiSndio * Combine declaration with assignment in ControlLayout * Combine declaration with assignment in MainWindow * Combine declaration with assignment in ProjectNotes * Use ternary operator for nextValue variable in AutomationClipView * Combine declaration with assignment in AutomationEditor * Move length variable in for-loop in PianoRoll * Combine declaration with assignment in ControllerConnectionDialog * Combine declaration with assignment in Graph * Combine declaration with assignment in LcdFloatSpinBox * Combine declaration with assignment in TimeDisplayWidget * Remove currentNote variable in InstrumentTrack * Combine declaration with assignment in DrumSynth (again) * Use ternary operator for factor variable in BitInvader * Use ternary operator for highestBandwich variable in EqCurve Bandwich? * Move sum variable into for loop in Graph * Fix format in MidiSndio * Fixup a few more * Cleanup error variables * Use ternary operators and combine declaration with initialization * Combine declaration with initialization * Update plugins/LadspaEffect/LadspaControlDialog.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/OpulenZ/OpulenZ.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/SpectrumAnalyzer/SaProcessor.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/midi/MidiAlsaRaw.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/MainWindow.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/clips/AutomationClipView.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/editors/AutomationEditor.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/widgets/Fader.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Move static_cast conversion into separate variable * Use real index when interpolating * Remove empty line * Make helpBtn a private member * Move controller type into separate variable * Fix format of DrumSynth::waveform function * Use tabs and static_cast * Remove redundant if branch * Refactor using static_cast/reinterpret_cast * Add std namespace prefix * Store repeated conditional into boolean variable * Cast to int before assigning to m_currentLength * Rename note_frames to noteFrames * Update src/core/Controller.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/widgets/Graph.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Revert changes that initialized variables redudantly For situations where the initialization is more complex or passed into a function by a pointer, we dont need to do initialization ourselves since it is already done for us, just in a different way. * Remove redundant err variable * Remove explicit check of err variable * Clean up changes and address review * Do not initialize to 0/nullptr when not needed * Wrap condition in parentheses for readability --------- Co-authored-by: Kevin Zander <veratil@gmail.com> Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
587 lines
14 KiB
C++
587 lines
14 KiB
C++
/*
|
|
* VstEffectControls.cpp - controls for VST effect plugins
|
|
*
|
|
* Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program (see COPYING); if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#include <QAction>
|
|
#include <QDomElement>
|
|
#include <QGridLayout>
|
|
#include <QMenu>
|
|
#include <QPushButton>
|
|
#include <QScrollArea>
|
|
|
|
#include "embed.h"
|
|
#include "CustomTextKnob.h"
|
|
#include "VstEffectControls.h"
|
|
#include "VstEffectControlDialog.h"
|
|
#include "VstEffect.h"
|
|
#include "VstPlugin.h"
|
|
|
|
#include "LocaleHelper.h"
|
|
#include "MainWindow.h"
|
|
#include "GuiApplication.h"
|
|
#include "SubWindow.h"
|
|
#include <QApplication>
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
|
|
VstEffectControls::VstEffectControls( VstEffect * _eff ) :
|
|
EffectControls( _eff ),
|
|
m_effect( _eff ),
|
|
m_subWindow( nullptr ),
|
|
ctrHandle( nullptr ),
|
|
lastPosInMenu (0),
|
|
m_vstGuiVisible ( true )
|
|
// m_presetLabel ( NULL )
|
|
{
|
|
}
|
|
|
|
|
|
|
|
|
|
VstEffectControls::~VstEffectControls()
|
|
{
|
|
delete ctrHandle;
|
|
ctrHandle = nullptr;
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::loadSettings( const QDomElement & _this )
|
|
{
|
|
//m_effect->closePlugin();
|
|
//m_effect->openPlugin( _this.attribute( "plugin" ) );
|
|
m_effect->m_pluginMutex.lock();
|
|
if( m_effect->m_plugin != nullptr )
|
|
{
|
|
m_vstGuiVisible = _this.attribute( "guivisible" ).toInt();
|
|
|
|
m_effect->m_plugin->loadSettings( _this );
|
|
|
|
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
|
|
paramCount = dump.size();
|
|
auto paramStr = std::array<char, 35>{};
|
|
knobFModel.resize(paramCount);
|
|
QStringList s_dumpValues;
|
|
for( int i = 0; i < paramCount; i++ )
|
|
{
|
|
sprintf(paramStr.data(), "param%d", i);
|
|
s_dumpValues = dump[paramStr.data()].split(":");
|
|
|
|
knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) );
|
|
knobFModel[i]->loadSettings(_this, paramStr.data());
|
|
|
|
if( !( knobFModel[ i ]->isAutomated() ||
|
|
knobFModel[ i ]->controllerConnection() ) )
|
|
{
|
|
knobFModel[ i ]->setValue(LocaleHelper::toFloat(s_dumpValues.at(2)));
|
|
knobFModel[ i ]->setInitValue(LocaleHelper::toFloat(s_dumpValues.at(2)));
|
|
}
|
|
|
|
connect( knobFModel[i], &FloatModel::dataChanged, this,
|
|
[this, i]() { setParameter( knobFModel[i] ); }, Qt::DirectConnection);
|
|
}
|
|
|
|
}
|
|
m_effect->m_pluginMutex.unlock();
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::setParameter( Model * action )
|
|
{
|
|
int knobUNID = action->displayName().toInt();
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->setParam( knobUNID, knobFModel[knobUNID]->value() );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
|
{
|
|
_this.setAttribute( "plugin", m_effect->m_key.attributes["file"] );
|
|
m_effect->m_pluginMutex.lock();
|
|
if( m_effect->m_plugin != nullptr )
|
|
{
|
|
m_effect->m_plugin->saveSettings( _doc, _this );
|
|
if (!knobFModel.empty()) {
|
|
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
|
|
paramCount = dump.size();
|
|
auto paramStr = std::array<char, 35>{};
|
|
for( int i = 0; i < paramCount; i++ )
|
|
{
|
|
if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) {
|
|
sprintf(paramStr.data(), "param%d", i);
|
|
knobFModel[i]->saveSettings(_doc, _this, paramStr.data());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
m_effect->m_pluginMutex.unlock();
|
|
}
|
|
|
|
|
|
|
|
|
|
int VstEffectControls::controlCount()
|
|
{
|
|
return m_effect->m_plugin != nullptr ? 1 : 0;
|
|
}
|
|
|
|
|
|
|
|
gui::EffectControlDialog* VstEffectControls::createView()
|
|
{
|
|
auto dialog = new gui::VstEffectControlDialog( this );
|
|
dialog->togglePluginUI( m_vstGuiVisible );
|
|
return dialog;
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::managePlugin()
|
|
{
|
|
if ( m_effect->m_plugin != nullptr && m_subWindow == nullptr ) {
|
|
auto tt = new gui::ManageVSTEffectView(m_effect, this);
|
|
ctrHandle = (QObject *)tt;
|
|
} else if (m_subWindow != nullptr) {
|
|
if (m_subWindow->widget()->isVisible() == false ) {
|
|
m_scrollArea->show();
|
|
m_subWindow->show();
|
|
} else {
|
|
m_scrollArea->hide();
|
|
m_subWindow->hide();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::savePreset()
|
|
{
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->savePreset();
|
|
/* bool converted;
|
|
QString str = m_vi->m_plugin->currentProgramName().section("/", 0, 0);
|
|
if (str != "")
|
|
lastPosInMenu = str.toInt(&converted, 10) - 1;
|
|
QWidget::update();*/
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::updateMenu()
|
|
{
|
|
|
|
// get all presets -
|
|
if ( m_effect->m_plugin != nullptr )
|
|
{
|
|
m_effect->m_plugin->loadProgramNames();
|
|
///QWidget::update();
|
|
|
|
QString str = m_effect->m_plugin->allProgramNames();
|
|
|
|
QStringList list1 = str.split("|");
|
|
|
|
QMenu * to_menu = m_selPresetButton->menu();
|
|
to_menu->clear();
|
|
|
|
for (int i = 0; i < list1.size(); i++) {
|
|
auto presetAction = new QAction(this);
|
|
connect(presetAction, SIGNAL(triggered()), this, SLOT(selPreset()));
|
|
|
|
presetAction->setText(QString("%1. %2").arg(QString::number(i+1), list1.at(i)));
|
|
presetAction->setData(i);
|
|
if (i == lastPosInMenu) {
|
|
presetAction->setIcon(embed::getIconPixmap( "sample_file", 16, 16 ));
|
|
} else presetAction->setIcon(embed::getIconPixmap( "edit_copy", 16, 16 ));
|
|
to_menu->addAction( presetAction );
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::openPreset()
|
|
{
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->openPreset();
|
|
bool converted;
|
|
QString str = m_effect->m_plugin->currentProgramName().section("/", 0, 0);
|
|
if (str != "")
|
|
lastPosInMenu = str.toInt(&converted, 10) - 1;
|
|
//QWidget::update();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::rollPreset()
|
|
{
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->rotateProgram( 1 );
|
|
bool converted;
|
|
QString str = m_effect->m_plugin->currentProgramName().section("/", 0, 0);
|
|
if (str != "")
|
|
lastPosInMenu = str.toInt(&converted, 10) - 1;
|
|
//QWidget::update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::rolrPreset()
|
|
{
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->rotateProgram( -1 );
|
|
bool converted;
|
|
QString str = m_effect->m_plugin->currentProgramName().section("/", 0, 0);
|
|
if (str != "")
|
|
lastPosInMenu = str.toInt(&converted, 10) - 1;
|
|
//QWidget::update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::selPreset()
|
|
{
|
|
auto action = qobject_cast<QAction*>(sender());
|
|
if (action && m_effect->m_plugin != nullptr)
|
|
{
|
|
lastPosInMenu = action->data().toInt();
|
|
m_effect->m_plugin->setProgram(lastPosInMenu);
|
|
// QWidget::update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void VstEffectControls::paintEvent( QPaintEvent * )
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace gui
|
|
{
|
|
|
|
|
|
ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * m_vi ) :
|
|
m_effect( _eff )
|
|
{
|
|
#if QT_VERSION < 0x50C00
|
|
// Workaround for a bug in Qt versions below 5.12,
|
|
// where argument-dependent-lookup fails for QFlags operators
|
|
// declared inside a namepsace.
|
|
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
|
|
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
|
|
|
|
using ::operator|;
|
|
#endif
|
|
|
|
m_vi2 = m_vi;
|
|
widget = new QWidget();
|
|
m_vi->m_scrollArea = new QScrollArea( widget );
|
|
l = new QGridLayout( widget );
|
|
|
|
m_vi->m_subWindow = getGUI()->mainWindow()->addWindowedWidget(nullptr, Qt::SubWindow |
|
|
Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
|
m_vi->m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
|
m_vi->m_subWindow->setFixedSize( 960, 300);
|
|
m_vi->m_subWindow->setWidget(m_vi->m_scrollArea);
|
|
m_vi->m_subWindow->setWindowTitle( _eff->m_plugin->name() + tr( " - VST parameter control" ) );
|
|
m_vi->m_subWindow->setWindowIcon( PLUGIN_NAME::getIconPixmap( "logo" ) );
|
|
m_vi->m_subWindow->setAttribute(Qt::WA_DeleteOnClose, false);
|
|
|
|
|
|
l->setContentsMargins( 20, 10, 10, 10 );
|
|
l->setVerticalSpacing( 10 );
|
|
l->setHorizontalSpacing( 23 );
|
|
|
|
m_syncButton = new QPushButton( tr( "VST sync" ), widget );
|
|
connect( m_syncButton, SIGNAL( clicked() ), this,
|
|
SLOT( syncPlugin() ) );
|
|
|
|
l->addWidget( m_syncButton, 0, 0, 1, 2, Qt::AlignLeft );
|
|
|
|
m_displayAutomatedOnly = new QPushButton( tr( "Automated" ), widget );
|
|
connect( m_displayAutomatedOnly, SIGNAL( clicked() ), this,
|
|
SLOT( displayAutomatedOnly() ) );
|
|
|
|
l->addWidget( m_displayAutomatedOnly, 0, 1, 1, 2, Qt::AlignLeft );
|
|
|
|
|
|
m_closeButton = new QPushButton( tr( " Close " ), widget );
|
|
connect( m_closeButton, SIGNAL( clicked() ), this,
|
|
SLOT( closeWindow() ) );
|
|
|
|
l->addWidget( m_closeButton, 0, 2, 1, 7, Qt::AlignLeft );
|
|
|
|
|
|
for( int i = 0; i < 10; i++ )
|
|
{
|
|
l->addItem( new QSpacerItem( 68, 45, QSizePolicy::Fixed, QSizePolicy::Fixed ), 0, i );
|
|
}
|
|
|
|
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
|
|
m_vi->paramCount = dump.size();
|
|
|
|
vstKnobs = new CustomTextKnob *[ m_vi->paramCount ];
|
|
|
|
bool hasKnobModel = true;
|
|
if (m_vi->knobFModel.empty())
|
|
{
|
|
m_vi->knobFModel.resize(m_vi->paramCount);
|
|
hasKnobModel = false;
|
|
}
|
|
|
|
auto paramStr = std::array<char, 35>{};
|
|
QStringList s_dumpValues;
|
|
|
|
for( int i = 0; i < m_vi->paramCount; i++ )
|
|
{
|
|
sprintf(paramStr.data(), "param%d", i);
|
|
s_dumpValues = dump[paramStr.data()].split(":");
|
|
|
|
vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, widget, s_dumpValues.at( 1 ) );
|
|
vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" );
|
|
vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) );
|
|
|
|
if( !hasKnobModel )
|
|
{
|
|
sprintf(paramStr.data(), "%d", i);
|
|
m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)),
|
|
0.0f, 1.0f, 0.01f, _eff, paramStr.data());
|
|
}
|
|
|
|
FloatModel * model = m_vi->knobFModel[i];
|
|
connect( model, &FloatModel::dataChanged, this,
|
|
[this, model]() { setParameter( model ); }, Qt::DirectConnection);
|
|
vstKnobs[ i ] ->setModel( model );
|
|
}
|
|
syncParameterText();
|
|
|
|
int i = 0;
|
|
for( int lrow = 1; lrow < ( int( m_vi->paramCount / 10 ) + 1 ) + 1; lrow++ )
|
|
{
|
|
for( int lcolumn = 0; lcolumn < 10; lcolumn++ )
|
|
{
|
|
if( i < m_vi->paramCount )
|
|
{
|
|
l->addWidget( vstKnobs[i], lrow, lcolumn, Qt::AlignCenter );
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
l->setRowStretch( ( int( m_vi->paramCount / 10 ) + 1 ), 1 );
|
|
l->setColumnStretch( 10, 1 );
|
|
|
|
widget->setLayout(l);
|
|
widget->setAutoFillBackground(true);
|
|
|
|
m_vi->m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
|
|
m_vi->m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
m_vi->m_scrollArea->setPalette( QApplication::palette( m_vi->m_scrollArea ) );
|
|
m_vi->m_scrollArea->setMinimumHeight( 64 );
|
|
|
|
m_vi->m_scrollArea->setWidget( widget );
|
|
|
|
m_vi->m_subWindow->show();
|
|
}
|
|
|
|
|
|
|
|
|
|
void ManageVSTEffectView::closeWindow()
|
|
{
|
|
m_vi2->m_subWindow->hide();
|
|
}
|
|
|
|
|
|
|
|
|
|
void ManageVSTEffectView::syncPlugin()
|
|
{
|
|
auto paramStr = std::array<char, 35>{};
|
|
QStringList s_dumpValues;
|
|
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
|
|
|
|
for( int i = 0; i < m_vi2->paramCount; i++ )
|
|
{
|
|
// only not automated knobs are synced from VST
|
|
// those auto-setted values are not jurnaled, tracked for undo / redo
|
|
if( !( m_vi2->knobFModel[ i ]->isAutomated() ||
|
|
m_vi2->knobFModel[ i ]->controllerConnection() ) )
|
|
{
|
|
sprintf(paramStr.data(), "param%d", i);
|
|
s_dumpValues = dump[paramStr.data()].split(":");
|
|
float f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
|
|
m_vi2->knobFModel[ i ]->setAutomatedValue( f_value );
|
|
m_vi2->knobFModel[ i ]->setInitValue( f_value );
|
|
}
|
|
}
|
|
syncParameterText();
|
|
}
|
|
|
|
|
|
|
|
void ManageVSTEffectView::displayAutomatedOnly()
|
|
{
|
|
bool isAuto = QString::compare( m_displayAutomatedOnly->text(), tr( "Automated" ) ) == 0;
|
|
|
|
for( int i = 0; i< m_vi2->paramCount; i++ )
|
|
{
|
|
|
|
if( !( m_vi2->knobFModel[ i ]->isAutomated() ||
|
|
m_vi2->knobFModel[ i ]->controllerConnection() ) )
|
|
{
|
|
if( vstKnobs[ i ]->isVisible() == true && isAuto )
|
|
{
|
|
vstKnobs[ i ]->hide();
|
|
m_displayAutomatedOnly->setText( "All" );
|
|
} else {
|
|
vstKnobs[ i ]->show();
|
|
m_displayAutomatedOnly->setText( "Automated" );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void ManageVSTEffectView::setParameter( Model * action )
|
|
{
|
|
int knobUNID = action->displayName().toInt();
|
|
|
|
if ( m_effect->m_plugin != nullptr ) {
|
|
m_effect->m_plugin->setParam( knobUNID, m_vi2->knobFModel[knobUNID]->value() );
|
|
syncParameterText();
|
|
}
|
|
}
|
|
|
|
void ManageVSTEffectView::syncParameterText()
|
|
{
|
|
m_effect->m_plugin->loadParameterLabels();
|
|
m_effect->m_plugin->loadParameterDisplays();
|
|
|
|
QString paramLabelStr = m_effect->m_plugin->allParameterLabels();
|
|
QString paramDisplayStr = m_effect->m_plugin->allParameterDisplays();
|
|
|
|
QStringList paramLabelList;
|
|
QStringList paramDisplayList;
|
|
|
|
for( int i = 0; i < paramLabelStr.size(); )
|
|
{
|
|
const int length = paramLabelStr[i].digitValue();
|
|
paramLabelList.append(paramLabelStr.mid(i + 1, length));
|
|
i += length + 1;
|
|
}
|
|
|
|
for( int i = 0; i < paramDisplayStr.size(); )
|
|
{
|
|
const int length = paramDisplayStr[i].digitValue();
|
|
paramDisplayList.append(paramDisplayStr.mid(i + 1, length));
|
|
i += length + 1;
|
|
}
|
|
|
|
for( int i = 0; i < paramLabelList.size(); ++i )
|
|
{
|
|
vstKnobs[i]->setValueText(paramDisplayList[i] + ' ' + paramLabelList[i]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ManageVSTEffectView::~ManageVSTEffectView()
|
|
{
|
|
if (!m_vi2->knobFModel.empty())
|
|
{
|
|
for( int i = 0; i < m_vi2->paramCount; i++ )
|
|
{
|
|
delete m_vi2->knobFModel[ i ];
|
|
delete vstKnobs[ i ];
|
|
}
|
|
}
|
|
|
|
if( vstKnobs != nullptr )
|
|
{
|
|
delete [] vstKnobs;
|
|
vstKnobs = nullptr;
|
|
}
|
|
|
|
m_vi2->knobFModel.clear();
|
|
|
|
if( m_vi2->m_scrollArea != nullptr )
|
|
{
|
|
delete m_vi2->m_scrollArea;
|
|
m_vi2->m_scrollArea = nullptr;
|
|
}
|
|
|
|
if( m_vi2->m_subWindow != nullptr )
|
|
{
|
|
m_vi2->m_subWindow->setAttribute( Qt::WA_DeleteOnClose );
|
|
m_vi2->m_subWindow->close();
|
|
|
|
if( m_vi2->m_subWindow != nullptr )
|
|
{
|
|
delete m_vi2->m_subWindow;
|
|
}
|
|
m_vi2->m_subWindow = nullptr;
|
|
}
|
|
//delete m_vi2->m_subWindow;
|
|
//m_vi2->m_subWindow = NULL;
|
|
}
|
|
|
|
|
|
} // namespace gui
|
|
|
|
} // namespace lmms
|