removed buffer allocator, automatable object dependencies, deadlocks
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@477 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -97,10 +97,11 @@ public:
|
||||
return( m_channels );
|
||||
}
|
||||
|
||||
bool processNextBuffer( void );
|
||||
void processNextBuffer( void );
|
||||
|
||||
virtual void startProcessing( void )
|
||||
{
|
||||
m_in_process = TRUE;
|
||||
}
|
||||
|
||||
virtual void stopProcessing( void );
|
||||
@@ -175,6 +176,7 @@ private:
|
||||
sample_rate_t m_sampleRate;
|
||||
ch_cnt_t m_channels;
|
||||
mixer * m_mixer;
|
||||
bool m_in_process;
|
||||
|
||||
QMutex m_devMutex;
|
||||
|
||||
|
||||
@@ -92,10 +92,14 @@ private:
|
||||
while( TRUE )
|
||||
{
|
||||
timer.reset();
|
||||
if ( !processNextBuffer() )
|
||||
const surroundSampleFrame * b =
|
||||
getMixer()->nextBuffer();
|
||||
if( !b )
|
||||
{
|
||||
break;
|
||||
}
|
||||
delete[] b;
|
||||
|
||||
const Sint32 microseconds = static_cast<Sint32>(
|
||||
getMixer()->framesPerAudioBuffer() *
|
||||
1000000.0f / getMixer()->sampleRate() -
|
||||
|
||||
@@ -29,29 +29,24 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "qt3support.h"
|
||||
#include "automation_editor.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "engine.h"
|
||||
#include "journalling_object.h"
|
||||
#include "templates.h"
|
||||
#include "midi_time.h"
|
||||
#include "level_object.h"
|
||||
|
||||
#ifndef QT3
|
||||
|
||||
#include <Qt/QtXml>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
#else
|
||||
|
||||
#include <qdom.h>
|
||||
#include <qvariant.h>
|
||||
#include <qguardedptr.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class automationPattern;
|
||||
class track;
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE = T>
|
||||
class automatableObject : public journallingObject, public levelObject
|
||||
{
|
||||
@@ -60,32 +55,9 @@ public:
|
||||
|
||||
automatableObject( track * _track = NULL, const T _val = 0,
|
||||
const T _min = 0, const T _max = 0,
|
||||
const T _step = defaultRelStep() ) :
|
||||
m_value( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_step( _step ),
|
||||
m_automation_pattern( NULL ),
|
||||
m_track( _track ),
|
||||
m_journalEntryReady( FALSE )
|
||||
{
|
||||
m_curLevel = level( _val );
|
||||
m_minLevel = level( _min );
|
||||
m_maxLevel = level( _max );
|
||||
}
|
||||
const T _step = defaultRelStep() );
|
||||
|
||||
virtual ~automatableObject()
|
||||
{
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
delete m_automation_pattern;
|
||||
}
|
||||
while( m_linkedObjects.empty() == FALSE )
|
||||
{
|
||||
m_linkedObjects.last()->unlinkObject( this );
|
||||
m_linkedObjects.erase( m_linkedObjects.end() - 1 );
|
||||
}
|
||||
}
|
||||
virtual ~automatableObject();
|
||||
|
||||
static inline T minRelStep( void )
|
||||
{
|
||||
@@ -128,217 +100,32 @@ public:
|
||||
return( m_curLevel );
|
||||
}
|
||||
|
||||
inline T fittedValue( T _value )
|
||||
{
|
||||
_value = tLimit<T>( _value, minValue(), maxValue() );
|
||||
inline T fittedValue( T _value );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = static_cast<T>( roundf( _value
|
||||
/ (float)step() ) * step() );
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = minValue();
|
||||
}
|
||||
virtual void setInitValue( const T _value );
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<T>( _value - maxValue() ) < minEps() *
|
||||
tAbs<T>( step() ) )
|
||||
{
|
||||
_value = maxValue();
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<T>( _value ) < minEps() * tAbs<T>( step() ) )
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
return( _value );
|
||||
}
|
||||
|
||||
inline virtual void setInitValue( const T _value )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( _value );
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
setFirstValue();
|
||||
}
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
inline virtual void setValue( const T _value )
|
||||
{
|
||||
const T old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
m_curLevel = level( m_value );
|
||||
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( journalEntry( 0,
|
||||
static_cast<EDIT_STEP_TYPE>( m_value ) -
|
||||
static_cast<EDIT_STEP_TYPE>( old_val ) ) );
|
||||
|
||||
// notify linked objects
|
||||
|
||||
// doesn't work because of implicit typename T
|
||||
// for( autoObjVector::iterator it =
|
||||
// m_linkedObjects.begin();
|
||||
// it != m_linkedObjects.end(); ++it )
|
||||
for( csize i = 0; i < m_linkedObjects.size(); ++i )
|
||||
{
|
||||
autoObj * it = m_linkedObjects[i];
|
||||
if( value() != it->value() &&
|
||||
it->fittedValue( value() ) !=
|
||||
it->value() )
|
||||
{
|
||||
bool journalling =
|
||||
it->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
it->setValue( value() );
|
||||
it->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inline virtual void setValue( const T _value );
|
||||
|
||||
inline virtual void incValue( int _steps )
|
||||
{
|
||||
setValue( m_value + _steps * m_step );
|
||||
}
|
||||
|
||||
inline virtual void setRange( const T _min, const T _max,
|
||||
const T _step = defaultRelStep() )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<T>( m_minValue, m_maxValue );
|
||||
}
|
||||
setStep( _step );
|
||||
// re-adjust value
|
||||
autoObj::setInitValue( value() );
|
||||
}
|
||||
virtual void setRange( const T _min, const T _max,
|
||||
const T _step = defaultRelStep() );
|
||||
|
||||
inline virtual void setStep( const T _step )
|
||||
{
|
||||
/*
|
||||
const T intv = maxValue() - minValue();
|
||||
inline virtual void setStep( const T _step );
|
||||
|
||||
if( _step == 0 )
|
||||
{
|
||||
m_step = intv * defaultRelStep();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( intv > 0 ) && ( _step < 0 ) || ( intv < 0 ) &&
|
||||
( _step > 0 ) )
|
||||
{
|
||||
m_step = -_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_step = _step;
|
||||
}
|
||||
if( tAbs<T>( m_step ) <
|
||||
tAbs<T>( minRelStep() * intv ) )
|
||||
{
|
||||
m_step = minRelStep() * intv;
|
||||
}
|
||||
}*/
|
||||
m_step = _step;
|
||||
m_curLevel = level( m_value );
|
||||
m_minLevel = level( m_minValue );
|
||||
m_maxLevel = level( m_maxValue );
|
||||
}
|
||||
static void linkObjects( autoObj * _object1, autoObj * _object2 );
|
||||
|
||||
static inline void linkObjects( autoObj * _object1,
|
||||
autoObj * _object2 )
|
||||
{
|
||||
_object1->linkObject( _object2 );
|
||||
_object2->linkObject( _object1 );
|
||||
|
||||
if( _object1->m_automation_pattern
|
||||
!= _object2->m_automation_pattern )
|
||||
{
|
||||
if( _object2->m_automation_pattern )
|
||||
{
|
||||
delete _object2->m_automation_pattern;
|
||||
}
|
||||
_object2->m_automation_pattern
|
||||
= _object1->m_automation_pattern;
|
||||
}
|
||||
}
|
||||
|
||||
static void unlinkObjects( autoObj * _object1,
|
||||
autoObj * _object2 )
|
||||
{
|
||||
_object1->unlinkObject( _object2 );
|
||||
_object2->unlinkObject( _object1 );
|
||||
|
||||
if( _object1->m_automation_pattern
|
||||
&& _object1->m_automation_pattern
|
||||
== _object2->m_automation_pattern )
|
||||
{
|
||||
_object2->m_automation_pattern = new automationPattern(
|
||||
*_object1->m_automation_pattern, _object2 );
|
||||
}
|
||||
}
|
||||
static void unlinkObjects( autoObj * _object1, autoObj * _object2 );
|
||||
|
||||
virtual void FASTCALL saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name = "value" )
|
||||
{
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
QDomElement pattern_element;
|
||||
QDomNode node = _this.namedItem(
|
||||
automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
pattern_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern_element = _doc.createElement(
|
||||
automationPattern::classNodeName() );
|
||||
_this.appendChild( pattern_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_automation_pattern->saveSettings( _doc, element );
|
||||
pattern_element.appendChild( element );
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.setAttribute( _name, value() );
|
||||
}
|
||||
}
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual void FASTCALL loadSettings( const QDomElement & _this,
|
||||
const QString & _name = "value" )
|
||||
{
|
||||
QDomNode node = _this.namedItem(
|
||||
automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
m_automation_pattern->loadSettings(
|
||||
node.toElement() );
|
||||
setLevel( m_automation_pattern->valueAt(
|
||||
midiTime( 0 ) ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setInitValue( attributeValue( _this.attribute( _name ) ) );
|
||||
}
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual QString nodeName( void ) const
|
||||
{
|
||||
@@ -355,16 +142,7 @@ public:
|
||||
m_data = _data;
|
||||
}
|
||||
|
||||
inline automationPattern * getAutomationPattern( void )
|
||||
{
|
||||
if( !m_automation_pattern )
|
||||
{
|
||||
m_automation_pattern = new automationPattern( m_track,
|
||||
this );
|
||||
syncAutomationPattern();
|
||||
}
|
||||
return( m_automation_pattern );
|
||||
}
|
||||
inline automationPattern * getAutomationPattern( void );
|
||||
|
||||
inline bool nullTrack( void )
|
||||
{
|
||||
@@ -378,67 +156,15 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
virtual void redoStep( journalEntry & _je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
/*#ifndef QT3
|
||||
setValue( static_cast<T>( value() +
|
||||
_je.data().value<EDIT_STEP_TYPE>() ) );
|
||||
#else*/
|
||||
setValue( static_cast<T>( value() + static_cast<EDIT_STEP_TYPE>(
|
||||
_je.data().toDouble() ) ) );
|
||||
//#endif
|
||||
setJournalling( journalling );
|
||||
}
|
||||
virtual void redoStep( journalEntry & _je );
|
||||
|
||||
virtual void undoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(),
|
||||
/*#ifndef QT3
|
||||
-_je.data().value<EDIT_STEP_TYPE>()
|
||||
#else*/
|
||||
static_cast<EDIT_STEP_TYPE>( -_je.data().toDouble() )
|
||||
//#endif
|
||||
);
|
||||
redoStep( je );
|
||||
}
|
||||
virtual void undoStep( journalEntry & _je );
|
||||
|
||||
inline void prepareJournalEntryFromOldVal( void )
|
||||
{
|
||||
m_oldValue = value();
|
||||
saveJournallingState( FALSE );
|
||||
m_journalEntryReady = TRUE;
|
||||
}
|
||||
void prepareJournalEntryFromOldVal( void );
|
||||
|
||||
inline void addJournalEntryFromOldToCurVal( void )
|
||||
{
|
||||
if( m_journalEntryReady )
|
||||
{
|
||||
restoreJournallingState();
|
||||
if( value() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( journalEntry( 0, value() -
|
||||
m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = FALSE;
|
||||
}
|
||||
}
|
||||
void addJournalEntryFromOldToCurVal( void );
|
||||
|
||||
inline void setFirstValue( void )
|
||||
{
|
||||
if( m_automation_pattern
|
||||
&& m_automation_pattern->updateFirst() )
|
||||
{
|
||||
m_automation_pattern->putValue( midiTime( 0 ),
|
||||
m_curLevel, FALSE );
|
||||
if( engine::getAutomationEditor() &&
|
||||
engine::getAutomationEditor()->currentPattern()
|
||||
== m_automation_pattern )
|
||||
{
|
||||
engine::getAutomationEditor()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void setFirstValue( void );
|
||||
|
||||
|
||||
private:
|
||||
@@ -459,52 +185,15 @@ private:
|
||||
typedef vvector<autoObj *> autoObjVector;
|
||||
autoObjVector m_linkedObjects;
|
||||
|
||||
inline void linkObject( autoObj * _object )
|
||||
{
|
||||
if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(),
|
||||
_object ) == m_linkedObjects.end() )
|
||||
{
|
||||
m_linkedObjects.push_back( _object );
|
||||
}
|
||||
}
|
||||
inline void linkObject( autoObj * _object );
|
||||
|
||||
inline void unlinkObject( autoObj * _object )
|
||||
{
|
||||
if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(),
|
||||
_object ) != m_linkedObjects.end() )
|
||||
{
|
||||
m_linkedObjects.erase( qFind( m_linkedObjects.begin(),
|
||||
m_linkedObjects.end(),
|
||||
_object ) );
|
||||
}
|
||||
}
|
||||
inline void unlinkObject( autoObj * _object );
|
||||
|
||||
static T attributeValue( QString _value );
|
||||
static inline T attributeValue( QString _value );
|
||||
|
||||
inline void syncAutomationPattern( void )
|
||||
{
|
||||
for( csize i = 0; i < m_linkedObjects.size(); ++i )
|
||||
{
|
||||
autoObj * it = m_linkedObjects[i];
|
||||
if( m_automation_pattern != it->m_automation_pattern )
|
||||
{
|
||||
it->m_automation_pattern = m_automation_pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void syncAutomationPattern( void );
|
||||
|
||||
void setLevel( int _level )
|
||||
{
|
||||
if( m_curLevel == _level )
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
m_automation_pattern->setUpdateFirst( FALSE );
|
||||
setValue( _level * m_step );
|
||||
m_automation_pattern->setUpdateFirst( TRUE );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
inline void setLevel( int _level );
|
||||
|
||||
inline int level( T _value ) const
|
||||
{
|
||||
@@ -525,54 +214,6 @@ private:
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::minRelStep( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::defaultRelStep( void )
|
||||
{
|
||||
return( 1.0e-2 );
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::minEps( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toFloat() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline int automatableObject<int>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toInt() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline bool automatableObject<bool, signed char>::attributeValue(
|
||||
QString _value )
|
||||
{
|
||||
return( static_cast<bool>( _value.toInt() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
533
include/automatable_object_templates.h
Normal file
533
include/automatable_object_templates.h
Normal file
@@ -0,0 +1,533 @@
|
||||
/*
|
||||
* automatable_object_templates.h - definition of automatableObject templates
|
||||
*
|
||||
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _AUTOMATABLE_OBJECT_TEMPLATES_H
|
||||
#define _AUTOMATABLE_OBJECT_TEMPLATES_H
|
||||
|
||||
|
||||
#include "automatable_object.h"
|
||||
#include "automation_editor.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "engine.h"
|
||||
#include "templates.h"
|
||||
|
||||
#ifndef QT3
|
||||
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
#else
|
||||
|
||||
#include <qdom.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automatableObject<T, EDIT_STEP_TYPE>::automatableObject( track * _track,
|
||||
const T _val, const T _min,
|
||||
const T _max, const T _step ) :
|
||||
m_value( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_step( _step ),
|
||||
m_automation_pattern( NULL ),
|
||||
m_track( _track ),
|
||||
m_journalEntryReady( FALSE )
|
||||
{
|
||||
m_curLevel = level( _val );
|
||||
m_minLevel = level( _min );
|
||||
m_maxLevel = level( _max );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automatableObject<T, EDIT_STEP_TYPE>::~automatableObject()
|
||||
{
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
delete m_automation_pattern;
|
||||
}
|
||||
while( m_linkedObjects.empty() == FALSE )
|
||||
{
|
||||
m_linkedObjects.last()->unlinkObject( this );
|
||||
m_linkedObjects.erase( m_linkedObjects.end() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
T automatableObject<T, EDIT_STEP_TYPE>::fittedValue( T _value )
|
||||
{
|
||||
_value = tLimit<T>( _value, minValue(), maxValue() );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = static_cast<T>( roundf( _value / (float)step() )
|
||||
* step() );
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = minValue();
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<T>( _value - maxValue() ) < minEps() * tAbs<T>( step() ) )
|
||||
{
|
||||
_value = maxValue();
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<T>( _value ) < minEps() * tAbs<T>( step() ) )
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
return( _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setInitValue( const T _value )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( _value );
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
setFirstValue();
|
||||
}
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setValue( const T _value )
|
||||
{
|
||||
const T old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
m_curLevel = level( m_value );
|
||||
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( journalEntry( 0,
|
||||
static_cast<EDIT_STEP_TYPE>( m_value ) -
|
||||
static_cast<EDIT_STEP_TYPE>( old_val ) ) );
|
||||
|
||||
// notify linked objects
|
||||
|
||||
// doesn't work because of implicit typename T
|
||||
// for( autoObjVector::iterator it =
|
||||
// m_linkedObjects.begin();
|
||||
// it != m_linkedObjects.end(); ++it )
|
||||
for( csize i = 0; i < m_linkedObjects.size(); ++i )
|
||||
{
|
||||
autoObj * it = m_linkedObjects[i];
|
||||
if( value() != it->value() && it->fittedValue( value() )
|
||||
!= it->value() )
|
||||
{
|
||||
bool journalling = it->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
it->setValue( value() );
|
||||
it->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setRange( const T _min, const T _max,
|
||||
const T _step )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<T>( m_minValue, m_maxValue );
|
||||
}
|
||||
setStep( _step );
|
||||
// re-adjust value
|
||||
autoObj::setInitValue( value() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setStep( const T _step )
|
||||
{
|
||||
/*
|
||||
const T intv = maxValue() - minValue();
|
||||
|
||||
if( _step == 0 )
|
||||
{
|
||||
m_step = intv * defaultRelStep();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( intv > 0 ) && ( _step < 0 ) || ( intv < 0 ) &&
|
||||
( _step > 0 ) )
|
||||
{
|
||||
m_step = -_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_step = _step;
|
||||
}
|
||||
if( tAbs<T>( m_step ) < tAbs<T>( minRelStep() * intv ) )
|
||||
{
|
||||
m_step = minRelStep() * intv;
|
||||
}
|
||||
}*/
|
||||
m_step = _step;
|
||||
m_curLevel = level( m_value );
|
||||
m_minLevel = level( m_minValue );
|
||||
m_maxLevel = level( m_maxValue );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::linkObjects( autoObj * _object1,
|
||||
autoObj * _object2 )
|
||||
{
|
||||
_object1->linkObject( _object2 );
|
||||
_object2->linkObject( _object1 );
|
||||
|
||||
if( _object1->m_automation_pattern != _object2->m_automation_pattern )
|
||||
{
|
||||
if( _object2->m_automation_pattern )
|
||||
{
|
||||
delete _object2->m_automation_pattern;
|
||||
}
|
||||
_object2->m_automation_pattern = _object1->m_automation_pattern;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::unlinkObjects( autoObj * _object1,
|
||||
autoObj * _object2 )
|
||||
{
|
||||
_object1->unlinkObject( _object2 );
|
||||
_object2->unlinkObject( _object1 );
|
||||
|
||||
if( _object1->m_automation_pattern && _object1->m_automation_pattern
|
||||
== _object2->m_automation_pattern )
|
||||
{
|
||||
_object2->m_automation_pattern = new automationPattern(
|
||||
*_object1->m_automation_pattern, _object2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
if( m_automation_pattern )
|
||||
{
|
||||
QDomElement pattern_element;
|
||||
QDomNode node = _this.namedItem(
|
||||
automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
pattern_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern_element = _doc.createElement(
|
||||
automationPattern::classNodeName() );
|
||||
_this.appendChild( pattern_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_automation_pattern->saveSettings( _doc, element );
|
||||
pattern_element.appendChild( element );
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.setAttribute( _name, value() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::loadSettings(
|
||||
const QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
QDomNode node = _this.namedItem( automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
m_automation_pattern->loadSettings( node.toElement() );
|
||||
setLevel( m_automation_pattern->valueAt(
|
||||
midiTime( 0 ) ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setInitValue( attributeValue( _this.attribute( _name ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automationPattern * automatableObject<T, EDIT_STEP_TYPE>::getAutomationPattern(
|
||||
void )
|
||||
{
|
||||
if( !m_automation_pattern )
|
||||
{
|
||||
m_automation_pattern = new automationPattern( m_track, this );
|
||||
syncAutomationPattern();
|
||||
}
|
||||
return( m_automation_pattern );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::redoStep( journalEntry & _je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
/*#ifndef QT3
|
||||
setValue( static_cast<T>( value() +
|
||||
_je.data().value<EDIT_STEP_TYPE>() ) );
|
||||
#else*/
|
||||
setValue( static_cast<T>( value() + static_cast<EDIT_STEP_TYPE>(
|
||||
_je.data().toDouble() ) ) );
|
||||
//#endif
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::undoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(),
|
||||
/*#ifndef QT3
|
||||
-_je.data().value<EDIT_STEP_TYPE>()
|
||||
#else*/
|
||||
static_cast<EDIT_STEP_TYPE>( -_je.data().toDouble() )
|
||||
//#endif
|
||||
);
|
||||
redoStep( je );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::prepareJournalEntryFromOldVal( void )
|
||||
{
|
||||
m_oldValue = value();
|
||||
saveJournallingState( FALSE );
|
||||
m_journalEntryReady = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::addJournalEntryFromOldToCurVal(
|
||||
void )
|
||||
{
|
||||
if( m_journalEntryReady )
|
||||
{
|
||||
restoreJournallingState();
|
||||
if( value() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( journalEntry( 0, value() -
|
||||
m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setFirstValue( void )
|
||||
{
|
||||
if( m_automation_pattern && m_automation_pattern->updateFirst() )
|
||||
{
|
||||
m_automation_pattern->putValue( midiTime( 0 ), m_curLevel,
|
||||
FALSE );
|
||||
if( engine::getAutomationEditor() &&
|
||||
engine::getAutomationEditor()->currentPattern()
|
||||
== m_automation_pattern )
|
||||
{
|
||||
engine::getAutomationEditor()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::linkObject( autoObj * _object )
|
||||
{
|
||||
if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), _object )
|
||||
== m_linkedObjects.end() )
|
||||
{
|
||||
m_linkedObjects.push_back( _object );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::unlinkObject( autoObj * _object )
|
||||
{
|
||||
if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), _object )
|
||||
!= m_linkedObjects.end() )
|
||||
{
|
||||
m_linkedObjects.erase( qFind( m_linkedObjects.begin(),
|
||||
m_linkedObjects.end(),
|
||||
_object ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::syncAutomationPattern( void )
|
||||
{
|
||||
for( csize i = 0; i < m_linkedObjects.size(); ++i )
|
||||
{
|
||||
autoObj * it = m_linkedObjects[i];
|
||||
if( m_automation_pattern != it->m_automation_pattern )
|
||||
{
|
||||
it->m_automation_pattern = m_automation_pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableObject<T, EDIT_STEP_TYPE>::setLevel( int _level )
|
||||
{
|
||||
if( m_curLevel == _level )
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
m_automation_pattern->setUpdateFirst( FALSE );
|
||||
setValue( _level * m_step );
|
||||
m_automation_pattern->setUpdateFirst( TRUE );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::minRelStep( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::defaultRelStep( void )
|
||||
{
|
||||
return( 1.0e-2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::minEps( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableObject<float>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toFloat() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline int automatableObject<int>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toInt() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline bool automatableObject<bool, signed char>::attributeValue(
|
||||
QString _value )
|
||||
{
|
||||
return( static_cast<bool>( _value.toInt() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
m_b2a0( 0.0f ),
|
||||
m_a1a0( 0.0f ),
|
||||
m_a2a0( 0.0f ),
|
||||
m_sampleRate( 1.0f / _sample_rate ),
|
||||
m_sampleRate( _sample_rate ),
|
||||
m_subFilter( NULL )
|
||||
{
|
||||
// reset in/out history
|
||||
@@ -231,13 +231,17 @@ public:
|
||||
return( out );
|
||||
}
|
||||
|
||||
|
||||
inline void calcFilterCoeffs( const filterTypes _type, float _freq,
|
||||
float _q
|
||||
|
||||
void setType( const filterTypes _type )
|
||||
{
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
|
||||
inline void calcFilterCoeffs( float _freq, float _q
|
||||
/*, const bool _q_is_bandwidth = FALSE*/ )
|
||||
{
|
||||
// temp coef vars
|
||||
m_type = _type;
|
||||
_freq = tMax( _freq, 0.01f );// limit freq and q for not getting
|
||||
// bad noise out of the filter...
|
||||
_q = tMax( _q, minQ() );
|
||||
@@ -250,21 +254,21 @@ public:
|
||||
{
|
||||
m_subFilter =
|
||||
new basicFilters<CHANNELS>(
|
||||
static_cast<sample_rate_t>( 1.0f / m_sampleRate ) );
|
||||
static_cast<sample_rate_t>( m_sampleRate ) );
|
||||
m_subFilter->setType( MOOG );
|
||||
}
|
||||
m_subFilter->calcFilterCoeffs( MOOG, _freq,
|
||||
_q );
|
||||
m_subFilter->calcFilterCoeffs( _freq, _q );
|
||||
}
|
||||
|
||||
case MOOG:
|
||||
{
|
||||
// [ 0 - 1 ]
|
||||
const float f = 2 * _freq * m_sampleRate;
|
||||
const float f = 2 * _freq / m_sampleRate;
|
||||
// (Empirical tunning)
|
||||
m_k = 3.6f*f - 1.6f*f*f - 1;
|
||||
m_p = (m_k+1)*0.5f;
|
||||
m_r = _q*powf( M_E, ( ( 1-m_p ) * 1.386249f ) );
|
||||
break;
|
||||
m_k = 3.6f * f - 1.6f * f * f - 1;
|
||||
m_p = ( m_k + 1 ) * 0.5f;
|
||||
m_r = _q * powf( M_E, ( 1 - m_p ) * 1.386249f );
|
||||
return;
|
||||
}
|
||||
|
||||
/* case DOUBLE_MOOG2:
|
||||
@@ -273,7 +277,7 @@ public:
|
||||
{
|
||||
m_subFilter =
|
||||
new basicFilters<CHANNELS>(
|
||||
1.0f / m_sampleRate );
|
||||
m_sampleRate );
|
||||
}
|
||||
m_subFilter->calcFilterCoeffs( MOOG2, _freq,
|
||||
_q );
|
||||
@@ -281,8 +285,8 @@ public:
|
||||
|
||||
case MOOG2:
|
||||
{
|
||||
const float kfc = 2 * _freq * m_sampleRate;
|
||||
const float kf = _freq * m_sampleRate;
|
||||
const float kfc = 2 * _freq / m_sampleRate;
|
||||
const float kf = _freq / m_sampleRate;
|
||||
const float kfcr = 1.8730 * ( kfc*kfc*kfc ) +
|
||||
0.4955 * ( kfc*kfc ) +
|
||||
0.6490 * kfc + 0.9988;
|
||||
@@ -295,81 +299,79 @@ public:
|
||||
}*/
|
||||
|
||||
default:
|
||||
{
|
||||
// other filters
|
||||
const float omega = F_2PI * _freq *
|
||||
m_sampleRate;
|
||||
const float tsin = sinf( omega );
|
||||
const float tcos = cosf( omega );
|
||||
//float alpha;
|
||||
|
||||
//if (q_is_bandwidth)
|
||||
//alpha = tsin*sinhf(logf(2.0f)/2.0f*q*omega/
|
||||
// tsin);
|
||||
//else
|
||||
const float alpha = 0.5f * tsin / _q;
|
||||
|
||||
const float a0 = 1.0f / ( 1.0f + alpha );
|
||||
|
||||
if( m_type == LOWPASS ||
|
||||
m_type == DOUBLE_LOWPASS )
|
||||
{
|
||||
m_b0a0 = ((1.0f-tcos)*0.5f)*a0;
|
||||
m_b1a0 = (1.0f-tcos)*a0;
|
||||
m_b2a0 = m_b0a0;//((1.0f-tcos)/2.0f)*a0;
|
||||
m_a1a0 = (-2.0f*tcos)*a0;
|
||||
if( m_type == DOUBLE_LOWPASS )
|
||||
{
|
||||
if( m_subFilter == NULL )
|
||||
{
|
||||
m_subFilter =
|
||||
new basicFilters<CHANNELS>( static_cast<sample_rate_t>(
|
||||
1.0f / m_sampleRate ) );
|
||||
}
|
||||
m_subFilter->calcFilterCoeffs(
|
||||
LOWPASS, _freq, _q );
|
||||
}
|
||||
}
|
||||
else if( m_type == HIPASS )
|
||||
{
|
||||
m_b0a0 = ((1.0f+tcos)*0.5f)*a0;
|
||||
m_b1a0 = (-1.0f-tcos)*a0;
|
||||
m_b2a0 = m_b0a0;//((1.0f+tcos)/2.0f)*a0;
|
||||
m_a1a0 = (-2.0f*tcos)*a0;
|
||||
}
|
||||
else if( m_type == BANDPASS_CSG )
|
||||
{
|
||||
m_b0a0 = tsin*0.5f*a0;
|
||||
m_b1a0 = 0.0f;
|
||||
m_b2a0 = -tsin*0.5f*a0;
|
||||
m_a1a0 = (-2.0f*tcos)*a0;
|
||||
}
|
||||
else if( m_type == BANDPASS_CZPG )
|
||||
{
|
||||
m_b0a0 = alpha*a0;
|
||||
m_b1a0 = 0.0f;
|
||||
m_b2a0 = (-alpha)*a0;
|
||||
m_a1a0 = (-2.0f*tcos)*a0;
|
||||
}
|
||||
else if( m_type == NOTCH )
|
||||
{
|
||||
m_b0a0 = a0;
|
||||
m_b1a0 = (-2.0f*tcos)*a0;
|
||||
m_b2a0 = a0;
|
||||
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
|
||||
}
|
||||
else if( m_type == ALLPASS )
|
||||
{
|
||||
m_b0a0 = (1.0f-alpha)*a0;
|
||||
m_b1a0 = (-2.0f*tcos)*a0;
|
||||
m_b2a0 = 1.0;//(1.0f+alpha)*a0;
|
||||
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
|
||||
//m_a2a0 = m_b0a0;//(1.0f-alpha)*a0;
|
||||
}
|
||||
m_a2a0 = (1.0f-alpha)*a0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// other filters
|
||||
const float omega = F_2PI * _freq / m_sampleRate;
|
||||
const float tsin = sinf( omega );
|
||||
const float tcos = cosf( omega );
|
||||
//float alpha;
|
||||
|
||||
//if (q_is_bandwidth)
|
||||
//alpha = tsin*sinhf(logf(2.0f)/2.0f*q*omega/
|
||||
// tsin);
|
||||
//else
|
||||
const float alpha = 0.5f * tsin / _q;
|
||||
|
||||
const float a0 = 1.0f / ( 1.0f + alpha );
|
||||
|
||||
switch( m_type )
|
||||
{
|
||||
case LOWPASS:
|
||||
case DOUBLE_LOWPASS:
|
||||
m_b0a0 = ( 1.0f - tcos ) * 0.5f * a0;
|
||||
m_b1a0 = ( 1.0f - tcos ) * a0;
|
||||
m_b2a0 = m_b0a0;//((1.0f-tcos)/2.0f)*a0;
|
||||
m_a1a0 = -2.0f * tcos * a0;
|
||||
if( m_type == DOUBLE_LOWPASS )
|
||||
{
|
||||
if( m_subFilter == NULL )
|
||||
{
|
||||
m_subFilter =
|
||||
new basicFilters<CHANNELS>( static_cast<sample_rate_t>(
|
||||
m_sampleRate ) );
|
||||
m_subFilter->setType( LOWPASS );
|
||||
}
|
||||
m_subFilter->calcFilterCoeffs( _freq,
|
||||
_q );
|
||||
}
|
||||
break;
|
||||
case HIPASS:
|
||||
m_b0a0 = ( 1.0f + tcos ) * 0.5f * a0;
|
||||
m_b1a0 = ( -1.0f - tcos ) * a0;
|
||||
m_b2a0 = m_b0a0;//((1.0f+tcos)/2.0f)*a0;
|
||||
m_a1a0 = -2.0f * tcos * a0;
|
||||
break;
|
||||
case BANDPASS_CSG:
|
||||
m_b0a0 = tsin * 0.5f * a0;
|
||||
m_b1a0 = 0.0f;
|
||||
m_b2a0 = -tsin * 0.5f * a0;
|
||||
m_a1a0 = -2.0f * tcos * a0;
|
||||
break;
|
||||
case BANDPASS_CZPG:
|
||||
m_b0a0 = alpha * a0;
|
||||
m_b1a0 = 0.0f;
|
||||
m_b2a0 = -alpha * a0;
|
||||
m_a1a0 = -2.0f * tcos * a0;
|
||||
break;
|
||||
case NOTCH:
|
||||
m_b0a0 = a0;
|
||||
m_b1a0 = -2.0f * tcos * a0;
|
||||
m_b2a0 = a0;
|
||||
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
|
||||
break;
|
||||
case ALLPASS:
|
||||
m_b0a0 = ( 1.0f - alpha ) * a0;
|
||||
m_b1a0 = -2.0f * tcos * a0;
|
||||
m_b2a0 = 1.0f;//(1.0f+alpha)*a0;
|
||||
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
|
||||
//m_a2a0 = m_b0a0;//(1.0f-alpha)*a0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m_a2a0 = ( 1.0f - alpha ) * a0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* buffer_allocator.h - namespace bufferAllocator providing routines for own
|
||||
* optimized memory-management for audio-buffers
|
||||
*
|
||||
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _BUFFER_ALLOCATOR_H
|
||||
#define _BUFFER_ALLOCATOR_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace bufferAllocator
|
||||
{
|
||||
void * FASTCALL allocBytes( const Uint32 _bytes );
|
||||
|
||||
template<class T>
|
||||
inline T * FASTCALL alloc( const Uint32 _n )
|
||||
{
|
||||
return( (T *) allocBytes( sizeof( T ) * _n ) );
|
||||
}
|
||||
|
||||
// free given buffer
|
||||
void FASTCALL free( void * _buf );
|
||||
|
||||
// try to cleanup _level unused buffers
|
||||
void FASTCALL cleanUp( const Uint16 _level );
|
||||
|
||||
// disable autocleanup-mechanisms
|
||||
void FASTCALL disableAutoCleanup( const bool _disabled );
|
||||
|
||||
|
||||
// simple class for automatically freeing buffer in complex functions
|
||||
template<class T = void>
|
||||
class autoCleaner
|
||||
{
|
||||
public:
|
||||
autoCleaner( T * _ptr ) :
|
||||
m_ptr( _ptr )
|
||||
{
|
||||
}
|
||||
~autoCleaner()
|
||||
{
|
||||
bufferAllocator::free( m_ptr );
|
||||
}
|
||||
inline const T * ptr( void ) const
|
||||
{
|
||||
return( m_ptr );
|
||||
}
|
||||
|
||||
private:
|
||||
T * m_ptr;
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -77,9 +77,9 @@ public:
|
||||
track * _track );
|
||||
virtual ~envelopeAndLFOWidget();
|
||||
|
||||
static inline float expKnobVal( float val )
|
||||
static inline float expKnobVal( float _val )
|
||||
{
|
||||
return( ( ( val < 0 ) ? -1 : 1 ) * val*val );
|
||||
return( ( ( _val < 0 ) ? -_val : _val ) * _val );
|
||||
}
|
||||
|
||||
static void triggerLFO( void );
|
||||
|
||||
@@ -114,7 +114,8 @@ private:
|
||||
QString m_tempoSyncDescription;
|
||||
|
||||
tempoSyncMode m_tempoLastSyncMode;
|
||||
meterDialog * m_custom;
|
||||
QPointer<meterDialog> m_custom;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user