From 5977041b6e68bd883a7203f6847ae681d7de2c78 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 29 Jan 2012 11:36:24 +0100 Subject: [PATCH] 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. --- include/note_play_handle.h | 13 ++++++++++++- src/core/note_play_handle.cpp | 12 ++++++++---- src/tracks/InstrumentTrack.cpp | 10 +++++++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/note_play_handle.h b/include/note_play_handle.h index 186ada814..a80eda9b5 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-2010 Tobias Doerffel + * Copyright (c) 2004-2012 Tobias Doerffel * * 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; } ; diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 1d6c8f476..a94a9eca4 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -2,7 +2,7 @@ * note_play_handle.cpp - implementation of class notePlayHandle, part of * rendering engine * - * Copyright (c) 2004-2010 Tobias Doerffel + * Copyright (c) 2004-2012 Tobias Doerffel * * 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::isEqual( v, m_baseDetuning->value() ) ) { m_baseDetuning->setValue( v ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 59b4f744f..bfbad257e 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -2,7 +2,7 @@ * InstrumentTrack.cpp - implementation of instrument-track-class * (window + data-structures) * - * Copyright (c) 2004-2011 Tobias Doerffel + * Copyright (c) 2004-2012 Tobias Doerffel * * 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