|
From: <sag...@us...> - 2015-05-29 21:29:04
|
Revision: 5206
http://sourceforge.net/p/modplug/code/5206
Author: saga-games
Date: 2015-05-29 21:28:57 +0000 (Fri, 29 May 2015)
Log Message:
-----------
[Fix] Song estimation should not affect modern tempo tick compensation of potentially parallel playback
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-05-29 20:26:17 UTC (rev 5205)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-05-29 21:28:57 UTC (rev 5206)
@@ -738,13 +738,13 @@
break;
}
- ROWINDEX rowsPerBeat = m_nDefaultRowsPerBeat;
+ m_PlayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat;
if(Patterns[memory.state.m_nPattern].GetOverrideSignature())
{
- rowsPerBeat = Patterns[memory.state.m_nPattern].GetRowsPerBeat();
+ m_PlayState.m_nCurrentRowsPerBeat = Patterns[memory.state.m_nPattern].GetRowsPerBeat();
}
- const uint32 tickDuration = GetTickDuration(memory.state.m_nMusicTempo, memory.state.m_nMusicSpeed, rowsPerBeat);
+ const uint32 tickDuration = GetTickDuration(memory.state);
const uint32 rowDuration = tickDuration * numTicks;
memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq);
memory.state.m_lTotalSampleCount += rowDuration;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-05-29 20:26:17 UTC (rev 5205)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-05-29 21:28:57 UTC (rev 5206)
@@ -1811,38 +1811,38 @@
// Get length of a tick in sample, with tick-to-tick tempo correction in modern tempo mode.
// This has to be called exactly once per tick because otherwise the error accumulation
// goes wrong.
-uint32 CSoundFile::GetTickDuration(uint32 tempo, uint32 speed, ROWINDEX rowsPerBeat)
-//----------------------------------------------------------------------------------
+uint32 CSoundFile::GetTickDuration(PlayState &playState) const
+//------------------------------------------------------------
{
- UINT retval = 0;
+ uint32 retval = 0;
switch(m_nTempoMode)
{
case tempo_mode_classic:
default:
- retval = (m_MixerSettings.gdwMixingFreq * 5) / (tempo << 1);
+ retval = (m_MixerSettings.gdwMixingFreq * 5) / (playState.m_nMusicTempo << 1);
break;
case tempo_mode_alternative:
- retval = m_MixerSettings.gdwMixingFreq / tempo;
+ retval = m_MixerSettings.gdwMixingFreq / playState.m_nMusicTempo;
break;
case tempo_mode_modern:
{
- double accurateBufferCount = static_cast<double>(m_MixerSettings.gdwMixingFreq) * (60.0 / static_cast<double>(tempo) / (static_cast<double>(speed * rowsPerBeat)));
- UINT bufferCount = static_cast<int>(accurateBufferCount);
- m_PlayState.m_dBufferDiff += accurateBufferCount - bufferCount;
+ double accurateBufferCount = static_cast<double>(m_MixerSettings.gdwMixingFreq) * (60.0 / static_cast<double>(playState.m_nMusicTempo) / (static_cast<double>(playState.m_nMusicSpeed * playState.m_nCurrentRowsPerBeat)));
+ uint32 bufferCount = static_cast<int>(accurateBufferCount);
+ playState.m_dBufferDiff += accurateBufferCount - bufferCount;
//tick-to-tick tempo correction:
- if(m_PlayState.m_dBufferDiff >= 1)
+ if(playState.m_dBufferDiff >= 1)
{
bufferCount++;
- m_PlayState.m_dBufferDiff--;
+ playState.m_dBufferDiff--;
} else if(m_PlayState.m_dBufferDiff <= -1)
{
bufferCount--;
- m_PlayState.m_dBufferDiff++;
+ playState.m_dBufferDiff++;
}
- MPT_ASSERT(fabs(m_PlayState.m_dBufferDiff) < 1);
+ MPT_ASSERT(fabs(playState.m_dBufferDiff) < 1);
retval = bufferCount;
}
break;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2015-05-29 20:26:17 UTC (rev 5205)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2015-05-29 21:28:57 UTC (rev 5206)
@@ -650,7 +650,7 @@
void RecalculateSamplesPerTick();
double GetRowDuration(UINT tempo, UINT speed) const;
- uint32 GetTickDuration(uint32 tempo, uint32 speed, ROWINDEX rowsPerBeat);
+ uint32 GetTickDuration(PlayState &playState) const;
// A repeat count value of -1 means infinite loop
void SetRepeatCount(int n) { m_nRepeatCount = n; }
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2015-05-29 20:26:17 UTC (rev 5205)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2015-05-29 21:28:57 UTC (rev 5206)
@@ -1769,7 +1769,7 @@
////////////////////////////////////////////////////////////////////////////////////
if (!m_PlayState.m_nMusicTempo) return false;
- m_PlayState.m_nSamplesPerTick = GetTickDuration(m_PlayState.m_nMusicTempo, m_PlayState.m_nMusicSpeed, m_PlayState.m_nCurrentRowsPerBeat);
+ m_PlayState.m_nSamplesPerTick = GetTickDuration(m_PlayState);
m_PlayState.m_nBufferCount = m_PlayState.m_nSamplesPerTick;
// Master Volume + Pre-Amplification / Attenuation setup
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|