diff --git a/include/instrument_track.h b/include/instrument_track.h index 3fcf177b6..be74080d1 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -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" @@ -211,8 +212,7 @@ private: intModel m_baseNoteModel; - QList m_processHandles; - + NotePlayHandleList m_processHandles; floatModel m_volumeModel; floatModel m_panningModel; diff --git a/include/note_play_handle.h b/include/note_play_handle.h index ba7ccf6ec..7c66c3a2d 100644 --- a/include/note_play_handle.h +++ b/include/note_play_handle.h @@ -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 + * Copyright (c) 2004-2009 Tobias Doerffel * * 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 class basicFilters; -typedef QVector notePlayHandleVector; -typedef QVector constNotePlayHandleVector; +typedef QList NotePlayHandleList; +typedef QList 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) diff --git a/include/preset_preview_play_handle.h b/include/preset_preview_play_handle.h index 657940f69..d358d3a76 100644 --- a/include/preset_preview_play_handle.h +++ b/include/preset_preview_play_handle.h @@ -48,7 +48,7 @@ public: static void init( void ); static void cleanup( void ); - static constNotePlayHandleVector nphsOfInstrumentTrack( + static ConstNotePlayHandleList nphsOfInstrumentTrack( const instrumentTrack * _ct ); diff --git a/plugins/patman/patman.cpp b/plugins/patman/patman.cpp index c8b8c6b38..c2a66c15f 100644 --- a/plugins/patman/patman.cpp +++ b/plugins/patman/patman.cpp @@ -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" diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 256710012..434c52e68 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -34,6 +34,7 @@ #include "engine.h" #include "gui_templates.h" +#include "instrument_track.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" diff --git a/src/core/engine.cpp b/src/core/engine.cpp index 3bf0d0945..89edb8d1d 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -33,6 +33,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" @@ -41,6 +42,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" diff --git a/src/core/instrument_functions.cpp b/src/core/instrument_functions.cpp index f0f879afb..13c8d30e8 100644 --- a/src/core/instrument_functions.cpp +++ b/src/core/instrument_functions.cpp @@ -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 ) { diff --git a/src/core/instrument_sound_shaping.cpp b/src/core/instrument_sound_shaping.cpp index ae77aa238..e1ed21573 100644 --- a/src/core/instrument_sound_shaping.cpp +++ b/src/core/instrument_sound_shaping.cpp @@ -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" diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index df7fdddae..0bacea6a0 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -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 ); diff --git a/src/core/preset_preview_play_handle.cpp b/src/core/preset_preview_play_handle.cpp index bb2bccf60..73f40ac0f 100644 --- a/src/core/preset_preview_play_handle.cpp +++ b/src/core/preset_preview_play_handle.cpp @@ -4,7 +4,7 @@ * preset_preview_play_handle.cpp - implementation of class * presetPreviewPlayHandle * - * Copyright (c) 2005-2008 Tobias Doerffel + * Copyright (c) 2005-2009 Tobias Doerffel * * 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 ) diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 9374b24b9..be50bf71b 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -522,7 +522,7 @@ void instrumentTrack::setName( const QString & _new_name ) void instrumentTrack::updateBaseNote( void ) { engine::getMixer()->lock(); - for( QList::iterator it = m_processHandles.begin(); + for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { ( *it )->updateFrequency(); @@ -584,7 +584,7 @@ bool instrumentTrack::play( const midiTime & _start, } // Handle automation: detuning - for( QList::iterator it = m_processHandles.begin(); + for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { ( *it )->processMidiTime( _start );