merged note's tone and octave-property into one key-property which makes us save calculations in a lot of places and also shrinks sizes of XML-files, renamed various note-related constants and enums to match current coding-style

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@806 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-03-22 13:24:43 +00:00
parent 1809db2ed0
commit c31dbd6a09
35 changed files with 382 additions and 436 deletions

View File

@@ -38,7 +38,7 @@
#include "journalling_object.h"
const int NUM_FX_CHANNELS = 64;
const int NumFxChannels = 64;
class fader;
class fxLine;
@@ -72,7 +72,7 @@ public:
private:
fxChannel * m_fxChannels[NUM_FX_CHANNELS+1]; // +1 = master
fxChannel * m_fxChannels[NumFxChannels+1]; // +1 = master
friend class mixerWorkerThread;
@@ -111,7 +111,7 @@ private:
fader * m_fader;
} ;
fxChannelView m_fxChannelViews[NUM_FX_CHANNELS+1];
fxChannelView m_fxChannelViews[NumFxChannels+1];
QWidget * m_fxRackArea;
fxLine * m_currentFxLine;

View File

@@ -169,7 +169,7 @@ private:
midiPort * m_midiPort;
audioPort m_audioPort;
notePlayHandle * m_notes[NOTES_PER_OCTAVE * OCTAVES];
notePlayHandle * m_notes[NumKeys];
intModel m_baseNoteModel;

View File

@@ -47,16 +47,16 @@ class midiTime;
class midiPort
{
public:
enum modes
enum Modes
{
DUMMY, // don't route any MIDI-events (default)
INPUT, // from MIDI-client to MIDI-event-processor
OUTPUT, // from MIDI-event-processor to MIDI-client
DUPLEX // both directions
Disabled, // don't route any MIDI-events (default)
Input, // from MIDI-client to MIDI-event-processor
Output, // from MIDI-event-processor to MIDI-client
Duplex // both directions
} ;
midiPort( midiClient * _mc, midiEventProcessor * _mep,
const QString & _name, modes _mode = DUMMY );
const QString & _name, Modes _mode = Disabled );
~midiPort();
inline const QString & name( void ) const
@@ -66,12 +66,12 @@ public:
void FASTCALL setName( const QString & _name );
inline modes mode( void ) const
inline Modes mode( void ) const
{
return( m_mode );
}
void FASTCALL setMode( modes _mode );
void FASTCALL setMode( Modes _mode );
inline Sint8 inputChannel( void ) const
{
@@ -115,7 +115,7 @@ private:
midiClient * m_midiClient;
midiEventProcessor * m_midiEventProcessor;
QString m_name;
modes m_mode;
Modes m_mode;
Sint8 m_inputChannel;
Sint8 m_outputChannel;
bool m_defaultVelocityForInEventsEnabled;

View File

@@ -87,9 +87,9 @@ const Uint8 BYTES_PER_SURROUND_FRAME = sizeof( surroundSampleFrame );
const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f;
const float BASE_FREQ = 440.0f;
const tones BASE_TONE = A;
const octaves BASE_OCTAVE = OCTAVE_4;
const float BaseFreq = 440.0f;
const Keys BaseKey = Key_A;
const Octaves BaseOctave = DefaultOctave;
class mixerWorkerThread;

View File

@@ -2,7 +2,7 @@
* note.h - declaration of class note which contains all informations about a
* note + definitions of several constants and enums
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -37,45 +37,45 @@
class detuningHelper;
enum tones
enum Keys
{
C = 0,
CIS = 1, DES = 1,
D = 2,
DIS = 3, ES = 3,
E = 4, FES = 4,
F = 5,
FIS = 6, GES = 6,
G = 7,
GIS = 8, AS = 8,
A = 9,
AIS = 10, B = 10,
H = 11
Key_C = 0,
Key_CIS = 1, Key_DES = 1,
Key_D = 2,
Key_DIS = 3, Key_ES = 3,
Key_E = 4, Key_FES = 4,
Key_F = 5,
Key_FIS = 6, Key_GES = 6,
Key_G = 7,
Key_GIS = 8, Key_AS = 8,
Key_A = 9,
Key_AIS = 10, Key_B = 10,
Key_H = 11
} ;
enum octaves
enum Octaves
{
OCTAVE_0,
OCTAVE_1,
OCTAVE_2,
OCTAVE_3,
OCTAVE_4, // default
OCTAVE_5,
OCTAVE_6,
OCTAVE_7,
OCTAVE_8
Octave_0,
Octave_1,
Octave_2,
Octave_3,
Octave_4, DefaultOctave = Octave_4,
Octave_5,
Octave_6,
Octave_7,
Octave_8,
NumOctaves
} ;
const octaves DEFAULT_OCTAVE = OCTAVE_4;
const octaves MIN_OCTAVE = OCTAVE_0;
const octaves MAX_OCTAVE = OCTAVE_8;
const int WHITE_KEYS_PER_OCTAVE = 7;
const int BLACK_KEYS_PER_OCTAVE = 5;
const int NOTES_PER_OCTAVE = WHITE_KEYS_PER_OCTAVE + BLACK_KEYS_PER_OCTAVE;
const int OCTAVES = MAX_OCTAVE+1;
const int NOTES = OCTAVES*NOTES_PER_OCTAVE;
const int WhiteKeysPerOctave = 7;
const int BlackKeysPerOctave = 5;
const int KeysPerOctave = WhiteKeysPerOctave + BlackKeysPerOctave;
const int NumKeys = NumOctaves * KeysPerOctave;
const int DefaultKey = DefaultOctave*KeysPerOctave + Key_A;
const float MaxDetuning = 4 * 12.0f;
@@ -84,21 +84,18 @@ class note : public journallingObject
public:
note( const midiTime & _length = 0,
const midiTime & _pos = 0,
tones _tone = A,
octaves _octave = DEFAULT_OCTAVE,
volume _volume = DEFAULT_VOLUME,
panning _panning = DEFAULT_PANNING,
int key = DefaultKey,
volume _volume = DefaultVolume,
panning _panning = DefaultPanning,
detuningHelper * _detuning = NULL ) FASTCALL;
note( const note & _note );
virtual ~note();
void FASTCALL setLength( const midiTime & _length );
void FASTCALL setPos( const midiTime & _pos );
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 setVolume( const volume _volume = DefaultVolume );
void FASTCALL setPanning( const panning _panning = DefaultPanning );
void FASTCALL quantizeLength( const int _q_grid );
void FASTCALL quantizePos( const int _q_grid );
@@ -122,19 +119,9 @@ public:
return( m_pos - _base_pos );
}
inline tones tone( void ) const
{
return( m_tone );
}
inline octaves octave( void ) const
{
return( m_octave );
}
inline int key( void ) const
{
return( m_octave * NOTES_PER_OCTAVE + m_tone );
return( m_key );
}
inline volume getVolume( void ) const
@@ -180,17 +167,17 @@ protected:
private:
enum actions
enum Actions
{
CHANGE_KEY, CHANGE_VOLUME, CHANGE_PANNING,
CHANGE_LENGTH, CHANGE_POSITION
ChangeKey,
ChangeVolume,
ChangePanning,
ChangeLength,
ChangePosition
} ;
static const float MAX_DETUNING;
tones m_tone;
octaves m_octave;
int m_key;
volume m_volume;
panning m_panning;
midiTime m_length;

