From c19f8df3292b8977ba0c85a8ff8b781ea757b699 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 21 Jan 2007 19:33:13 +0000 Subject: [PATCH] improved support for monophonic instruments git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@453 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 8 ++++++++ src/core/note_play_handle.cpp | 14 -------------- src/tracks/instrument_track.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25ded2ec4..f664bb121 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-01-21 Tobias Doerffel + + * src/core/note_play_handle.cpp: + removed obsolete support for monophonic instruments + + * src/tracks/instrument_track.cpp: + added new code for better support of monophonic instrument + 2007-01-20 Javier Serrano Polo * plugins/singerbot/artwork.png: diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index c6f92acaf..1f2c3c19f 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -63,20 +63,6 @@ notePlayHandle::notePlayHandle( instrumentTrack * _it, , m_patternIndex( 0 ) #endif { - // if the instrument is monophonic we do not allow other note-play- - // handles to exist for this track and therefore remove them - if( m_instrumentTrack->getInstrument()->isMonophonic() ) - { - constNotePlayHandleVector cphv = nphsOfInstrumentTrack( - m_instrumentTrack ); - for( constNotePlayHandleVector::iterator it = cphv.begin(); - it != cphv.end(); ++it ) - { - m_instrumentTrack->eng()->getMixer()-> - removePlayHandle( *it ); - } - } - setDetuning( _n.detuning() ); if( detuning() ) { diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index e4da18206..8f7ac08b5 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -757,6 +757,33 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing ) if( _n->arpBaseNote() == FALSE && m_instrument != NULL ) { + if( m_instrument->isMonophonic() ) + { + constNotePlayHandleVector v = + notePlayHandle::nphsOfInstrumentTrack( this, + TRUE ); + if( v.size() > 1 ) + { + constNotePlayHandleVector::iterator + youngest_note = v.begin(); + for( constNotePlayHandleVector::iterator it = + v.begin(); it != v.end(); ++it ) + { + if( !( *it )->arpBaseNote() && ( *it )->totalFramesPlayed() <= + ( *youngest_note )-> + totalFramesPlayed() ) + { + youngest_note = it; + } + } + if( *youngest_note != _n && !( *youngest_note )->arpBaseNote() ) + { + processInEvent( midiEvent( NOTE_OFF, 0, + _n->key(), 0 ), midiTime() ); + return; + } + } + } // all is done, so now lets play the note! m_instrument->playNote( _n, _try_parallelizing ); }