InstrumentTrack, NotePlayHandle: fixed note detuning processing

Note detuning did not work properly for patterns starting after the
first bar in the song editor. This has been fixed by introducing
additional information about parent's song-global offset to
NotePlayHandle objects.

Closes #3462555.
This commit is contained in:
Tobias Doerffel
2012-01-29 11:36:24 +01:00
parent 132ab41e5d
commit 5977041b6e
3 changed files with 29 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
* note_play_handle.h - declaration of class notePlayHandle which is needed
* by LMMS-Play-Engine
*
* Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -192,6 +192,16 @@ public:
void processMidiTime( const midiTime & _time );
void resize( const bpm_t _new_tempo );
void setSongGlobalParentOffset( const midiTime &offset )
{
m_songGlobalParentOffset = offset;
}
const midiTime &songGlobalParentOffset() const
{
return m_songGlobalParentOffset;
}
#ifdef LMMS_SINGERBOT_SUPPORT
int patternIndex()
{
@@ -263,6 +273,7 @@ private:
float m_unpitchedFrequency;
BaseDetuning * m_baseDetuning;
midiTime m_songGlobalParentOffset;
} ;

View File

@@ -2,7 +2,7 @@
* note_play_handle.cpp - implementation of class notePlayHandle, part of
* rendering engine
*
* Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -70,7 +70,11 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
m_patternIndex( 0 ),
#endif
m_origTempo( engine::getSong()->getTempo() ),
m_origBaseNote( instrumentTrack()->baseNoteModel()->value() )
m_origBaseNote( instrumentTrack()->baseNoteModel()->value() ),
m_frequency( 0 ),
m_unpitchedFrequency( 0 ),
m_baseDetuning( NULL ),
m_songGlobalParentOffset( 0 )
{
if( isTopNote() )
{
@@ -496,10 +500,10 @@ void notePlayHandle::updateFrequency()
void notePlayHandle::processMidiTime( const midiTime & _time )
{
if( _time >= pos() )
if( _time >= songGlobalParentOffset()+pos() )
{
const float v = detuning()->automationPattern()->
valueAt( _time - pos() );
valueAt( _time - songGlobalParentOffset() - pos() );
if( !typeInfo<float>::isEqual( v, m_baseDetuning->value() ) )
{
m_baseDetuning->setValue( v );

View File

@@ -2,7 +2,7 @@
* InstrumentTrack.cpp - implementation of instrument-track-class
* (window + data-structures)
*
* Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -672,6 +672,14 @@ bool InstrumentTrack::play( const midiTime & _start,
note_frames,
*cur_note );
note_play_handle->setBBTrack( bb_track );
// are we playing global song?
if( _tco_num < 0 )
{
// then set song-global offset of pattern in order to
// properly perform the note detuning
note_play_handle->setSongGlobalParentOffset( p->startPosition() );
}
#if LMMS_SINGERBOT_SUPPORT
note_play_handle->setPatternIndex( note_idx );
#endif