bugfixes and some small new features

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@89 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-02-23 11:14:15 +00:00
parent c77af5f46f
commit 1ef530bde2
115 changed files with 1059 additions and 263 deletions

198
include/automatable_object.h Executable file
View File

@@ -0,0 +1,198 @@
/*
* automatable_object.h - declaration of class automatableObject
*
* Copyright (c) 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef _AUTOMATABLE_OBJECT_H
#define _AUTOMATABLE_OBJECT_H
#include <math.h>
#include "templates.h"
template<typename T>
class automatableObject
{
public:
automatableObject( const T _val = 0, const T _min = 0,
const T _max = 0, const T _step = 1 ) :
m_value( _val ),
m_minValue( _min ),
m_maxValue( _max ),
m_step( _step )
{
}
virtual ~automatableObject()
{
}
static inline T minRelStep( void )
{
return( 1 );
}
static inline T defaultRelStep( void )
{
return( 1 );
}
static inline T minEps( void )
{
return( 1 );
}
inline virtual T value( void ) const
{
return( m_value );
}
inline virtual T minValue( void ) const
{
return( m_minValue );
}
inline virtual T maxValue( void ) const
{
return( m_maxValue );
}
inline virtual T step( void ) const
{
return( m_step );
}
inline virtual void setValue( const T _value )
{
m_value = tLimit<T>( _value, minValue(), maxValue() );
if( m_step != 0 )
{
m_value = static_cast<T>( floorf( m_value / m_step ) *
m_step );
}
else
{
m_value = m_minValue;
}
// correct rounding error at the border
if( tAbs<T>( m_value - m_maxValue ) < minEps() *
tAbs<T>( m_step ) )
{
m_value = m_maxValue;
}
// correct rounding error if value = 0
if( tAbs<T>( m_value ) < minEps() * tAbs<T>( m_step ) )
{
m_value = 0;
}
}
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 = 0 )
{
m_minValue = _min;
m_maxValue = _max;
setStep( _step );
if( m_minValue > m_maxValue )
{
qSwap<T>( m_minValue, m_maxValue );
}
// re-adjust value
setValue( value() );
}
inline virtual void 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;
}
private:
T m_value;
T m_minValue;
T m_maxValue;
T m_step;
} ;
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 );
}
#endif

View File

@@ -1,7 +1,7 @@
/*
* group_box.h - LMMS-groupbox
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -48,7 +48,7 @@ class groupBox : public QWidget
Q_OBJECT
public:
groupBox( const QString & _caption, QWidget * _parent );
~groupBox();
virtual ~groupBox();
bool isActive( void ) const
{

View File

@@ -33,7 +33,7 @@
class instrumentPlayHandle : public playHandle
{
public:
inline instrumentPlayHandle( instrument * _instrument ) FASTCALL :
inline instrumentPlayHandle( instrument * _instrument ) :
playHandle( INSTRUMENT_PLAY_HANDLE, _instrument->eng() ),
m_instrument( _instrument )
{

View File

@@ -45,6 +45,7 @@
#include "engine.h"
#include "automatable_object.h"
class QPixmap;
@@ -58,7 +59,8 @@ enum knobTypes
class knob : public QWidget, public engineObject
class knob : public QWidget, public engineObject,
public automatableObject<float>
{
Q_OBJECT
public:
@@ -73,10 +75,18 @@ public:
void setTotalAngle( float _angle );
void setRange( float _vmin, float _vmax, float _vstep = 0.0,
int _pagesize = 1 );
inline void setInitValue( const float _val )
{
m_initValue = _val;
setValue( _val );
}
inline float value( void ) const
virtual void setValue( const float _x );
virtual void setRange( const float _min, const float _max,
const float _step = 0.0 );
/* inline float value( void ) const
{
return( m_value );
}
@@ -90,19 +100,19 @@ public:
inline float minValue( void ) const
{
return( m_minValue );
}
}*/
inline void incPages( int _n_pages )
/* inline void incPages( int _n_pages )
{
setNewValue( m_value + float( _n_pages ) * m_pageSize, 1 );
}
setNewValue( value() + float( _n_pages ) * m_pageSize, 1 );
}*/
public slots:
void setValue( float _val, bool _is_init_value = FALSE );
/* void setValue( float _val, bool _is_init_value = FALSE );
void fitValue( float _val );
void incValue( int _steps );
void incValue( int _steps );*/
void reset( void );
void copyValue( void );
void pasteValue( void );
@@ -148,7 +158,6 @@ protected:
void buttonReleased( void );
void setNewValue( float _x, bool _align = FALSE );
static float s_copiedValue;
@@ -160,6 +169,7 @@ protected:
bool m_buttonPressed;
float m_pageSize;
float m_angle;
float m_totalAngle;
@@ -170,14 +180,6 @@ protected:
QString m_label;
float m_minValue;
float m_maxValue;
float m_step;
float m_pageSize;
float m_value;
float m_exactValue;
float m_exactPrevValue;
float m_prevValue;
float m_initValue;
} ;

View File

