initial controllers code

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@883 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-04-04 06:39:00 +00:00
parent 20b949274d
commit 3541af29df
12 changed files with 315 additions and 7 deletions

View File

@@ -31,8 +31,10 @@
#include "journalling_object.h"
#include "level_object.h"
#include "mv_base.h"
#include "controller.h"
#include <QtCore/QPointer>
#include <QtCore/QObject>
@@ -102,11 +104,54 @@ public:
return( static_cast<T>( _v ) );
}
inline virtual T value( void ) const
inline virtual T value( void ) const
{
return value( 0 );
}
inline virtual T value( int _frameOffset ) const
{
return( m_value );
T val;
if( m_controller != NULL )
{
val = minValue() +
( maxValue() - minValue() ) *
castValue( m_controller->currentValue( _frameOffset ) );
// New framebuffer, emit signal for all the signal based users
if( _frameOffset == 0 && val != m_value )
{
// Sort of a hack, but this really is our intention
//
// Any model that wants sample-exactness must operate without relying
// on the dataChanged signal. This is primarily for updating the GUI
//autoModel * that = const_cast<autoModel *>( this );
//emit that->dataChanged();
}
}
else
{
val = m_value;
}
return val;
}
inline controller * getController( void ) const
{
return m_controller;
}
inline void setController( controller * _c )
{
m_controller = _c;
QObject::connect( m_controller, SIGNAL( valueChanged() ),
this, SIGNAL( dataChanged() ) );
}
inline virtual T initValue( void ) const
{
return( m_initValue );
@@ -200,12 +245,14 @@ protected:
private:
controller * m_controller;
T m_value;
T m_initValue;
T m_minValue;
T m_maxValue;
T m_step;
int m_curLevel;
QPointer<automationPattern> m_automationPattern;
track * m_track;
@@ -240,6 +287,14 @@ private:
{
return( level( attributeValue( _label ) ) );
}
/*
public slots:
void changeData( void )
{
emit dataChanged();
}
*/
} ;

View File

@@ -45,6 +45,7 @@ automatableModel<T, EDIT_STEP_TYPE>::automatableModel(
::model * _parent,
bool _default_constructed ) :
model( _parent, _default_constructed ),
m_controller( NULL ),
m_value( _val ),
m_initValue( _val ),
m_minValue( _min ),

96
include/controller.h Normal file
View File

@@ -0,0 +1,96 @@
/*
* controller.h - declaration of class controller, which provides a
* standard for all controllers and controller plugins
*
* Copyright (c) 2008 Paul Giblock <pgllama/at/gmail.com>
*
* 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 _CONTROLLER_H
#define _CONTROLLER_H
#include <QtCore/QObject>
#include <QtCore/QVector>
#include "engine.h"
#include "mixer.h"
class controller : public QObject
{
Q_OBJECT
public:
controller( void );
virtual ~controller();
virtual float currentValue( int _offset );
inline bool isSampleExact( void ) const
{
return m_sampleExact || engine::getMixer()->highQuality();
}
void setSampleExact( bool _exact )
{
m_sampleExact = _exact;
}
static int runningFrames();
static float runningTime();
static void triggerFrameCounter( void );
static void resetFrameCounter( void );
private:
protected:
// The internal per-controller get-value function
virtual float value( int _offset );
float m_currentValue;
bool m_sampleExact;
static QVector<controller *> s_controllers;
static unsigned int s_frames;
/*
QString publicName();
slots:
void trigger();
*/
signals:
// The value changed while the mixer isn't running (i.e: MIDI CC)
void valueChanged( void );
// Allow all attached models to unlink
void destroying( void );
};
#endif

View File

@@ -68,6 +68,7 @@ public slots:
void pasteValue( void );
virtual void enterValue( void );
void connectToMidiDevice( void );
void connectToController( void );
void displayHelp( void );