- added detuning knob

- added explicit constructor from another note


git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@226 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Javier Serrano Polo
2006-07-14 20:07:43 +00:00
parent 7147da59a3
commit dd3668dcd4
2 changed files with 111 additions and 2 deletions

View File

@@ -88,6 +88,9 @@ const int NOTES_PER_OCTAVE = WHITE_KEYS_PER_OCTAVE + BLACK_KEYS_PER_OCTAVE;
const int OCTAVES = 9;
class knob;
class note : public journallingObject
{
@@ -99,7 +102,7 @@ public:
octaves _octave = DEFAULT_OCTAVE,
volume _volume = DEFAULT_VOLUME,
panning _panning = DEFAULT_PANNING ) FASTCALL;
note( const note & _note );
virtual ~note();
void FASTCALL setLength( const midiTime & _length );
@@ -109,6 +112,7 @@ public:
void FASTCALL setKey( const int _key );
void FASTCALL setVolume( const volume _volume = DEFAULT_VOLUME );
void FASTCALL setPanning( const panning _panning = DEFAULT_PANNING );
void FASTCALL setDetuning( knob * _detuning );
void FASTCALL quantizeLength( const int _q_grid );
void FASTCALL quantizePos( const int _q_grid );
@@ -165,6 +169,14 @@ public:
static midiTime FASTCALL quantized( const midiTime & _m,
const int _q_grid );
knob * detuning( void ) const
{
return( m_detuning );
}
void editDetuningPattern( void );
void detachCurrentDetuning( void );
protected:
virtual void FASTCALL saveSettings( QDomDocument & _doc,
@@ -182,6 +194,8 @@ private:
CHANGE_LENGTH, CHANGE_POSITION
} ;
static const float MAX_DETUNING;
tones m_tone;
octaves m_octave;
@@ -189,6 +203,9 @@ private:
panning m_panning;
midiTime m_length;
midiTime m_pos;
knob * m_detuning;
void createDetuning( void );
} ;

View File

@@ -41,9 +41,14 @@
#include "debug.h"
#include "note.h"
#include "knob.h"
#include "templates.h"
const float note::MAX_DETUNING = 4 * 12.0f;
note::note( engine * _engine, const midiTime & _length, const midiTime & _pos,
tones _tone, octaves _octave, volume _volume,
@@ -54,7 +59,8 @@ note::note( engine * _engine, const midiTime & _length, const midiTime & _pos,
m_volume( DEFAULT_VOLUME ),
m_panning( DEFAULT_PANNING ),
m_length( _length ),
m_pos( _pos )
m_pos( _pos ),
m_detuning( NULL )
{
//saveJournallingState( FALSE );
setJournalling( FALSE );
@@ -64,14 +70,44 @@ note::note( engine * _engine, const midiTime & _length, const midiTime & _pos,
setVolume( _volume );
setPanning( _panning );
if( _engine )
{
createDetuning();
}
//restoreJournallingState();
}
note::note( const note & _note ) :
journallingObject( _note ),
m_tone( _note.m_tone ),
m_octave( _note.m_octave ),
m_volume( _note.m_volume ),
m_panning( _note.m_panning ),
m_length( _note.m_length ),
m_pos( _note.m_pos )
{
setDetuning( _note.m_detuning );
}
note::~note()
{
if( m_detuning )
{
if( m_detuning->data().toInt() )
{
m_detuning->setData( m_detuning->data().toInt() - 1 );
}
else
{
delete m_detuning;
}
}
}
@@ -190,6 +226,10 @@ void note::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "pan", m_panning );
_this.setAttribute( "len", m_length );
_this.setAttribute( "pos", m_pos );
if( m_length > 0 )
{
m_detuning->saveSettings( _doc, _this, "detuning" );
}
}
@@ -203,6 +243,7 @@ void note::loadSettings( const QDomElement & _this )
m_panning = _this.attribute( "pan" ).toInt();
m_length = _this.attribute( "len" ).toInt();
m_pos = _this.attribute( "pos" ).toInt();
m_detuning->loadSettings( _this, "detuning" );
}
@@ -247,4 +288,55 @@ void note::redoStep( journalEntry & _je )
void note::editDetuningPattern( void )
{
m_detuning->getAutomationPattern()->openInAutomationEditor();
}
void note::setDetuning( knob * _detuning )
{
m_detuning = _detuning;
if( m_detuning )
{
m_detuning->setData( m_detuning->data().toInt() + 1 );
}
}
void note::createDetuning( void )
{
m_detuning = new knob( knobDark_28, NULL,
QObject::tr( "Note detuning" ),
eng(), NULL );
m_detuning->initAutomationPattern( eng() );
m_detuning->setData( 0 );
m_detuning->setRange( -MAX_DETUNING, MAX_DETUNING, 0.1f );
}
void note::detachCurrentDetuning( void )
{
if( m_detuning->data().toInt() )
{
m_detuning->setData( m_detuning->data().toInt() - 1 );
QDomDocument doc;
QDomElement parent = doc.createElement( "clone" );
m_detuning->saveSettings( doc, parent );
createDetuning();
m_detuning->loadSettings( parent );
}
}
#endif