@@ -41,22 +41,25 @@
#endif
#include "automatable_object.h"
class QLabel;
class lcdSpinBox : public QWidget
class lcdSpinBox : public QWidget, public automatableObject<int>
{
Q_OBJECT
public:
lcdSpinBox( int _min, int _max, int _num_digits, QWidget * _parent );
virtual ~lcdSpinBox();
void setStep( int _step );
virtual void setStep( const int _step );
inline int value( void ) const
/* inline int value( void ) const
{
return( m_number->intValue() );
}
}*/
void setLabel( const QString & _txt );
@@ -67,7 +70,7 @@ public:
public slots:
void setValue( int _value );
virtual void setValue( const int _value );
virtual void setEnabled( bool _on );
@@ -81,10 +84,10 @@ protected:
private:
QMap<int, QString> m_textForValue;
int m_value;
/* int m_value;
int m_minValue;
int m_maxValue;
int m_step;
int m_step;*/
QLCDNumber * m_number;
QLabel * m_label;

View File

@@ -1,7 +1,7 @@
/*
* led_checkbox.h - class ledCheckBox, an improved QCheckBox
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -39,10 +39,13 @@
#endif
#include "automatable_object.h"
class QPixmap;
class ledCheckBox : public QWidget
class ledCheckBox : public QWidget, public automatableObject<bool>
{
Q_OBJECT
public:
@@ -58,7 +61,7 @@ public:
inline bool isChecked( void ) const
{
return( m_checked );
return( value() );
}
inline const QString & text( void )
@@ -81,7 +84,6 @@ private:
QPixmap * m_ledOnPixmap;
QPixmap * m_ledOffPixmap;
bool m_checked;
QString m_text;
signals:

View File

@@ -1,7 +1,7 @@
/*
* midi_mapper.h - MIDI-mapper for any midiDevice
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -43,11 +43,11 @@
#include "types.h"
#include "midi.h"
const Uint8 MIDI_PROGRAMS = 128;
const Uint8 MIDI_KEYS = 128;
const Uint8 MIDI_CHANNELS = 16;
class midiMapper
{
@@ -104,7 +104,7 @@ private:
QPair<Uint8, QString> m_patchMap[MIDI_PROGRAMS];
QPair<Uint8, QString> m_drumsetKeyMap[MIDI_KEYS];
Uint8 m_channelMap[MIDI_CHANNELS];
Uint8 m_channelMap[MIDI_CHANNEL_COUNT];
Uint8 m_drumsetChannel;
Uint8 m_drumsetPatch;

View File

@@ -161,16 +161,18 @@ public:
// play-handle stuff
inline void addPlayHandle( playHandle * _ph )
inline bool addPlayHandle( playHandle * _ph )
{
if( criticalXRuns() == FALSE )
{
m_playHandles.push_back( _ph );
return( TRUE );
}
else
{
delete _ph;
}
return( FALSE );
}
inline void removePlayHandle( playHandle * _ph )

View File

@@ -101,11 +101,13 @@ public:
void FASTCALL setLength( const midiTime & _length );
void FASTCALL setPos( const midiTime & _pos );
void FASTCALL setTone( tones _tone = C );
void FASTCALL setOctave( octaves _octave = DEFAULT_OCTAVE );
void FASTCALL setKey( int _key );
void FASTCALL setVolume( volume _volume = DEFAULT_VOLUME );
void FASTCALL setPanning( panning _panning = DEFAULT_PANNING );
void FASTCALL setTone( const tones _tone = C );
void FASTCALL setOctave( const octaves _octave = DEFAULT_OCTAVE );
void FASTCALL setKey( const int _key );
void FASTCALL setVolume( const volume _volume = DEFAULT_VOLUME );
void FASTCALL setPanning( const panning _panning = DEFAULT_PANNING );
void FASTCALL quantizeLength( const int _q_grid );
void FASTCALL quantizePos( const int _q_grid );
inline midiTime endPos( void ) const
{
@@ -162,6 +164,8 @@ public:
private:
midiTime FASTCALL quantized( const midiTime & _m, const int _q_grid );
tones m_tone;
octaves m_octave;
volume m_volume;

View File

@@ -47,7 +47,7 @@ public:
notePlayHandle( channelTrack * _chnl_trk, const f_cnt_t _frames_ahead,
const f_cnt_t _frames, note * _n,
const bool _arp_note = FALSE ) FASTCALL;
const bool _arp_note = FALSE );
virtual ~notePlayHandle();

View File

@@ -80,6 +80,8 @@ public:
return( m_pattern != NULL );
}
int quantization( void ) const;
public slots:
virtual void update( void );
@@ -165,6 +167,8 @@ private:
pianoRoll( const pianoRoll & );
virtual ~pianoRoll();
midiTime newNoteLen( void ) const;
static QPixmap * s_whiteKeyBigPm;
static QPixmap * s_whiteKeySmallPm;
@@ -193,6 +197,8 @@ private:
toolButton * m_pasteButton;
comboBox * m_zoomingComboBox;
comboBox * m_quantizeComboBox;
comboBox * m_noteLenComboBox;
QPixmap m_paintPixmap;
bool m_cursorInside;

View File

@@ -56,7 +56,7 @@ public:
PRESET_PREVIEW_PLAY_HANDLE
} ;
inline playHandle( const types _type, engine * _engine ) FASTCALL :
playHandle( const types _type, engine * _engine ) :
engineObject( _engine ),
m_type( _type )
{

View File

@@ -53,7 +53,7 @@ class presetPreviewPlayHandle : public playHandle
{
public:
presetPreviewPlayHandle( const QString & _preset_file,
engine * _engine ) FASTCALL;
engine * _engine );
virtual ~presetPreviewPlayHandle();
virtual void play( void );

View File

@@ -35,6 +35,7 @@
#else
#include <qmainwindow.h>
#define textColor color
#endif

View File

@@ -37,9 +37,8 @@ class audioPort;
class samplePlayHandle : public playHandle
{
public:
samplePlayHandle( const QString & _sample_file, engine * _engine )
FASTCALL;
samplePlayHandle( sampleBuffer * _sample_buffer ) FASTCALL;
samplePlayHandle( const QString & _sample_file, engine * _engine );
samplePlayHandle( sampleBuffer * _sample_buffer );
virtual ~samplePlayHandle();
virtual void play( void );