NotePlayHandle: cleanups, header dependency reductions etc.

* do not include instrument_track.h in note_play_handle.h by making
  two functions non-inline
* renamed notePlayHandleVector / constNotePlayHandleVector to
  NotePlayHandleList / ConstNotePlayHandleList and changed typedef
  to QList (which has faster insert- and remove-operations).
* removed unused method willFinishThisPeriod()

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-15 14:36:56 +02:00
parent 8fb10e3d4d
commit 08ea133aa2
11 changed files with 45 additions and 82 deletions

View File

@@ -34,6 +34,7 @@
#include "instrument_sound_shaping.h"
#include "midi_event_processor.h"
#include "midi_port.h"
#include "note_play_handle.h"
#include "piano.h"
#include "track.h"
@@ -210,7 +211,7 @@ private:
notePlayHandle * m_notes[NumKeys];
int m_runningMidiNotes[NumKeys];
QList<notePlayHandle *> m_processHandles;
NotePlayHandleList m_processHandles;
floatModel m_volumeModel;

View File

@@ -2,7 +2,7 @@
* note_play_handle.h - declaration of class notePlayHandle which is needed
* by LMMS-Play-Engine
*
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -30,16 +30,16 @@
#include "lmmsconfig.h"
#include "mixer.h"
#include "note.h"
#include "instrument.h"
#include "instrument_track.h"
#include "engine.h"
#include "track.h"
class instrumentTrack;
class notePlayHandle;
template<ch_cnt_t=DEFAULT_CHANNELS> class basicFilters;
typedef QVector<notePlayHandle *> notePlayHandleVector;
typedef QVector<const notePlayHandle *> constNotePlayHandleVector;
typedef QList<notePlayHandle *> NotePlayHandleList;
typedef QList<const notePlayHandle *> ConstNotePlayHandleList;
class EXPORT notePlayHandle : public playHandle, public note
@@ -79,55 +79,6 @@ public:
return m_released && framesLeft() <= 0;
}
bool willFinishThisPeriod( void ) const
{
f_cnt_t rftd = m_releaseFramesToDo;
f_cnt_t fbr = m_framesBeforeRelease;
f_cnt_t rfd = m_releaseFramesDone;
if( m_released == TRUE )
{
f_cnt_t todo = engine::getMixer()->framesPerPeriod();
if( isArpeggioBaseNote() )
{
rftd = rfd + 2 *
engine::getMixer()->framesPerPeriod();
}
if( fbr )
{
if( fbr <=
engine::getMixer()->framesPerPeriod() )
{
todo -= fbr;
fbr = 0;
}
else
{
todo = 0;
fbr -=
engine::getMixer()->framesPerPeriod();
}
}
if( todo && rfd < rftd )
{
if( rftd - rfd >= todo )
{
rfd += todo;
}
else
{
rfd = rftd;
}
}
}
if( isArpeggioBaseNote() && m_subNotes.size() == 0 )
{
rfd = rftd;
}
return ( m_released && fbr == 0 && rfd >= rftd );
}
f_cnt_t framesLeft( void ) const;
inline fpp_t framesLeftForCurrentPeriod( void ) const
@@ -202,11 +153,7 @@ public:
}
// returns whether note is base-note for arpeggio
inline bool isArpeggioBaseNote( void ) const
{
return isBaseNote() && ( m_partOfArpeggio ||
m_instrumentTrack->arpeggiatorEnabled() );
}
bool isArpeggioBaseNote( void ) const;
inline bool isMuted( void ) const
{
@@ -219,15 +166,15 @@ public:
// belonging to this instrument-track - used by arpeggiator
int index( void ) const;
// note-play-handles belonging to given channel, if _all_ph = TRUE,
// note-play-handles belonging to given channel, if _all_ph = true,
// also released note-play-handles are returned
static constNotePlayHandleVector nphsOfInstrumentTrack(
const instrumentTrack * _ct, bool _all_ph = FALSE );
static ConstNotePlayHandleList nphsOfInstrumentTrack(
const instrumentTrack * _ct, bool _all_ph = false );
// return whether given note-play-handle is equal to *this
bool operator==( const notePlayHandle & _nph ) const;
bool bbTrackMuted( void )
inline bool bbTrackMuted( void )
{
return m_bbTrack && m_bbTrack->isMuted();
}
@@ -288,7 +235,7 @@ private:
// played after release
f_cnt_t m_releaseFramesDone; // number of frames done after
// release of note
notePlayHandleVector m_subNotes;// used for chords and arpeggios
NotePlayHandleList m_subNotes; // used for chords and arpeggios
volatile bool m_released; // indicates whether note is released
bool m_baseNote; // indicates whether note is a
// base-note (i.e. no sub-note)

View File

@@ -48,7 +48,7 @@ public:
static void init( void );
static void cleanup( void );
static constNotePlayHandleVector nphsOfInstrumentTrack(
static ConstNotePlayHandleList nphsOfInstrumentTrack(
const instrumentTrack * _ct );

View File

@@ -33,6 +33,7 @@
#include "endian_handling.h"
#include "engine.h"
#include "gui_templates.h"
#include "instrument_track.h"
#include "note_play_handle.h"
#include "pixmap_button.h"
#include "song.h"

View File

@@ -34,6 +34,7 @@
#include "engine.h"
#include "gui_templates.h"
#include "instrument_track.h"
#undef SINGLE_SOURCE_COMPILE
#include "embed.cpp"

View File

@@ -36,6 +36,7 @@
#include "controller_rack_view.h"
#include "fx_mixer.h"
#include "fx_mixer_view.h"
#include "instrument_track.h"
#include "ladspa_2_lmms.h"
#include "main_window.h"
#include "mixer.h"
@@ -44,6 +45,7 @@
#include "preset_preview_play_handle.h"
#include "project_journal.h"
#include "project_notes.h"
#include "plugin.h"
#include "song_editor.h"
#include "song.h"
#include "midi_control_listener.h"

View File

@@ -305,7 +305,7 @@ void arpeggiator::processNote( notePlayHandle * _n )
const int selected_arp = m_arpModel.value();
constNotePlayHandleVector cnphv = notePlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList cnphv = notePlayHandle::nphsOfInstrumentTrack(
_n->getInstrumentTrack() );
if( m_arpModeModel.value() != FreeMode && cnphv.size() == 0 )
{

View File

@@ -33,6 +33,7 @@
#include "embed.h"
#include "engine.h"
#include "envelope_and_lfo_parameters.h"
#include "instrument.h"
#include "instrument_track.h"
#include "note_play_handle.h"

View File

@@ -136,7 +136,7 @@ notePlayHandle::~notePlayHandle()
m_instrumentTrack->m_notes[key()] = NULL;
}
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); ++it )
{
delete *it;
@@ -252,7 +252,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer )
}
// play sub-notes (e.g. chords)
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); )
{
( *it )->play( _working_buffer );
@@ -316,7 +316,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
}
// first note-off all sub-notes
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); ++it )
{
( *it )->noteOff( _s );
@@ -373,10 +373,19 @@ float notePlayHandle::volumeLevel( const f_cnt_t _frame )
bool notePlayHandle::isArpeggioBaseNote( void ) const
{
return isBaseNote() && ( m_partOfArpeggio ||
m_instrumentTrack->arpeggiatorEnabled() );
}
void notePlayHandle::mute( void )
{
// mute all sub-notes
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); ++it )
{
( *it )->mute();
@@ -391,7 +400,7 @@ int notePlayHandle::index( void ) const
{
const playHandleVector & phv = engine::getMixer()->playHandles();
int idx = 0;
for( constPlayHandleVector::const_iterator it = phv.begin();
for( constPlayHandleVector::ConstIterator it = phv.begin();
it != phv.end(); ++it )
{
const notePlayHandle * nph =
@@ -414,13 +423,13 @@ int notePlayHandle::index( void ) const
constNotePlayHandleVector notePlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList notePlayHandle::nphsOfInstrumentTrack(
const instrumentTrack * _it, bool _all_ph )
{
const playHandleVector & phv = engine::getMixer()->playHandles();
constNotePlayHandleVector cnphv;
ConstNotePlayHandleList cnphv;
for( constPlayHandleVector::const_iterator it = phv.begin();
for( constPlayHandleVector::ConstIterator it = phv.begin();
it != phv.end(); ++it )
{
const notePlayHandle * nph =
@@ -466,7 +475,7 @@ void notePlayHandle::updateFrequency( void )
m_instrumentTrack->pitchModel()->value() / ( 100 * 12.0f ) );
m_unpitchedFrequency = BaseFreq * powf( 2.0f, pitch );
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); ++it )
{
( *it )->updateFrequency();
@@ -500,7 +509,7 @@ void notePlayHandle::resize( const bpm_t _new_tempo )
m_frames = (f_cnt_t)new_frames;
m_totalFramesPlayed = (f_cnt_t)( completed * new_frames );
for( notePlayHandleVector::iterator it = m_subNotes.begin();
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
it != m_subNotes.end(); ++it )
{
( *it )->resize( _new_tempo );

View File

@@ -4,7 +4,7 @@
* preset_preview_play_handle.cpp - implementation of class
* presetPreviewPlayHandle
*
* 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
*
@@ -32,6 +32,7 @@
#include "preset_preview_play_handle.h"
#include "debug.h"
#include "engine.h"
#include "instrument.h"
#include "instrument_track.h"
#include "midi_port.h"
#include "mmp.h"
@@ -230,10 +231,10 @@ void presetPreviewPlayHandle::cleanup( void )
constNotePlayHandleVector presetPreviewPlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList presetPreviewPlayHandle::nphsOfInstrumentTrack(
const instrumentTrack * _it )
{
constNotePlayHandleVector cnphv;
ConstNotePlayHandleList cnphv;
s_previewTC->lockData();
if( s_previewTC->previewNote() != NULL &&
s_previewTC->previewNote()->getInstrumentTrack() == _it )

View File

@@ -521,7 +521,7 @@ void instrumentTrack::setName( const QString & _new_name )
void instrumentTrack::updateBaseNote( void )
{
engine::getMixer()->lock();
for( QList<notePlayHandle *>::iterator it = m_processHandles.begin();
for( NotePlayHandleList::Iterator it = m_processHandles.begin();
it != m_processHandles.end(); ++it )
{
( *it )->updateFrequency();
@@ -592,7 +592,7 @@ bool instrumentTrack::play( const midiTime & _start,
}
// Handle automation: detuning
for( QList<notePlayHandle *>::iterator it = m_processHandles.begin();
for( NotePlayHandleList::Iterator it = m_processHandles.begin();
it != m_processHandles.end(); ++it )
{
( *it )->processMidiTime( _start );