Moved baseNoteModel from InstrumentTrack to MidiEventProcessor; cleanups

Moved baseNoteModel from InstrumentTrack class to MidiEventProcessor
class in order to make Piano class independent from InstrumentTrack
class (so it can be used by other classes as well).

Furthermore did various cleanups and coding style improvements.
This commit is contained in:
Tobias Doerffel
2009-05-29 01:31:50 +02:00
parent 7fd599a2f9
commit 8395c9428c
11 changed files with 146 additions and 149 deletions

View File

@@ -58,7 +58,7 @@ class tabWidget;
class trackLabelButton;
class EXPORT instrumentTrack : public track, public midiEventProcessor
class EXPORT instrumentTrack : public track, public MidiEventProcessor
{
Q_OBJECT
mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel);
@@ -143,12 +143,7 @@ public:
return &m_midiPort;
}
intModel * baseNoteModel( void )
{
return &m_baseNoteModel;
}
piano * getPiano( void )
Piano * getPiano( void )
{
return &m_piano;
}
@@ -217,8 +212,6 @@ private:
notePlayHandle * m_notes[NumKeys];
int m_runningMidiNotes[NumKeys];
intModel m_baseNoteModel;
QList<notePlayHandle *> m_processHandles;
@@ -234,7 +227,7 @@ private:
arpeggiator m_arpeggiator;
chordCreator m_chordCreator;
piano m_piano;
Piano m_piano;
friend class instrumentTrackView;
@@ -401,7 +394,7 @@ private:
effectRackView * m_effectView;
// test-piano at the bottom of every instrument-settings-window
pianoView * m_pianoView;
PianoView * m_pianoView;
friend class instrumentView;

View File

@@ -31,7 +31,7 @@
#include "midi_port.h"
#include "note.h"
class MidiControlListener : public midiEventProcessor
class MidiControlListener : public MidiEventProcessor
{
public:
typedef enum

View File

@@ -36,7 +36,7 @@
class midiPort;
class midiController : public controller, public midiEventProcessor
class midiController : public controller, public MidiEventProcessor
{
Q_OBJECT
public:

View File

@@ -1,7 +1,8 @@
/*
* midi_event_processor.h - base-class for midi-processing classes
* midi_event_processor.h - class MidiEventProcessor, a base class for all
* midi-processing classes
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,28 +27,47 @@
#ifndef _MIDI_EVENT_PROCESSOR_H
#define _MIDI_EVENT_PROCESSOR_H
class midiEvent;
class midiTime;
#include "piano.h"
#include "automatable_model.h"
// all classes being able to process MIDI-events should inherit from this
class midiEventProcessor
class MidiEventProcessor
{
public:
inline midiEventProcessor( void )
inline MidiEventProcessor() :
m_baseNoteModel( DefaultKey,
0,
KeysPerOctave * NumOctaves - 1,
NULL,
PianoView::tr( "Base note" ) )
{
}
virtual inline ~midiEventProcessor()
virtual inline ~MidiEventProcessor()
{
}
intModel * baseNoteModel( void )
{
return &m_baseNoteModel;
}
const intModel * baseNoteModel( void ) const
{
return &m_baseNoteModel;
}
// to be implemented by inheriting classes
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time ) = 0;
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time ) = 0;
private:
intModel m_baseNoteModel;
} ;
#endif

View File

@@ -36,7 +36,7 @@
class midiClient;
class midiEventProcessor;
class MidiEventProcessor;
class midiPortMenu;
class midiTime;
@@ -74,7 +74,7 @@ public:
midiPort( const QString & _name,
midiClient * _mc,
midiEventProcessor * _mep,
MidiEventProcessor * _mep,
model * _parent = NULL,
Modes _mode = Disabled );
virtual ~midiPort();
@@ -142,7 +142,7 @@ private slots:
private:
midiClient * m_midiClient;
midiEventProcessor * m_midiEventProcessor;
MidiEventProcessor * m_midiEventProcessor;
Modes m_mode;

View File

@@ -1,5 +1,5 @@
/*
* piano.h - piano and pianoView, an interactive piano/keyboard-widget
* piano.h - Piano and PianoView, an interactive piano/keyboard-widget
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -26,32 +26,25 @@
#ifndef _PIANO_H
#define _PIANO_H
#include <QtGui/QWidget>
#include <QtGui/QPixmap>
#include <QtGui/QScrollBar>
#include "note.h"
#include "automatable_model.h"
#include "mv_base.h"
class MidiEventProcessor;
class instrumentTrack;
class instrumentTrackView;
class notePlayHandle;
enum KeyTypes
{
WhiteKey,
BlackKey
} ;
class piano : public model
class Piano : public model
{
public:
piano( instrumentTrack * _it );
virtual ~piano();
enum KeyTypes
{
WhiteKey,
BlackKey
} ;
Piano( MidiEventProcessor * _mep );
virtual ~Piano();
void setKeyState( int _key, bool _on = FALSE );
@@ -60,22 +53,22 @@ public:
private:
instrumentTrack * m_instrumentTrack;
MidiEventProcessor * m_midiEvProc;
bool m_pressedKeys[NumKeys];
friend class pianoView;
friend class PianoView;
} ;
class pianoView : public QWidget, public modelView
class PianoView : public QWidget, public modelView
{
Q_OBJECT
public:
pianoView( QWidget * _parent );
virtual ~pianoView();
PianoView( QWidget * _parent );
virtual ~PianoView();
static int getKeyFromKeyEvent( QKeyEvent * _ke );
@@ -101,7 +94,7 @@ private:
static QPixmap * s_whiteKeyPressedPm;
static QPixmap * s_blackKeyPressedPm;
piano * m_piano;
Piano * m_piano;
QScrollBar * m_pianoScroll;
int m_startKey; // first key when drawing