rewrote effect-framework, changes in plugin-instantiation

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@656 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-01-06 12:47:21 +00:00
parent 784a7991d6
commit dc5d949af4
61 changed files with 886 additions and 938 deletions

View File

@@ -3,7 +3,7 @@
/*
* audio_port.cpp - base-class for objects providing sound at a port
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -33,7 +33,7 @@
#include "engine.h"
audioPort::audioPort( const QString & _name ) :
audioPort::audioPort( const QString & _name, track * _track ) :
m_bufferUsage( NONE ),
m_firstBuffer( new surroundSampleFrame[
engine::getMixer()->framesPerPeriod()] ),
@@ -42,7 +42,7 @@ audioPort::audioPort( const QString & _name ) :
m_extOutputEnabled( FALSE ),
m_nextFxChannel( -1 ),
m_name( "unnamed port" ),
m_effects( new effectChain ),
m_effects( this, _track ),
m_frames( engine::getMixer()->framesPerPeriod() )
{
engine::getMixer()->clearAudioBuffer( m_firstBuffer,
@@ -62,7 +62,6 @@ audioPort::~audioPort()
engine::getMixer()->removeAudioPort( this );
delete[] m_firstBuffer;
delete[] m_secondBuffer;
delete m_effects;
}

View File

@@ -25,25 +25,27 @@
*
*/
#include <QtGui/QMessageBox>
#include "effect.h"
#include "engine.h"
#include "dummy_effect.h"
#include "effect_chain.h"
#include "effect_view.h"
effect::effect( const plugin::descriptor * _desc,
model * _parent,
const descriptor::subPluginFeatures::key * _key ) :
plugin( _desc ),
plugin( _desc, _parent ),
m_key( _key ? *_key : descriptor::subPluginFeatures::key() ),
m_okay( TRUE ),
m_noRun( FALSE ),
m_running( FALSE ),
m_enabledModel( FALSE, FALSE, TRUE ),
m_bufferCount( 0 ),
m_silenceTimeout( 10 ),
m_wetDryModel( 1.0f, 0.0f, 1.0f, 0.01f ),
m_gateModel( 0.0f, 0.0f, 1.0f, 0.01f )
m_enabledModel( TRUE, FALSE, TRUE, boolModel::defaultRelStep(), this ),
m_wetDryModel( 1.0f, 0.0f, 1.0f, 0.01f, this ),
m_gateModel( 0.0f, 0.0f, 1.0f, 0.01f, this ),
m_autoQuitModel( 1.0f, 1.0f, 8000.0f, 100.0f, this )
{
}
@@ -57,7 +59,45 @@ effect::~effect()
bool FASTCALL effect::processAudioBuffer( surroundSampleFrame * _buf,
void effect::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "on", m_enabledModel.value() );
_this.setAttribute( "wet", m_wetDryModel.value() );
_this.setAttribute( "autoquit", m_autoQuitModel.value() );
_this.setAttribute( "gate", m_gateModel.value() );
// m_controlView->saveState( _doc, _this );
}
void effect::loadSettings( const QDomElement & _this )
{
m_enabledModel.setValue( _this.attribute( "on" ).toInt() );
m_wetDryModel.setValue( _this.attribute( "wet" ).toFloat() );
m_autoQuitModel.setValue( _this.attribute( "autoquit" ).toFloat() );
m_gateModel.setValue( _this.attribute( "gate" ).toFloat() );
/*
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( m_controlView->nodeName() == node.nodeName() )
{
m_controlView->restoreState(
node.toElement() );
}
}
node = node.nextSibling();
}*/
}
bool effect::processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames )
{
return( FALSE );
@@ -65,18 +105,12 @@ bool FASTCALL effect::processAudioBuffer( surroundSampleFrame * _buf,
/*
void FASTCALL effect::setGate( float _level )
{
m_gate = _level * _level * m_processors *
engine::getMixer()->framesPerPeriod();
}
*/
effect * effect::instantiate( const QString & _plugin_name,
model * _parent,
descriptor::subPluginFeatures::key * _key )
{
plugin * p = plugin::instantiate( _plugin_name, _key );
plugin * p = plugin::instantiate( _plugin_name, _parent, _key );
// check whether instantiated plugin is an instrument
if( dynamic_cast<effect *>( p ) != NULL )
{
@@ -86,9 +120,16 @@ effect * effect::instantiate( const QString & _plugin_name,
// not quite... so delete plugin and return dummy instrument
delete p;
return( new dummyEffect() );
return( new dummyEffect( _parent ) );
}
pluginView * effect::instantiateView( QWidget * _parent )
{
return( new effectView( this, _parent ) );
}
#endif

View File

@@ -4,6 +4,7 @@
* effect_chain.cpp - class for processing and effects chain
*
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -31,7 +32,10 @@
effectChain::effectChain( void ) :
effectChain::effectChain( audioPort * _port, track * _track ) :
model( /*_track*/ NULL ),
m_port( _port ),
m_track( _track ),
m_enabledModel( FALSE, FALSE, TRUE )
{
}
@@ -41,26 +45,89 @@ effectChain::effectChain( void ) :
effectChain::~effectChain()
{
for( effect_list_t::size_type eff = 0; eff < m_effects.count(); eff++ )
deleteAllPlugins();
}
void effectChain::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "fxenabled", m_enabledModel.value() );
_this.setAttribute( "numofeffects", m_effects.count() );
for( effectList::iterator it = m_effects.begin();
it != m_effects.end(); it++ )
{
delete m_effects[eff];
QDomElement ef = ( *it )->saveState( _doc, _this );
ef.setAttribute( "name", ( *it )->getDescriptor()->name );
ef.setAttribute( "key", ( *it )->getKey().dumpBase64() );
}
}
void effectChain::loadSettings( const QDomElement & _this )
{
// deleteAllPlugins();
for( int i = 0; i < m_effects.count(); ++i )
{
delete m_effects[i];
}
m_effects.clear();
m_enabledModel.setValue( _this.attribute( "fxenabled" ).toInt() );
const int plugin_cnt = _this.attribute( "numofeffects" ).toInt();
QDomNode node = _this.firstChild();
for( int i = 0; i < plugin_cnt; i++ )
{
if( node.isElement() && node.nodeName() == "effect" )
{
QDomElement cn = node.toElement();
const QString name = cn.attribute( "name" );
// we have this really convenient key-ctor
// which takes a QString and decodes the
// base64-data inside :-)
effectKey key( cn.attribute( "key" ) );
effect * e = effect::instantiate( name, this, &key );
m_effects.push_back( e );
// TODO: somehow detect if effect is sub-plugin-capable
// but couldn't load sub-plugin with requsted key
if( node.isElement() )
{
if( e->nodeName() == node.nodeName() )
{
e->restoreState( node.toElement() );
}
}
}
node = node.nextSibling();
}
emit dataChanged();
}
void FASTCALL effectChain::appendEffect( effect * _effect )
void effectChain::appendEffect( effect * _effect )
{
engine::getMixer()->lock();
_effect->m_enabledModel.setTrack( m_track );
_effect->m_wetDryModel.setTrack( m_track );
_effect->m_gateModel.setTrack( m_track );
_effect->m_autoQuitModel.setTrack( m_track );
m_effects.append( _effect );
engine::getMixer()->unlock();
emit dataChanged();
}
void FASTCALL effectChain::removeEffect( effect * _effect )
void effectChain::removeEffect( effect * _effect )
{
engine::getMixer()->lock();
m_effects.erase( qFind( m_effects.begin(), m_effects.end(), _effect ) );
@@ -70,12 +137,12 @@ void FASTCALL effectChain::removeEffect( effect * _effect )
void FASTCALL effectChain::moveDown( effect * _effect )
void effectChain::moveDown( effect * _effect )
{
if( _effect != m_effects.last() )
{
int i = 0;
for( effect_list_t::iterator it = m_effects.begin();
for( effectList::iterator it = m_effects.begin();
it != m_effects.end(); it++, i++ )
{
if( *it == _effect )
@@ -93,12 +160,12 @@ void FASTCALL effectChain::moveDown( effect * _effect )
void FASTCALL effectChain::moveUp( effect * _effect )
void effectChain::moveUp( effect * _effect )
{
if( _effect != m_effects.first() )
{
int i = 0;
for( effect_list_t::iterator it = m_effects.begin();
for( effectList::iterator it = m_effects.begin();
it != m_effects.end(); it++, i++ )
{
if( *it == _effect )
@@ -116,7 +183,7 @@ void FASTCALL effectChain::moveUp( effect * _effect )
bool FASTCALL effectChain::processAudioBuffer( surroundSampleFrame * _buf,
bool effectChain::processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames )
{
if( m_enabledModel.value() == FALSE )
@@ -124,7 +191,7 @@ bool FASTCALL effectChain::processAudioBuffer( surroundSampleFrame * _buf,
return( FALSE );
}
bool more_effects = FALSE;
for( effect_list_t::iterator it = m_effects.begin();
for( effectList::iterator it = m_effects.begin();
it != m_effects.end(); it++ )
{
more_effects |= ( *it )->processAudioBuffer( _buf, _frames );
@@ -142,7 +209,7 @@ void effectChain::startRunning( void )
return;
}
for( effect_list_t::iterator it = m_effects.begin();
for( effectList::iterator it = m_effects.begin();
it != m_effects.end(); it++ )
{
( *it )->startRunning();
@@ -161,7 +228,7 @@ bool effectChain::isRunning( void )
bool running = FALSE;
for( effect_list_t::iterator it = m_effects.begin();
for( effectList::iterator it = m_effects.begin();
it != m_effects.end() || !running; it++ )
{
running = ( *it )->isRunning() && running;
@@ -170,4 +237,16 @@ bool effectChain::isRunning( void )
}
void effectChain::deleteAllPlugins( void )
{
for( int i = 0; i < m_effects.count(); ++i )
{
delete m_effects[i];
}
m_effects.clear();
}
#endif

View File

@@ -35,6 +35,7 @@
effectControlDialog::effectControlDialog( QWidget * _parent, effect * _eff ) :
QWidget( _parent ),
modelView( _eff ),
m_effect( _eff )
{
setWindowTitle( m_effect->publicName() );

View File

@@ -47,7 +47,7 @@ effectSelectDialog::effectSelectDialog( QWidget * _parent ) :
vlayout->setSpacing( 10 );
vlayout->setMargin( 10 );
effectList * elist = new effectList( this );
effectListWidget * elist = new effectListWidget( this );
elist->setMinimumSize( 500, 400 );
connect( elist, SIGNAL( doubleClicked( const effectKey & ) ),
this, SLOT( selectPlugin() ) );
@@ -107,11 +107,12 @@ effectSelectDialog::~effectSelectDialog()
effect * effectSelectDialog::instantiateSelectedPlugin( void )
effect * effectSelectDialog::instantiateSelectedPlugin( effectChain * _parent )
{
if( !m_currentSelection.name.isEmpty() && m_currentSelection.desc )
{
return( effect::instantiate( m_currentSelection.desc->name,
_parent,
&m_currentSelection ) );
}
return( NULL );
@@ -148,7 +149,7 @@ void effectSelectDialog::selectPlugin( void )
effectList::effectList( QWidget * _parent ) :
effectListWidget::effectListWidget( QWidget * _parent ) :
QWidget( _parent ),
m_descriptionWidget( NULL )
{
@@ -226,14 +227,14 @@ effectList::effectList( QWidget * _parent ) :
effectList::~effectList()
effectListWidget::~effectListWidget()
{
}
void effectList::rowChanged( int _pluginIndex )
void effectListWidget::rowChanged( int _pluginIndex )
{
delete m_descriptionWidget;
m_descriptionWidget = NULL;
@@ -268,7 +269,7 @@ void effectList::rowChanged( int _pluginIndex )
void effectList::onDoubleClicked( QListWidgetItem * _item )
void effectListWidget::onDoubleClicked( QListWidgetItem * _item )
{
emit( doubleClicked( m_currentSelection ) );
}
@@ -276,7 +277,7 @@ void effectList::onDoubleClicked( QListWidgetItem * _item )
void effectList::onAddButtonReleased()
void effectListWidget::onAddButtonReleased()
{
emit( addPlugin( m_currentSelection ) );
}
@@ -284,7 +285,7 @@ void effectList::onAddButtonReleased()
void effectList::resizeEvent( QResizeEvent * )
void effectListWidget::resizeEvent( QResizeEvent * )
{
//m_descriptionWidget->setFixedWidth( width() - 40 );
}

View File

@@ -1,154 +0,0 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* effect_tab_widget.cpp - tab-widget in channel-track-window for setting up
* effects
*
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 "effect_tab_widget.h"
#include <QtGui/QMenu>
#include <QtGui/QToolButton>
#include "audio_port.h"
#include "effect_select_dialog.h"
#include "embed.h"
#include "group_box.h"
#include "instrument_track.h"
#include "rack_plugin.h"
#include "rack_view.h"
#include "sample_track.h"
#include "tooltip.h"
#include "automatable_model_templates.h"
effectTabWidget::effectTabWidget( instrumentTrack * _track,
audioPort * _port ) :
QWidget( _track->tabWidgetParent() ),
m_track( dynamic_cast<track *>( _track ) ),
m_port( _port )
{
m_port->getEffects()->m_enabledModel.setTrack( m_track );
setupWidget();
}
effectTabWidget::effectTabWidget( QWidget * _parent,
sampleTrack * _track,
audioPort * _port ) :
QWidget( _parent ),
m_track( dynamic_cast<track *>( _track ) ),
m_port( _port )
{
m_port->getEffects()->m_enabledModel.setTrack( m_track );
setupWidget();
}
effectTabWidget::~effectTabWidget()
{
}
void effectTabWidget::setupWidget( void )
{
m_effectsGroupBox = new groupBox( tr( "EFFECTS CHAIN" ), this );
m_effectsGroupBox->setModel( &m_port->getEffects()->m_enabledModel );
m_effectsGroupBox->setGeometry( 2, 2, 242, 244 );
m_rack = new rackView( m_effectsGroupBox, m_track, m_port );
m_rack->move( 6, 22 );
m_addButton = new QPushButton( m_effectsGroupBox/*, "Add Effect"*/ );
m_addButton->setText( tr( "Add" ) );
m_addButton->move( 75, 210 );
connect( m_addButton, SIGNAL( clicked( void ) ),
this, SLOT( addEffect( void ) ) );
}
void effectTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "fxenabled",
m_port->getEffects()->m_enabledModel.value() );
m_rack->saveState( _doc, _this );
}
void effectTabWidget::loadSettings( const QDomElement & _this )
{
m_port->getEffects()->m_enabledModel.setValue(
_this.attribute( "fxenabled" ).toInt() );
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( m_rack->nodeName() == node.nodeName() )
{
m_rack->restoreState( node.toElement() );
}
}
node = node.nextSibling();
}
}
void effectTabWidget::addEffect( void )
{
effectSelectDialog esd( this );
esd.exec();
if( esd.result() == QDialog::Rejected )
{
return;
}
effect * e = esd.instantiateSelectedPlugin();
m_rack->addEffect( e );
}
#include "effect_tab_widget.moc"
#endif

View File

@@ -36,7 +36,7 @@
importFilter::importFilter( const QString & _file_name,
const descriptor * _descriptor ) :
plugin( _descriptor ),
plugin( _descriptor, NULL ),
m_file( _file_name )
{
}
@@ -70,7 +70,7 @@ void importFilter::import( const QString & _file_to_import,
{
if( it->type == plugin::ImportFilter )
{
plugin * p = plugin::instantiate( it->name, s );
plugin * p = plugin::instantiate( it->name, NULL, s );
if( dynamic_cast<importFilter *>( p ) != NULL &&
dynamic_cast<importFilter *>( p )->tryImport(
_tc ) == TRUE )

View File

@@ -26,6 +26,7 @@
#include "instrument.h"
#include "instrument_view.h"
#include "automatable_model_templates.h"
#include "instrument_track.h"
#include "dummy_instrument.h"
@@ -34,8 +35,7 @@
instrument::instrument( instrumentTrack * _instrument_track,
const descriptor * _descriptor ) :
plugin( _descriptor ),
model( /* _instrument_track */ NULL ),
plugin( _descriptor, NULL/* _instrument_track*/ ),
m_instrumentTrack( _instrument_track )
{
}
@@ -82,7 +82,8 @@ f_cnt_t instrument::beatLen( notePlayHandle * ) const
instrument * instrument::instantiate( const QString & _plugin_name,
instrumentTrack * _instrument_track )
{
plugin * p = plugin::instantiate( _plugin_name, _instrument_track );
plugin * p = plugin::instantiate( _plugin_name, /*_instrument_track*/ NULL,
_instrument_track );
// check whether instantiated plugin is an instrument
if( dynamic_cast<instrument *>( p ) != NULL )
{
@@ -105,16 +106,6 @@ bool instrument::isFromTrack( const track * _track ) const
instrumentView * instrument::createEditor( QWidget * _parent )
{
instrumentView * i = createView( _parent );
i->setModel( this );
return( i );
}
void instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n )
{
const fpp_t frames = _n->framesLeftForCurrentPeriod();
@@ -144,8 +135,7 @@ void instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n )
instrumentView::instrumentView( instrument * _instrument, QWidget * _parent ) :
QWidget( _parent ),
modelView()
pluginView( _instrument, _parent )
{
setModel( _instrument );
setFixedSize( 250, 250 );

View File

@@ -57,6 +57,7 @@
#include "side_bar.h"
#include "config_mgr.h"
#include "mixer.h"
#include "plugin_view.h"
#include "project_notes.h"
#include "setup_dialog.h"
#include "audio_dummy.h"
@@ -76,7 +77,7 @@ mainWindow::mainWindow( void ) :
m_workspace( NULL ),
m_templatesMenu( NULL ),
m_recentlyOpenedProjectsMenu( NULL ),
m_tools_menu( NULL ),
m_toolsMenu( NULL ),
m_modified( FALSE )
{
setAttribute( Qt::WA_DeleteOnClose );
@@ -421,7 +422,7 @@ void mainWindow::finalize( void )
configManager::inst(), SLOT( exec() ) );
m_tools_menu = new QMenu( this );
m_toolsMenu = new QMenu( this );
QVector<plugin::descriptor> pluginDescriptors;
plugin::getDescriptorsOfAvailPlugins( pluginDescriptors );
for( QVector<plugin::descriptor>::iterator it =
@@ -430,14 +431,15 @@ void mainWindow::finalize( void )
{
if( it->type == plugin::Tool )
{
m_tools_menu->addAction( *it->logo, it->public_name );
m_tools.push_back( tool::instantiate( it->name ) );
m_toolsMenu->addAction( *it->logo, it->public_name );
m_tools.push_back( tool::instantiate( it->name,
/*this*/NULL )->createView( this ) );
}
}
if( !m_tools_menu->isEmpty() )
if( !m_toolsMenu->isEmpty() )
{
menuBar()->addMenu( m_tools_menu )->setText( tr( "&Tools" ) );
connect( m_tools_menu, SIGNAL( triggered( QAction * ) ),
menuBar()->addMenu( m_toolsMenu )->setText( tr( "&Tools" ) );
connect( m_toolsMenu, SIGNAL( triggered( QAction * ) ),
this, SLOT( showTool( QAction * ) ) );
}
@@ -954,13 +956,13 @@ void mainWindow::fillTemplatesMenu( void )
void mainWindow::showTool( QAction * _idx )
{
tool * t = m_tools[m_tools_menu->actions().indexOf( _idx )];
t->show();
pluginView * p = m_tools[m_toolsMenu->actions().indexOf( _idx )];
p->show();
if( m_workspace )
{
t->parentWidget()->show();
p->parentWidget()->show();
}
t->setFocus();
p->setFocus();
}

View File

@@ -53,7 +53,9 @@ static plugin::descriptor dummy_plugin_descriptor =
plugin::plugin( const descriptor * _descriptor ) :
plugin::plugin( const descriptor * _descriptor, model * _parent ) :
journallingObject(),
model( _parent ),
m_descriptor( _descriptor )
{
if( dummy_plugin_descriptor.logo == NULL )
@@ -92,7 +94,8 @@ QString plugin::getParameter( const QString & )
plugin * plugin::instantiate( const QString & _plugin_name, void * _data )
plugin * plugin::instantiate( const QString & _plugin_name, model * _parent,
void * _data )
{
QLibrary plugin_lib( configManager::inst()->pluginDir() +
_plugin_name );
@@ -118,7 +121,7 @@ plugin * plugin::instantiate( const QString & _plugin_name, void * _data )
QMessageBox::Default );
return( new dummyPlugin() );
}
plugin * inst = inst_hook( _data );
plugin * inst = inst_hook( _parent, _data );
return( inst );
}
@@ -175,5 +178,17 @@ void plugin::getDescriptorsOfAvailPlugins( QVector<descriptor> & _plugin_descs )
pluginView * plugin::createView( QWidget * _parent )
{
pluginView * pv = instantiateView( _parent );
if( pv != NULL )
{
pv->setModel( this );
}
return( pv );
}
#endif

View File

@@ -42,7 +42,7 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file ) :
m_sampleBuffer( new sampleBuffer( _sample_file ) ),
m_doneMayReturnTrue( TRUE ),
m_frame( 0 ),
m_audioPort( new audioPort( "samplePlayHandle" ) ),
m_audioPort( new audioPort( "samplePlayHandle", NULL ) ),
m_ownAudioPort( TRUE ),
m_defaultVolumeModel( 1.0f, 0.0f, 4.0f, 0.001f/* this*/ ),
m_volumeModel( &m_defaultVolumeModel ),
@@ -59,7 +59,7 @@ samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) :
m_sampleBuffer( sharedObject::ref( _sample_buffer ) ),
m_doneMayReturnTrue( TRUE ),
m_frame( 0 ),
m_audioPort( new audioPort( "samplePlayHandle" ) ),
m_audioPort( new audioPort( "samplePlayHandle", NULL ) ),
m_ownAudioPort( TRUE ),
m_defaultVolumeModel( 1.0f, 0.0f, 4.0f, 0.001f/* this*/ ),
m_volumeModel( &m_defaultVolumeModel ),

View File

@@ -4,7 +4,7 @@
* surround_area.cpp - a widget for setting position of a channel +
* calculation of volume for each speaker
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -50,10 +50,8 @@ QPixmap * surroundArea::s_backgroundArtwork = NULL;
surroundArea::surroundArea( QWidget * _parent, const QString & _name ) :
QWidget( _parent ),
modelView()
modelView( new surroundAreaModel( NULL, NULL, TRUE ) )
{
setModel( new surroundAreaModel( NULL, NULL, TRUE ) );
if( s_backgroundArtwork == NULL )
{
s_backgroundArtwork = new QPixmap( embed::getIconPixmap(

View File

@@ -36,23 +36,9 @@
tool::tool( const descriptor * _descriptor ) :
plugin( _descriptor )
tool::tool( const descriptor * _descriptor, model * _parent ) :
plugin( _descriptor, _parent )
{
QWidget * window;
if( engine::getMainWindow()->workspace() )
{
engine::getMainWindow()->workspace()->addSubWindow( this );
window = parentWidget();
window->setAttribute( Qt::WA_DeleteOnClose, FALSE );
}
else
{
window = this;
}
window->setWindowTitle( _descriptor->public_name );
window->setWindowIcon( *_descriptor->logo );
}
@@ -65,11 +51,11 @@ tool::~tool()
tool * tool::instantiate( const QString & _plugin_name )
tool * tool::instantiate( const QString & _plugin_name, model * _parent )
{
plugin * p = plugin::instantiate( _plugin_name, NULL );
// check whether instantiated plugin is an instrument
if( dynamic_cast<tool *>( p ) != NULL )
plugin * p = plugin::instantiate( _plugin_name, _parent, NULL );
// check whether instantiated plugin is a tool
if( p->type() == Tool )
{
// everything ok, so return pointer
return( dynamic_cast<tool *>( p ) );
@@ -83,4 +69,25 @@ tool * tool::instantiate( const QString & _plugin_name )
toolView::toolView( tool * _tool, QWidget * _parent ) :
pluginView( _tool, _parent )
{
QWidget * window;
if( engine::getMainWindow()->workspace() )
{
engine::getMainWindow()->workspace()->addSubWindow( this );
window = parentWidget();
window->setAttribute( Qt::WA_DeleteOnClose, FALSE );
}
else
{
window = this;
}
window->setWindowTitle( _tool->publicName() );
window->setWindowIcon( *_tool->getDescriptor()->logo );
}
#endif

View File

@@ -50,7 +50,7 @@
#include "debug.h"
#include "effect_board.h"
#include "effect_chain.h"
#include "effect_tab_widget.h"
#include "effect_rack_view.h"
#include "embed.h"
#include "engine.h"
#include "envelope_tab_widget.h"
@@ -66,6 +66,7 @@
#include "note_play_handle.h"
#include "pattern.h"
#include "piano_widget.h"
#include "plugin_view.h"
#include "sample_play_handle.h"
#include "song_editor.h"
#include "string_pair_drag.h"
@@ -100,7 +101,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
m_trackType( INSTRUMENT_TRACK ),
m_midiPort( engine::getMixer()->getMIDIClient()->addPort( this,
tr( "unnamed_channel" ) ) ),
m_audioPort( new audioPort( tr( "unnamed_channel" ) ) ),
m_audioPort( tr( "unnamed_channel" ), this ),
m_notes(),
m_baseNoteModel( 0, 0, NOTES_PER_OCTAVE * OCTAVES - 1, 1/* this */ ),
m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME,
@@ -109,7 +110,9 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
m_effectChannelModel( DEFAULT_EFFECT_CHANNEL,
MIN_EFFECT_CHANNEL, MAX_EFFECT_CHANNEL
/* this */ ),
// m_effects( /* this */ NULL ),
m_instrument( NULL ),
m_instrumentView( NULL ),
m_midiInputAction( NULL ),
m_midiOutputAction( NULL )
{
@@ -248,10 +251,11 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
m_envWidget = new envelopeTabWidget( this );
m_arpWidget = new arpAndChordsTabWidget( this );
m_midiWidget = new midiTabWidget( this, m_midiPort );
m_effWidget = new effectTabWidget( this, m_audioPort );
m_effectRack = new effectRackView( m_audioPort.getEffects(),
m_tabWidget );
m_tabWidget->addTab( m_envWidget, tr( "ENV/LFO/FILTER" ), 1 );
m_tabWidget->addTab( m_arpWidget, tr( "ARP/CHORD" ), 2 );
m_tabWidget->addTab( m_effWidget, tr( "FX" ), 3 );
m_tabWidget->addTab( m_effectRack, tr( "FX" ), 3 );
m_tabWidget->addTab( m_midiWidget, tr( "MIDI" ), 4 );
// setup piano-widget
@@ -323,8 +327,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
instrumentTrack::~instrumentTrack()
{
engine::getMixer()->removePlayHandles( this );
delete m_effWidget;
delete m_audioPort;
delete m_effectRack;
engine::getMixer()->getMIDIClient()->removePort( m_midiPort );
if( engine::getMainWindow()->workspace() )
@@ -450,7 +453,7 @@ void instrumentTrack::processAudioBuffer( sampleFrame * _buf,
}
float v_scale = (float) getVolume() / DEFAULT_VOLUME;
m_audioPort->getEffects()->startRunning();
m_audioPort.getEffects()->startRunning();
// instruments using instrument-play-handles will call this method
// without any knowledge about notes, so they pass NULL for _n, which
@@ -465,7 +468,7 @@ void instrumentTrack::processAudioBuffer( sampleFrame * _buf,
engine::getMixer()->bufferToPort( _buf,
( _n != NULL ) ? tMin<f_cnt_t>( _n->framesLeftForCurrentPeriod(), _frames ) :
_frames,
( _n != NULL ) ? _n->offset() : 0, v, m_audioPort );
( _n != NULL ) ? _n->offset() : 0, v, &m_audioPort );
}
@@ -664,7 +667,7 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing )
// in last period and have
// to clear parts of it
_n->noteOff();
engine::getMixer()->clearAudioBuffer( m_audioPort->firstBuffer(),
engine::getMixer()->clearAudioBuffer( m_audioPort.firstBuffer(),
engine::getMixer()->framesPerPeriod() -
( *youngest_note )->offset(),
( *youngest_note )->offset() );
@@ -749,7 +752,7 @@ void instrumentTrack::setName( const QString & _new_name )
#endif
m_tswInstrumentTrackButton->setText( m_name );
m_midiPort->setName( m_name );
m_audioPort->setName( m_name );
m_audioPort.setName( m_name );
}
@@ -969,7 +972,7 @@ void instrumentTrack::saveTrackSpecificSettings( QDomDocument & _doc,
m_envWidget->saveState( _doc, _this );
m_arpWidget->saveState( _doc, _this );
m_midiWidget->saveState( _doc, _this );
m_effWidget->saveState( _doc, _this );
m_audioPort.getEffects()->saveState( _doc, _this );
}
@@ -990,7 +993,8 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this )
if( _this.hasAttribute( "baseoct" ) )
{
// TODO: move this compat code to mmp.cpp -> upgrade()
m_baseNoteModel.setInitValue( _this.attribute( "baseoct" ).toInt()
m_baseNoteModel.setInitValue( _this.
attribute( "baseoct" ).toInt()
* NOTES_PER_OCTAVE
+ _this.attribute( "basetone" ).toInt() );
}
@@ -1020,9 +1024,11 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this )
{
m_midiWidget->restoreState( node.toElement() );
}
else if( m_effWidget->nodeName() == node.nodeName() )
else if( m_audioPort.getEffects()->nodeName() ==
node.nodeName() )
{
m_effWidget->restoreState( node.toElement() );
m_audioPort.getEffects()->restoreState(
node.toElement() );
had_fx = TRUE;
}
else if( automationPattern::classNodeName()
@@ -1031,6 +1037,7 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this )
// if node-name doesn't match any known one,
// we assume that it is an instrument-plugin
// which we'll try to load
delete m_instrumentView;
delete m_instrument;
m_instrument = instrument::instantiate(
node.nodeName(), this );
@@ -1040,16 +1047,18 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this )
m_instrument->restoreState(
node.toElement() );
}
m_tabWidget->addTab( m_instrument->
createEditor( m_tabWidget ),
m_instrumentView = m_instrument->
createView( m_tabWidget );
m_tabWidget->addTab( m_instrumentView,
tr( "PLUGIN" ), 0 );
}
}
node = node.nextSibling();
}
// TODO: why not move above without any condition??
if( !had_fx )
{
m_effWidget->deleteAllEffects();
m_audioPort.getEffects()->deleteAllPlugins();
}
engine::getMixer()->unlock();
@@ -1072,12 +1081,13 @@ instrument * instrumentTrack::loadInstrument( const QString & _plugin_name )
invalidateAllMyNPH();
engine::getMixer()->lock();
delete m_instrumentView;
delete m_instrument;
m_instrument = instrument::instantiate( _plugin_name, this );
engine::getMixer()->unlock();
m_tabWidget->addTab( m_instrument->createEditor( m_tabWidget ),
tr( "PLUGIN" ), 0 );
m_instrumentView = m_instrument->createView( m_tabWidget );
m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), 0 );
m_tabWidget->setActiveTab( 0 );
m_tswInstrumentTrackButton->update();

View File

@@ -330,7 +330,7 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f )
sampleTrack::sampleTrack( trackContainer * _tc ) :
track( _tc ),
m_audioPort( new audioPort( tr( "Sample track" ) ) ),
m_audioPort( tr( "Sample track" ), this ),
m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, 1/*, this*/ )
{
m_volumeModel.setTrack( this );
@@ -372,7 +372,6 @@ sampleTrack::~sampleTrack()
}
engine::getMixer()->removePlayHandles( this );
delete m_audioPort;
}
@@ -393,7 +392,7 @@ bool FASTCALL sampleTrack::play( const midiTime & _start,
{
sendMidiTime( _start );
m_audioPort->getEffects()->startRunning();
m_audioPort.getEffects()->startRunning();
bool played_a_note = FALSE; // will be return variable
for( int i = 0; i < numOfTCOs(); ++i )
@@ -436,7 +435,7 @@ void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "name", m_trackLabel->text() );
m_trackLabel->saveState( _doc, _this );
m_audioPort.getEffects()->saveState( _doc, _this );
#if 0
_this.setAttribute( "icon", m_trackLabel->pixmapFile() );
#endif
@@ -454,9 +453,11 @@ void sampleTrack::loadTrackSpecificSettings( const QDomElement & _this )
{
if( node.isElement() )
{
if( m_trackLabel->nodeName() == node.nodeName() )
if( m_audioPort.getEffects()->nodeName() ==
node.nodeName() )
{
m_trackLabel->restoreState( node.toElement() );
m_audioPort.getEffects()->restoreState(
node.toElement() );
}
}
node = node.nextSibling();

View File

@@ -41,10 +41,10 @@
automatableButton::automatableButton( QWidget * _parent,
const QString & _name ) :
QPushButton( _parent ),
autoModelView(),
autoModelView( new autoModel( FALSE, FALSE, TRUE,
autoModel::defaultRelStep(), NULL, TRUE ) ),
m_group( NULL )
{
setModel( new autoModel( FALSE, FALSE, TRUE, 1, NULL, TRUE ) );
setAccessibleName( _name );
}
@@ -165,9 +165,8 @@ void automatableButton::toggle( void )
automatableButtonGroup::automatableButtonGroup( QWidget * _parent,
const QString & _name ) :
QWidget( _parent ),
autoModelView()
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) )
{
setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) );
hide();
setAccessibleName( _name );
}

View File

@@ -4,7 +4,7 @@
* automatable_slider.cpp - implementation of class automatableSlider
*
* Copyright (c) 2006-2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
* Copyright (c) 2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2007-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -41,10 +41,9 @@
automatableSlider::automatableSlider( QWidget * _parent, const QString & _name ) :
QSlider( _parent ),
autoModelView(),
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
m_showStatus( FALSE )
{
setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) );
setAccessibleName( _name );
connect( this, SIGNAL( valueChanged( int ) ),

View File

@@ -47,11 +47,10 @@ const int CB_ARROW_BTN_WIDTH = 20;
comboBox::comboBox( QWidget * _parent, const QString & _name ) :
QWidget( _parent ),
autoModelView(),
autoModelView( new comboBoxModel ),
m_menu( this ),
m_pressed( FALSE )
{
setModel( new comboBoxModel );
if( s_background == NULL )
{
s_background = new QPixmap( embed::getIconPixmap(

View File

@@ -5,6 +5,7 @@
* offers access to an effect rack
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -29,12 +30,13 @@
#include "effect_label.h"
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QMdiArea>
#include <QtGui/QMouseEvent>
#include <QtGui/QPushButton>
#include <QtXml/QDomElement>
#include "effect_tab_widget.h"
#include "effect_rack_view.h"
#include "embed.h"
#include "engine.h"
#include "gui_templates.h"
@@ -55,33 +57,33 @@ effectLabel::effectLabel( const QString & _initial_name, QWidget * _parent,
m_effectBtn->setGeometry( 6, 1, 28, 28 );
connect( m_effectBtn, SIGNAL( clicked() ),
this, SLOT( showEffects() ) );
m_label = new QLabel( this );
m_label->setText( _initial_name );
QFont f = m_label->font();
m_label->setFont( pointSize<8>( f ) );
m_label->setGeometry( 38, 1, 200, 28 );
m_effWidget = new effectTabWidget( engine::getMainWindow()->workspace(),
m_track,
m_track->getAudioPort() );
m_effectRack = new effectRackView(
m_track->getAudioPort()->getEffects(),
engine::getMainWindow()->workspace() );
if( engine::getMainWindow()->workspace() )
{
engine::getMainWindow()->workspace()->addSubWindow(
m_effWidget );
m_effWindow = m_effWidget->parentWidget();
m_effectRack );
m_effWindow = m_effectRack->parentWidget();
m_effWindow->setAttribute( Qt::WA_DeleteOnClose, FALSE );
m_effWindow->layout()->setSizeConstraint(
QLayout::SetFixedSize );
}
else
{
m_effWindow = m_effWidget;
m_effWindow = m_effectRack;
}
m_effWindow->setWindowTitle( _initial_name );
m_effWidget->setFixedSize( 240, 242 );
m_effectRack->setFixedSize( 240, 242 );
m_effWindow->hide();
}
@@ -104,7 +106,7 @@ QString effectLabel::text( void ) const
void FASTCALL effectLabel::setText( const QString & _text )
void effectLabel::setText( const QString & _text )
{
m_label->setText( _text );
m_effWindow->setWindowTitle( _text );
@@ -117,8 +119,8 @@ void effectLabel::showEffects( void )
{
if( m_effWindow->isHidden() )
{
m_effWidget->show();
if( m_effWindow != m_effWidget )
m_effectRack->show();
if( m_effWindow != m_effectRack )
{
m_effWindow->show();
}
@@ -133,36 +135,6 @@ void effectLabel::showEffects( void )
void effectLabel::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
// _this.setAttribute( "name", m_label->text() );
m_effWidget->saveState( _doc, _this );
}
void effectLabel::loadSettings( const QDomElement & _this )
{
// m_label->setText( _this.attribute( "name" ) );
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( m_effWidget->nodeName() == node.nodeName() )
{
m_effWidget->restoreState( node.toElement() );
}
}
node = node.nextSibling();
}
}
void effectLabel::rename( void )
{

View File

@@ -1,9 +1,10 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* rack_view.cpp - provides the display for the rackInsert instances
* effect_rack_view.cpp - view for effectChain-model
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn@netscape.net>
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,218 +27,239 @@
#include <QtGui/QApplication>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include "rack_view.h"
#include "audio_port.h"
#include "rack_plugin.h"
#include "effect_rack_view.h"
#include "effect_select_dialog.h"
#include "effect_view.h"
#include "group_box.h"
rackView::rackView( QWidget * _parent, track * _track, audioPort * _port ) :
effectRackView::effectRackView( effectChain * _model, QWidget * _parent ) :
QWidget( _parent ),
m_track( _track ),
m_port( _port )
modelView( NULL )
{
setFixedSize( 230, 184 );
m_mainLayout = new QVBoxLayout( this );
/* m_mainLayout = new QVBoxLayout( this );
m_mainLayout->setMargin( 0 );
m_mainLayout->setSpacing( 0 );
m_scrollArea = new QScrollArea( this );
m_mainLayout->setSpacing( 0 );*/
m_effectsGroupBox = new groupBox( tr( "EFFECTS CHAIN" ), this );
m_effectsGroupBox->setGeometry( 2, 2, 242, 244 );
m_scrollArea = new QScrollArea( m_effectsGroupBox );
m_scrollArea->setFixedSize( 230, 184 );
m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) );
m_scrollArea->move( 6, 22 );
m_addButton = new QPushButton( m_effectsGroupBox/*, "Add Effect"*/ );
m_addButton->setText( tr( "Add" ) );
m_addButton->move( 75, 210 );
connect( m_addButton, SIGNAL( clicked( void ) ),
this, SLOT( addEffect( void ) ) );
m_mainLayout->addWidget( m_scrollArea );
//m_mainLayout->addWidget( m_scrollArea );
QWidget * w = new QWidget;
m_scrollArea->setWidget( w );
w->show();
m_lastY = 0;
setModel( _model );
}
rackView::~rackView()
effectRackView::~effectRackView()
{
deleteAllPlugins();
//deleteAllPlugins();
}
void rackView::addEffect( effect * _e )
/*
void effectRackView::deleteAllPlugins( void )
{
if( !m_scrollArea->widget() )
{
QWidget * w = new QWidget;
m_scrollArea->setWidget( w );
w->show();
}
QWidget * w = m_scrollArea->widget();
rackPlugin * plugin = new rackPlugin( w, _e, m_track, m_port );
connect( plugin, SIGNAL( moveUp( rackPlugin * ) ),
this, SLOT( moveUp( rackPlugin * ) ) );
connect( plugin, SIGNAL( moveDown( rackPlugin * ) ),
this, SLOT( moveDown( rackPlugin * ) ) );
connect( plugin, SIGNAL( deletePlugin( rackPlugin * ) ),
this, SLOT( deletePlugin( rackPlugin * ) ) );
plugin->move( 0, m_lastY );
plugin->show();
m_lastY += plugin->height();
m_scrollArea->widget()->setFixedSize( 210, m_lastY );
m_rackInserts.append( plugin );
}
void FASTCALL rackView::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "numofeffects", m_rackInserts.count() );
for( QVector<rackPlugin *>::iterator it = m_rackInserts.begin();
it != m_rackInserts.end(); it++ )
{
QDomElement ef = ( *it )->saveState( _doc, _this );
ef.setAttribute( "name",
( *it )->getEffect()->getDescriptor()->name );
ef.setAttribute( "key",
( *it )->getEffect()->getKey().dumpBase64() );
}
}
void FASTCALL rackView::loadSettings( const QDomElement & _this )
{
deleteAllPlugins();
const int plugin_cnt = _this.attribute( "numofeffects" ).toInt();
QDomNode node = _this.firstChild();
for( int i = 0; i < plugin_cnt; i++ )
{
if( node.isElement() && node.nodeName() == "effect" )
{
QDomElement cn = node.toElement();
const QString name = cn.attribute( "name" );
// we have this really convenient key-ctor
// which takes a QString and decodes the
// base64-data inside :-)
effectKey key( cn.attribute( "key" ) );
addEffect( effect::instantiate( name, &key ) );
// TODO: somehow detect if effect is sub-plugin-capable
// but couldn't load sub-plugin with requsted key
if( node.isElement() )
{
if( m_rackInserts.last()->nodeName() ==
node.nodeName() )
{
m_rackInserts.last()->restoreState(
node.toElement() );
}
}
}
node = node.nextSibling();
}
}
void rackView::deleteAllPlugins( void )
{
for( QVector<rackPlugin *>::iterator it = m_rackInserts.begin();
it != m_rackInserts.end(); ++it )
for( QVector<effectView *>::iterator it = m_effectViews.begin();
it != m_effectViews.end(); ++it )
{
delete *it;
}
m_rackInserts.clear();
m_effectViews.clear();
}
*/
void rackView::moveUp( rackPlugin * _plugin )
void effectRackView::moveUp( effectView * _view )
{
if( _plugin != m_rackInserts.first() )
fxChain()->moveUp( _view->getEffect() );
if( _view != m_effectViews.first() )
{
int i = 0;
for( QVector<rackPlugin *>::iterator it =
m_rackInserts.begin();
it != m_rackInserts.end(); it++, i++ )
for( QVector<effectView *>::iterator it =
m_effectViews.begin();
it != m_effectViews.end(); it++, i++ )
{
if( *it == _plugin )
if( *it == _view )
{
break;
}
}
rackPlugin * temp = m_rackInserts[ i - 1 ];
effectView * temp = m_effectViews[ i - 1 ];
m_rackInserts[i - 1] = _plugin;
m_rackInserts[i] = temp;
m_effectViews[i - 1] = _view;
m_effectViews[i] = temp;
redraw();
updateView();
}
}
void rackView::moveDown( rackPlugin * _plugin )
void effectRackView::moveDown( effectView * _view )
{
m_port->getEffects()->moveDown( _plugin->getEffect() );
if( _plugin != m_rackInserts.last() )
if( _view != m_effectViews.last() )
{
// moving next effect up is the same
moveUp( *( qFind( m_effectViews.begin(), m_effectViews.end(),
_view ) + 1 ) );
}
/*
fxChain()->moveDown( _view->getEffect() );
if( _view != m_effectViews.last() )
{
int i = 0;
for( QVector<rackPlugin *>::iterator it =
m_rackInserts.begin();
it != m_rackInserts.end(); it++, i++ )
for( QVector<effectView *>::iterator it =
m_effectViews.begin();
it != m_effectViews.end(); it++, i++ )
{
if( *it == _plugin )
if( *it == _view )
{
break;
}
}
rackPlugin * temp = m_rackInserts.at( i + 1 );
effectView * temp = m_effectViews.at( i + 1 );
m_rackInserts[i + 1] = _plugin;
m_rackInserts[i] = temp;
m_effectViews[i + 1] = _view;
m_effectViews[i] = temp;
redraw();
}
}*/
}
void rackView::deletePlugin( rackPlugin * _plugin )
void effectRackView::deletePlugin( effectView * _view )
{
m_rackInserts.erase( qFind( m_rackInserts.begin(), m_rackInserts.end(),
_plugin ) );
delete _plugin;
redraw();
effect * e = _view->getEffect();
m_effectViews.erase( qFind( m_effectViews.begin(), m_effectViews.end(),
_view ) );
delete _view;
fxChain()->m_effects.erase( qFind( fxChain()->m_effects.begin(),
fxChain()->m_effects.end(),
e ) );
delete e;
updateView();
}
void rackView::redraw()
void effectRackView::updateView( void )
{
m_lastY = 0;
for( QVector<rackPlugin *>::iterator it = m_rackInserts.begin();
it != m_rackInserts.end(); it++ )
QWidget * w = m_scrollArea->widget();
QVector<bool> view_map( fxChain()->m_effects.size(), FALSE );
for( QVector<effect *>::iterator it = fxChain()->m_effects.begin();
it != fxChain()->m_effects.end(); ++it )
{
( *it )->move( 0, m_lastY );
m_lastY += ( *it )->height();
int i = 0;
for( QVector<effectView *>::iterator vit =
m_effectViews.begin();
vit != m_effectViews.end(); ++vit, ++i )
{
if( ( *vit )->getEffect() == *it )
{
view_map[i] = TRUE;
break;
}
}
if( i >= m_effectViews.size() )
{
effectView * view = new effectView( *it, w );
connect( view, SIGNAL( moveUp( effectView * ) ),
this, SLOT( moveUp( effectView * ) ) );
connect( view, SIGNAL( moveDown( effectView * ) ),
this, SLOT( moveDown( effectView * ) ) );
connect( view, SIGNAL( deletePlugin( effectView * ) ),
this, SLOT( deletePlugin( effectView * ) ) );
view->show();
m_effectViews.append( view );
view_map[i] = TRUE;
}
}
m_scrollArea->widget()->setFixedSize( 210, m_lastY );
}
int i = m_lastY = 0;
for( QVector<effectView *>::iterator it = m_effectViews.begin();
it != m_effectViews.end(); )
{
if( i < view_map.size() && view_map[i] == FALSE )
{
delete m_effectViews[i];
m_effectViews.erase( it );
}
else
{
( *it )->move( 0, m_lastY );
m_lastY += ( *it )->height();
++it;
++i;
}
}
w->setFixedSize( 210, m_lastY );
}
#include "rack_view.moc"
void effectRackView::addEffect( void )
{
effectSelectDialog esd( this );
esd.exec();
if( esd.result() == QDialog::Rejected )
{
return;
}
fxChain()->appendEffect( esd.instantiateSelectedPlugin( fxChain() ) );
updateView();
}
void effectRackView::modelChanged( void )
{
m_effectsGroupBox->setModel( &fxChain()->m_enabledModel );
updateView();
}
#include "effect_rack_view.moc"
#endif

View File

@@ -1,10 +1,10 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* effect_tab_widget.cpp - tab-widget in channel-track-window for setting up
* effects
* effect_view.cpp - view-component for an effect
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2007-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,7 +26,7 @@
*/
#include "rack_plugin.h"
#include "effect_view.h"
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
@@ -46,15 +46,8 @@
#include "tooltip.h"
rackPlugin::rackPlugin( QWidget * _parent,
effect * _eff,
track * _track,
audioPort * _port ) :
QWidget( _parent ),
m_autoQuitModel( 1.0f, 1.0f, 8000.0f, 100.0f /* this */ ),
m_effect( _eff ),
m_track( _track ),
m_port( _port ),
effectView::effectView( effect * _model, QWidget * _parent ) :
pluginView( _model, _parent ),
m_show( TRUE )
{
setFixedSize( 210, 60 );
@@ -66,18 +59,13 @@ rackPlugin::rackPlugin( QWidget * _parent,
pal.setBrush( backgroundRole(), bg );
setPalette( pal );
m_effect->m_enabledModel.setTrack( m_track );
m_effect->m_enabledModel.setValue( TRUE );
m_bypass = new ledCheckBox( "", this, tr( "Turn the effect off" ) );
m_bypass->setModel( &m_effect->m_enabledModel );
m_bypass->move( 3, 3 );
m_bypass->setWhatsThis( tr( "Toggles the effect on or off." ) );
toolTip::add( m_bypass, tr( "On/Off" ) );
m_effect->m_wetDryModel.setTrack( m_track );
m_wetDry = new knob( knobBright_26, this, tr( "Wet/Dry mix" ) );
m_wetDry->setModel( &m_effect->m_wetDryModel );
m_wetDry->setLabel( tr( "W/D" ) );
m_wetDry->move( 27, 5 );
m_wetDry->setHintText( tr( "Wet Level:" ) + " ", "" );
@@ -86,12 +74,7 @@ rackPlugin::rackPlugin( QWidget * _parent,
"shows up in the output." ) );
m_autoQuitModel.setTrack( m_track );
m_autoQuitModel.setInitValue( 1.0f );
connect( &m_autoQuitModel, SIGNAL( dataChanged( void ) ),
this, SLOT( updateAutoQuit( void ) ) );
m_autoQuit = new tempoSyncKnob( knobBright_26, this, tr( "Decay" ) );
m_autoQuit->setModel( &m_autoQuitModel );
m_autoQuit->setLabel( tr( "Decay" ) );
m_autoQuit->move( 60, 5 );
m_autoQuit->setHintText( tr( "Time:" ) + " ", "ms" );
@@ -101,9 +84,7 @@ rackPlugin::rackPlugin( QWidget * _parent,
"run the risk of clipping the tail on delay effects." ) );
m_effect->m_gateModel.setTrack( m_track );
m_gate = new knob( knobBright_26, this, tr( "Gate" ) );
m_gate->setModel( &m_effect->m_gateModel );
m_gate->setLabel( tr( "Gate" ) );
m_gate->move( 93, 5 );
m_gate->setHintText( tr( "Gate:" ) + " ", "" );
@@ -120,7 +101,7 @@ rackPlugin::rackPlugin( QWidget * _parent,
this, SLOT( editControls() ) );
m_label = new QLabel( this );
m_label->setText( m_effect->publicName() );
m_label->setText( getEffect()->publicName() );
f = m_label->font();
f.setBold( TRUE );
m_label->setFont( pointSize<7>( f ) );
@@ -131,7 +112,7 @@ rackPlugin::rackPlugin( QWidget * _parent,
bg.toImage().copy( 5, 44, 195, 10 ) ) );
m_label->setPalette( pal );
m_controlView = m_effect->createControlDialog( m_track );
m_controlView = getEffect()->createControlDialog( NULL );
m_subWindow = engine::getMainWindow()->workspace()->addSubWindow(
m_controlView );
connect( m_controlView, SIGNAL( closed() ),
@@ -173,23 +154,24 @@ rackPlugin::rackPlugin( QWidget * _parent,
"Right clicking will bring up a context menu where you can change the order "
"in which the effects are processed or delete an effect altogether." ) );
m_port->getEffects()->appendEffect( m_effect );
// m_port->getEffects()->appendEffect( m_effect );
setModel( _model );
}
rackPlugin::~rackPlugin()
effectView::~effectView()
{
m_port->getEffects()->removeEffect( m_effect );
delete m_effect;
// m_port->getEffects()->removeEffect( m_effect );
// delete m_effect;
m_controlView->deleteLater();
}
void rackPlugin::editControls( void )
void effectView::editControls( void )
{
if( m_show )
{
@@ -207,22 +189,10 @@ void rackPlugin::editControls( void )
void rackPlugin::updateAutoQuit( void )
{
float samples = engine::getMixer()->sampleRate() *
m_autoQuitModel.value() / 1000.0f;
Uint32 buffers = 1 + ( static_cast<Uint32>( samples ) /
engine::getMixer()->framesPerPeriod() );
m_effect->setTimeout( buffers );
}
void rackPlugin::contextMenuEvent( QContextMenuEvent * )
void effectView::contextMenuEvent( QContextMenuEvent * )
{
QPointer<captionMenu> contextMenu = new captionMenu(
m_effect->publicName() );
getEffect()->publicName() );
contextMenu->addAction( embed::getIconPixmap( "arp_up_on" ),
tr( "Move &up" ),
this, SLOT( moveUp() ) );
@@ -244,7 +214,7 @@ void rackPlugin::contextMenuEvent( QContextMenuEvent * )
void rackPlugin::moveUp()
void effectView::moveUp()
{
emit( moveUp( this ) );
}
@@ -252,14 +222,14 @@ void rackPlugin::moveUp()
void rackPlugin::moveDown()
void effectView::moveDown()
{
emit( moveDown( this ) );
}
void rackPlugin::deletePlugin()
void effectView::deletePlugin()
{
emit( deletePlugin( this ) );
}
@@ -267,7 +237,7 @@ void rackPlugin::deletePlugin()
void rackPlugin::displayHelp( void )
void effectView::displayHelp( void )
{
QWhatsThis::showText( mapToGlobal( rect().bottomRight() ),
whatsThis() );
@@ -276,53 +246,22 @@ void rackPlugin::displayHelp( void )
void FASTCALL rackPlugin::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "on", m_effect->m_enabledModel.value() );
_this.setAttribute( "wet", m_effect->m_wetDryModel.value() );
_this.setAttribute( "autoquit", m_autoQuitModel.value() );
_this.setAttribute( "gate", m_effect->m_gateModel.value() );
m_controlView->saveState( _doc, _this );
}
void FASTCALL rackPlugin::loadSettings( const QDomElement & _this )
{
m_effect->m_enabledModel.setValue( _this.attribute( "on" ).toInt() );
m_effect->m_wetDryModel.setValue( _this.attribute( "wet" ).toFloat() );
m_autoQuitModel.setValue( _this.attribute( "autoquit" ).toFloat() );
m_effect->m_gateModel.setValue( _this.attribute( "gate" ).toFloat() );
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( m_controlView->nodeName() == node.nodeName() )
{
m_controlView->restoreState(
node.toElement() );
}
}
node = node.nextSibling();
}
}
void rackPlugin::closeEffects( void )
void effectView::closeEffects( void )
{
m_subWindow->hide();
m_show = TRUE;
}
void effectView::modelChanged( void )
{
m_bypass->setModel( &getEffect()->m_enabledModel );
m_wetDry->setModel( &getEffect()->m_wetDryModel );
m_autoQuit->setModel( &getEffect()->m_autoQuitModel );
m_gate->setModel( &getEffect()->m_gateModel );
}
#include "rack_plugin.moc"
#include "effect_view.moc"
#endif

View File

@@ -49,7 +49,7 @@ QPixmap * groupBox::s_ledBg = NULL;
groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
QWidget( _parent ),
autoModelView(),
autoModelView( NULL ),
m_caption( _caption )
{
if( s_ledBg == NULL )

View File

@@ -65,7 +65,7 @@ textFloat * knob::s_textFloat = NULL;
knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
QWidget( _parent ),
autoModelView(),
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
m_mouseOffset( 0.0f ),
m_buttonPressed( FALSE ),
m_hintTextBeforeValue( "" ),
@@ -73,8 +73,6 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
m_knobNum( _knob_num ),
m_label( "" )
{
setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) );
if( s_textFloat == NULL )
{
s_textFloat = new textFloat( this );

View File

@@ -41,7 +41,7 @@
lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
const QString & _name ) :
QWidget( _parent ),
autoModelView(),
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
m_number( new QLCDNumber( _num_digits, this ) ),
m_label( NULL ),
m_origMousePos()
@@ -50,8 +50,6 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
m_number->setFrameShadow( QFrame::Sunken );
m_number->setSegmentStyle( QLCDNumber::Flat );
setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) );
QPalette pal;
pal.setColor( QPalette::Light, Qt::gray );
pal.setColor( QPalette::Mid, Qt::darkGray );