added LADSPA-support and some fixed lockup-bugs
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@17 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -218,24 +218,29 @@ void audioJACK::writeBufferToDev( surroundSampleFrame * _ab, Uint32 _frames,
|
||||
{
|
||||
m_bufMutex.lock();
|
||||
|
||||
vvector<bufset> bufs;
|
||||
for( Uint8 chnl = 0; chnl < channels(); ++chnl )
|
||||
jack_transport_state_t ts = jack_transport_query( m_client, NULL );
|
||||
if( ts == JackTransportRolling )
|
||||
{
|
||||
sampleType * buf = bufferAllocator::alloc<sampleType>(
|
||||
_frames );
|
||||
for( Uint32 frame = 0; frame < _frames; ++frame )
|
||||
vvector<bufset> bufs;
|
||||
for( Uint8 chnl = 0; chnl < channels(); ++chnl )
|
||||
{
|
||||
buf[frame] = _ab[frame][chnl] * _master_output;
|
||||
sampleType * buf = bufferAllocator::alloc<sampleType>(
|
||||
_frames );
|
||||
for( Uint32 frame = 0; frame < _frames; ++frame )
|
||||
{
|
||||
buf[frame] = _ab[frame][chnl] * _master_output;
|
||||
}
|
||||
bufset b = { buf, _frames } ;
|
||||
bufs.push_back( b );
|
||||
}
|
||||
bufset b = { buf, _frames } ;
|
||||
bufs.push_back( b );
|
||||
m_bufferSets.push_back( bufs );
|
||||
}
|
||||
m_bufferSets.push_back( bufs );
|
||||
|
||||
m_frameSync += _frames;
|
||||
|
||||
m_bufMutex.unlock();
|
||||
|
||||
// now wait until data has been collected by processCallback()
|
||||
// now wait until data has been collected/skipped by processCallback()
|
||||
while( m_frameSync > m_jackBufSize )
|
||||
{
|
||||
#ifdef HAVE_UNISTD_H
|
||||
@@ -261,6 +266,16 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata )
|
||||
NULL );
|
||||
if( ts != JackTransportRolling )
|
||||
{
|
||||
// always decrease frame-sync-var as we would do it if running
|
||||
// in normal mode, so that the mixer-thread does up
|
||||
if( _nframes < _this->m_frameSync )
|
||||
{
|
||||
_this->m_frameSync -= _nframes;
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->m_frameSync = 0;
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
844
src/lib/ladspa_manager.cpp
Normal file
844
src/lib/ladspa_manager.cpp
Normal file
@@ -0,0 +1,844 @@
|
||||
/*
|
||||
* ladspa_manager.cpp - a class to manage loading and instantiation
|
||||
* of ladspa plugins
|
||||
*
|
||||
* Linux MultiMedia Studio
|
||||
* Copyright (c) 2004-2005 Danny McRae <khjklujn@netscape.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., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef QT4
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QPair>
|
||||
|
||||
#else
|
||||
|
||||
#include <qdir.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qpair.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <ladspa.h>
|
||||
#include <dlfcn.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "ladspa_manager.h"
|
||||
|
||||
|
||||
ladspaManager * ladspaManager::s_instanceOfMe = NULL;
|
||||
|
||||
|
||||
ladspaManager::ladspaManager( void )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction;
|
||||
void * pluginHandle;
|
||||
|
||||
// TODO Need to move the search path definition to the config file to have
|
||||
// more control over where it tries to find the plugins.
|
||||
QStringList ladspaDirectories = QStringList::split( QString( ":" ),
|
||||
QString( getenv( "LADSPA_PATH" ) ) );
|
||||
// set default-directory if nothing is specified...
|
||||
if( ladspaDirectories.isEmpty() )
|
||||
{
|
||||
ladspaDirectories.push_back( "/usr/lib/ladspa" );
|
||||
}
|
||||
for( QStringList::iterator it = ladspaDirectories.begin();
|
||||
it != ladspaDirectories.end(); ++it )
|
||||
{
|
||||
QDir directory( ( *it ) );
|
||||
const QFileInfoList * list = directory.entryInfoList();
|
||||
|
||||
for( QFileInfoList::iterator file = list->begin();
|
||||
file != list->end(); ++file )
|
||||
{
|
||||
pluginHandle = dlopen( ( *file )->absFilePath().latin1(),
|
||||
RTLD_LAZY );
|
||||
if( pluginHandle )
|
||||
{
|
||||
dlerror();
|
||||
descriptorFunction
|
||||
= ( LADSPA_Descriptor_Function )
|
||||
dlsym( pluginHandle,
|
||||
"ladspa_descriptor" );
|
||||
if( dlerror() == NULL && descriptorFunction )
|
||||
{
|
||||
addPlugins( pluginHandle,
|
||||
descriptorFunction,
|
||||
( *file )->fileName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
dlclose( ( void * )
|
||||
( *file )->absFilePath().latin1()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ladspaManager::~ladspaManager()
|
||||
{
|
||||
for( ladspaManagerMapType::Iterator it = m_ladspaManagerMap.begin();
|
||||
it != m_ladspaManagerMap.end(); ++it )
|
||||
{
|
||||
dlclose( it.data()->pluginHandle );
|
||||
}
|
||||
m_ladspaManagerMap.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::addPlugins( void * _plugin_handle,
|
||||
LADSPA_Descriptor_Function _descriptor_func,
|
||||
const QString & _file )
|
||||
{
|
||||
const LADSPA_Descriptor * descriptor;
|
||||
long pluginIndex = 0;
|
||||
|
||||
while( ( descriptor = _descriptor_func( pluginIndex ) ) != NULL )
|
||||
{
|
||||
ladspaManagerDescription * plugIn =
|
||||
new ladspaManagerDescription;
|
||||
plugIn->pluginHandle = _plugin_handle;
|
||||
plugIn->descriptorFunction = _descriptor_func;
|
||||
plugIn->index = pluginIndex;
|
||||
|
||||
ladspaKey key( _file, QString( descriptor->Label ) );
|
||||
m_ladspaManagerMap[key] = plugIn;
|
||||
++pluginIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString FASTCALL ladspaManager::getLabel( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( QString( descriptor->Label ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( QString( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::hasRealTimeDependency( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( LADSPA_IS_REALTIME( descriptor->Properties ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isInplaceBroken( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( LADSPA_IS_INPLACE_BROKEN( descriptor->Properties ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isRealTimeCapable( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( LADSPA_IS_HARD_RT_CAPABLE( descriptor->Properties ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString FASTCALL ladspaManager::getName( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( QString( descriptor->Name ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( QString( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString FASTCALL ladspaManager::getMaker( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( QString( descriptor->Maker ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( QString( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString FASTCALL ladspaManager::getCopyright( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( QString( descriptor->Copyright ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( QString( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Uint32 FASTCALL ladspaManager::getPortCount( const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( descriptor->PortCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isPortInput( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
|
||||
return( LADSPA_IS_PORT_INPUT
|
||||
( descriptor->PortDescriptors[_port] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isPortOutput( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
|
||||
return( LADSPA_IS_PORT_OUTPUT
|
||||
( descriptor->PortDescriptors[_port] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isPortAudio( const ladspaKey & _plugin, Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
|
||||
return( LADSPA_IS_PORT_AUDIO
|
||||
( descriptor->PortDescriptors[_port] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isPortControl( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
|
||||
return( LADSPA_IS_PORT_CONTROL
|
||||
( descriptor->PortDescriptors[_port] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::areHintsSampleRateDependent(
|
||||
const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
return( LADSPA_IS_HINT_SAMPLE_RATE
|
||||
( hintDescriptor ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float FASTCALL ladspaManager::getLowerBound( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
if( LADSPA_IS_HINT_BOUNDED_BELOW
|
||||
( hintDescriptor ) )
|
||||
{
|
||||
return( descriptor->PortRangeHints[_port].LowerBound );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float FASTCALL ladspaManager::getUpperBound( const ladspaKey & _plugin, Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
if( LADSPA_IS_HINT_BOUNDED_ABOVE
|
||||
( hintDescriptor ) )
|
||||
{
|
||||
return( descriptor->PortRangeHints[_port].LowerBound );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isPortToggled( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
return( LADSPA_IS_HINT_TOGGLED
|
||||
( hintDescriptor ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float FASTCALL ladspaManager::getDefaultSetting( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
switch( hintDescriptor & LADSPA_HINT_DEFAULT_MASK )
|
||||
{
|
||||
case LADSPA_HINT_DEFAULT_NONE:
|
||||
return( -999e-99 );
|
||||
case LADSPA_HINT_DEFAULT_MINIMUM:
|
||||
return( descriptor->PortRangeHints[_port].LowerBound );
|
||||
case LADSPA_HINT_DEFAULT_LOW:
|
||||
if( LADSPA_IS_HINT_LOGARITHMIC
|
||||
( hintDescriptor ))
|
||||
{
|
||||
return( exp( log( descriptor->PortRangeHints[_port].LowerBound )
|
||||
* 0.75
|
||||
+ log( descriptor->PortRangeHints[_port].UpperBound )
|
||||
* 0.25 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( descriptor->PortRangeHints[_port].LowerBound
|
||||
* 0.75
|
||||
+ descriptor->PortRangeHints[_port].UpperBound
|
||||
* 0.25 );
|
||||
}
|
||||
case LADSPA_HINT_DEFAULT_MIDDLE:
|
||||
if( LADSPA_IS_HINT_LOGARITHMIC
|
||||
( hintDescriptor ) )
|
||||
{
|
||||
return( sqrt( descriptor->PortRangeHints[_port].LowerBound
|
||||
* descriptor->PortRangeHints[_port].UpperBound ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( 0.5 * ( descriptor->PortRangeHints[_port].LowerBound
|
||||
+ descriptor->PortRangeHints[_port].UpperBound ) );
|
||||
}
|
||||
case LADSPA_HINT_DEFAULT_HIGH:
|
||||
if( LADSPA_IS_HINT_LOGARITHMIC
|
||||
( hintDescriptor ) )
|
||||
{
|
||||
return( exp( log( descriptor->PortRangeHints[_port].LowerBound )
|
||||
* 0.25
|
||||
+ log( descriptor->PortRangeHints[_port].UpperBound )
|
||||
* 0.75 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( descriptor->PortRangeHints[_port].LowerBound
|
||||
* 0.25
|
||||
+ descriptor->PortRangeHints[_port].UpperBound
|
||||
* 0.75 );
|
||||
}
|
||||
case LADSPA_HINT_DEFAULT_MAXIMUM:
|
||||
return( descriptor->PortRangeHints[_port].UpperBound );
|
||||
case LADSPA_HINT_DEFAULT_0:
|
||||
return( 0.0 );
|
||||
case LADSPA_HINT_DEFAULT_1:
|
||||
return( 1.0 );
|
||||
case LADSPA_HINT_DEFAULT_100:
|
||||
return( 100.0 );
|
||||
case LADSPA_HINT_DEFAULT_440:
|
||||
return( 440.0 );
|
||||
default:
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return( -999e-99 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isLogarithmic( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
return( LADSPA_IS_HINT_LOGARITHMIC
|
||||
( hintDescriptor ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FASTCALL ladspaManager::isInteger( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
LADSPA_PortRangeHintDescriptor hintDescriptor
|
||||
= descriptor->PortRangeHints[_port].HintDescriptor;
|
||||
return( LADSPA_IS_HINT_INTEGER
|
||||
( hintDescriptor ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString FASTCALL ladspaManager::getPortName( const ladspaKey & _plugin,
|
||||
Uint32 _port )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
|
||||
return( QString( descriptor->PortNames[_port] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( QString( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const void * FASTCALL ladspaManager::getImplementationData( const ladspaKey &
|
||||
_plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( descriptor->ImplementationData );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const LADSPA_Descriptor * FASTCALL ladspaManager::getDescriptor(
|
||||
const ladspaKey & _plugin )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( descriptor );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
LADSPA_Handle FASTCALL ladspaManager::instantiate( const ladspaKey & _plugin,
|
||||
Uint32 _sample_rate )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
return( ( descriptor->instantiate ) ( descriptor, _sample_rate ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::connectPort( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance,
|
||||
Uint32 _port,
|
||||
LADSPA_Data * _data_location )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin )
|
||||
&& _port < getPortCount( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->connect_port != NULL )
|
||||
{
|
||||
( descriptor->connect_port ) ( _instance, _port, _data_location );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::activate( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->activate != NULL )
|
||||
{
|
||||
( descriptor->activate ) ( _instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::run( const ladspaKey & _plugin, LADSPA_Handle _instance,
|
||||
Uint32 _sample_count )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->run != NULL )
|
||||
{
|
||||
( descriptor->run ) ( _instance, _sample_count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::runAdding( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance,
|
||||
Uint32 _sample_count )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->run_adding!=NULL
|
||||
&& descriptor->set_run_adding_gain!=NULL )
|
||||
{
|
||||
( descriptor->run_adding ) ( _instance, _sample_count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::setRunAddingGain( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance,
|
||||
LADSPA_Data _gain )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->run_adding!=NULL
|
||||
&& descriptor->set_run_adding_gain!=NULL )
|
||||
{
|
||||
( descriptor->set_run_adding_gain ) ( _instance, _gain );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::deactivate( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->deactivate != NULL )
|
||||
{
|
||||
( descriptor->deactivate ) ( _instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FASTCALL ladspaManager::cleanup( const ladspaKey & _plugin,
|
||||
LADSPA_Handle _instance )
|
||||
{
|
||||
if( m_ladspaManagerMap.contains( _plugin ) )
|
||||
{
|
||||
LADSPA_Descriptor_Function descriptorFunction
|
||||
= m_ladspaManagerMap[_plugin]->descriptorFunction;
|
||||
const LADSPA_Descriptor * descriptor
|
||||
= descriptorFunction( m_ladspaManagerMap[_plugin]->index );
|
||||
if( descriptor->cleanup != NULL )
|
||||
{
|
||||
( descriptor->cleanup ) ( _instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,8 +162,6 @@ void knob::setHintText( const QString & _txt_before,
|
||||
{
|
||||
m_hintTextBeforeValue = _txt_before;
|
||||
m_hintTextAfterValue = _txt_after;
|
||||
/* toolTip::add( this, m_hintTextBeforeValue + QString::number( value() ) +
|
||||
m_hintTextAfterValue );*/
|
||||
}
|
||||
|
||||
|
||||
@@ -253,8 +251,6 @@ void knob::valueChange( void )
|
||||
{
|
||||
recalcAngle();
|
||||
update();
|
||||
/* toolTip::add( this, m_hintTextBeforeValue + QString::number( value() ) +
|
||||
m_hintTextAfterValue );*/
|
||||
if( m_tracking )
|
||||
{
|
||||
emit valueChanged( value() );
|
||||
@@ -474,22 +470,25 @@ void knob::mouseMoveEvent( QMouseEvent * _me )
|
||||
|
||||
|
||||
//! Mouse Release Event handler
|
||||
void knob::mouseReleaseEvent( QMouseEvent * _me )
|
||||
void knob::mouseReleaseEvent( QMouseEvent * /* _me*/ )
|
||||
{
|
||||
m_scrollMode = ScrNone;
|
||||
buttonReleased();
|
||||
if( m_scrollMode != ScrNone )
|
||||
{
|
||||
m_scrollMode = ScrNone;
|
||||
buttonReleased();
|
||||
}
|
||||
|
||||
switch( m_scrollMode )
|
||||
{
|
||||
case ScrMouse:
|
||||
setPosition( _me->pos() );
|
||||
//setPosition( _me->pos() );
|
||||
m_direction = 0;
|
||||
m_mouseOffset = 0;
|
||||
emit sliderReleased ();
|
||||
emit sliderReleased();
|
||||
break;
|
||||
|
||||
case ScrDirect:
|
||||
setPosition( _me->pos() );
|
||||
//setPosition( _me->pos() );
|
||||
m_direction = 0;
|
||||
m_mouseOffset = 0;
|
||||
break;
|
||||
@@ -527,9 +526,6 @@ void knob::wheelEvent( QWheelEvent * _me )
|
||||
QPoint( m_knobPixmap->width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
|
||||
/* toolTip::add( this, m_hintTextBeforeValue+QString::number( value() ) +
|
||||
m_hintTextAfterValue );*/
|
||||
|
||||
if( value() != m_prevValue )
|
||||
{
|
||||
emit sliderMoved( value() );
|
||||
@@ -727,6 +723,12 @@ void knob::setStep( float _vstep )
|
||||
|
||||
void knob::contextMenuEvent( QContextMenuEvent * )
|
||||
{
|
||||
// for the case, the user clicked right while pressing left mouse-
|
||||
// button, the context-menu appears while mouse-cursor is still hidden
|
||||
// and it isn't shown again until user does something which causes
|
||||
// an QApplication::restoreOverrideCursor()-call...
|
||||
mouseReleaseEvent( NULL );
|
||||
|
||||
QMenu contextMenu( this );
|
||||
#ifdef QT4
|
||||
contextMenu.setTitle( accessibleName() );
|
||||
|
||||
Reference in New Issue
Block a user