Instrument: introduced flags to replace virtual property getters
There'll be more and more flags for instruments. Handling them using virtual and overloaded getter functions doesn't scale well and adds unneccessary overhead.
This commit is contained in:
@@ -44,6 +44,16 @@ class track;
|
||||
class EXPORT Instrument : public Plugin
|
||||
{
|
||||
public:
|
||||
enum Flag
|
||||
{
|
||||
NoFlags = 0x00,
|
||||
IsSingleStreamed = 0x01, /*! Instrument provides a single audio stream for all notes */
|
||||
IsMidiBased = 0x02, /*! Instrument is controlled by MIDI events rather than NotePlayHandles */
|
||||
IsNotBendable = 0x04, /*! Instrument can't react to pitch bend changes */
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Flags, Flag);
|
||||
|
||||
Instrument( InstrumentTrack * _instrument_track,
|
||||
const Descriptor * _descriptor );
|
||||
virtual ~Instrument();
|
||||
@@ -84,17 +94,9 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// return false if instrument is not bendable
|
||||
inline virtual bool isBendable() const
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// return true if instruments reacts to MIDI events passed to
|
||||
// handleMidiEvent() rather than playNote() & Co
|
||||
inline virtual bool isMidiBased() const
|
||||
{
|
||||
return false;
|
||||
return NoFlags;
|
||||
}
|
||||
|
||||
// sub-classes can re-implement this for receiving all incoming
|
||||
@@ -135,4 +137,6 @@ private:
|
||||
|
||||
} ;
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Instrument::Flags)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -48,7 +48,10 @@ public:
|
||||
virtual QString nodeName() const;
|
||||
virtual PluginView * instantiateView( QWidget * _parent );
|
||||
|
||||
inline virtual bool isMidiBased() const { return true; }
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return IsSingleStreamed | IsMidiBased;
|
||||
}
|
||||
|
||||
virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time );
|
||||
virtual void play( sampleFrame * _working_buffer );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* sf2_player.h - a soundfont2 player using fluidSynth
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
* Copyright (c) 2009-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2009-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -77,9 +77,9 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool isMidiBased() const
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return true;
|
||||
return IsSingleStreamed | IsMidiBased;
|
||||
}
|
||||
|
||||
virtual PluginView * instantiateView( QWidget * _parent );
|
||||
|
||||
@@ -63,9 +63,9 @@ public:
|
||||
|
||||
virtual void loadFile( const QString & _file );
|
||||
|
||||
virtual bool isMidiBased( void ) const
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return true;
|
||||
return IsSingleStreamed | IsMidiBased;
|
||||
}
|
||||
|
||||
virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time );
|
||||
|
||||
@@ -52,11 +52,12 @@ public:
|
||||
|
||||
virtual QString nodeName() const;
|
||||
|
||||
inline virtual bool isBendable() const
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return( false );
|
||||
return IsNotBendable;
|
||||
}
|
||||
|
||||
|
||||
virtual PluginView * instantiateView( QWidget * _parent );
|
||||
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
|
||||
virtual QString nodeName() const;
|
||||
|
||||
virtual bool isMidiBased() const
|
||||
virtual Flags flags() const
|
||||
{
|
||||
return true;
|
||||
return IsSingleStreamed | IsMidiBased;
|
||||
}
|
||||
|
||||
virtual PluginView * instantiateView( QWidget * _parent );
|
||||
|
||||
@@ -1319,7 +1319,7 @@ void InstrumentTrackWindow::modelChanged()
|
||||
m_effectChannelNumber->setModel( &m_track->m_effectChannelModel );
|
||||
m_pianoView->setModel( &m_track->m_piano );
|
||||
|
||||
if( m_track->instrument() && m_track->instrument()->isBendable() )
|
||||
if( m_track->instrument() && m_track->instrument()->flags().testFlag( Instrument::IsNotBendable ) == false )
|
||||
{
|
||||
m_pitchKnob->setModel( &m_track->m_pitchModel );
|
||||
m_pitchRangeSpinBox->setModel( &m_track->m_pitchRangeModel );
|
||||
|
||||
Reference in New Issue
Block a user