View File

@@ -2,7 +2,7 @@
* panning.h - declaration of some constants and types, concerning the
* panning of a note
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -28,9 +28,9 @@
#include "types.h"
const panning PANNING_RIGHT = ( 0 + 100);
const panning PANNING_LEFT = - PANNING_RIGHT;
const panning PANNING_CENTER = 0;
const panning DEFAULT_PANNING = PANNING_CENTER;
const panning PanningRight = ( 0 + 100);
const panning PanningLeft = - PanningRight;
const panning PanningCenter = 0;
const panning DefaultPanning = PanningCenter;
#endif

View File

@@ -61,7 +61,7 @@ public:
private:
instrumentTrack * m_instrumentTrack;
bool m_pressedKeys[NOTES_PER_OCTAVE * OCTAVES];
bool m_pressedKeys[NumKeys];
friend class pianoView;
@@ -104,9 +104,7 @@ private:
piano * m_piano;
QScrollBar * m_pianoScroll;
tones m_startTone; // first key when drawing
octaves m_startOctave;
int m_startKey; // first key when drawing
int m_lastKey;

View File

@@ -82,7 +82,7 @@ public:
bool FASTCALL play( sampleFrame * _ab, handleState * _state,
const fpp_t _frames,
const float _freq = BASE_FREQ,
const float _freq = BaseFreq,
const bool _looped = FALSE ) const;
void FASTCALL visualize( QPainter & _p, const QRect & _dr,

View File

@@ -2,7 +2,7 @@
* volume.h - declaration of some constants and types, concerning the volume
* of a note
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -28,8 +28,8 @@
#include "types.h"
const volume MIN_VOLUME = 0;
const volume MAX_VOLUME = 200;
const volume DEFAULT_VOLUME = 100;
const volume MinVolume = 0;
const volume MaxVolume = 200;
const volume DefaultVolume = 100;
#endif