📄 output.cpp
字号:
}
CurrT -= DELTA_OVERFLOW;
PrevSamp0 = CurrSamp0;
PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
CurrSamp0 = (LONG)pSampleSrc->m8.sample;
CurrSamp0 = (CurrSamp0 - 128) << 8;
pCurrData+=1;
}
OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> DELTAFRAC);
OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
CurrT += DeltaT;
// Commented out for (possible) debug build optimisation
// DEBUGMSG(ZONE_VERBOSE, (TEXT("PrevSamp0=0x%X, CurrSamp0=0x%X, CurrT=0x%X, OutSamp0=0x%X\r\n"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
if (pBuffer < pBufferLast)
{
OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
#if USE_MIX_SATURATE
// Handle saturation
if (OutSamp0>AUDIO_SAMPLE_MAX)
{
OutSamp0=AUDIO_SAMPLE_MAX;
}
else if (OutSamp0<AUDIO_SAMPLE_MIN)
{
OutSamp0=AUDIO_SAMPLE_MIN;
}
#endif
}
((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
pBuffer += sizeof(HWSAMPLE);
}
Exit:
m_dwByteCount += (pCurrData - m_lpCurrData);
m_lpCurrData = pCurrData;
m_CurrT = CurrT;
m_PrevSamp[0] = PrevSamp0;
m_CurrSamp[0] = CurrSamp0;
return pBuffer;
}
//-----------------------------------------------------------------------------
// Member function: OutputStreamContextM8MW::Render2
//
// This function renders the next buffer-full of data to the given buffer.
// This class renders from mono 8-bit to mono 32-bit.
//
// Parameters:
// pBuffer the start of the output buffer.
// pBufferEnd the end of the output buffer.
// pBufferLast the current high-water mark in the buffer. This is the
// furthest point in the buffer which has had data rendered
// into it.
//
// Returns: PBYTE
// The end point rendered to by this stream. This is used to update
// pBufferLast when rendering several streams to the same buffer.
//-----------------------------------------------------------------------------
PBYTE OutputStreamContextM8MW::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
LONG CurrT = m_CurrT;
LONG DeltaT = m_DeltaT;
LONG CurrSamp0 = m_CurrSamp[0];
LONG PrevSamp0 = m_PrevSamp[0];
PBYTE pCurrData = m_lpCurrData;
PBYTE pCurrDataEnd = m_lpCurrDataEnd;
LONG fxpGain = m_fxpGain[0];
LONG OutSamp0;
while (pBuffer < pBufferEnd)
{
while (CurrT >= DELTA_OVERFLOW)
{
if (pCurrData>=pCurrDataEnd)
{
goto Exit;
}
CurrT -= DELTA_OVERFLOW;
PrevSamp0 = CurrSamp0;
PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
CurrSamp0 = (LONG)pSampleSrc->m8.sample;
CurrSamp0 = (CurrSamp0 - 128) << 8;
pCurrData+=1;
}
OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> DELTAFRAC);
OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
CurrT += DeltaT;
// Commented out for (possible) debug build optimisation
// DEBUGMSG(ZONE_VERBOSE, (TEXT("PrevSamp0=0x%X, CurrSamp0=0x%X, CurrT=0x%X, OutSamp0=0x%X\r\n"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
if (pBuffer < pBufferLast)
{
OutSamp0 += ((LHWSAMPLE *)pBuffer)[0];
#if USE_MIX_SATURATE
// Handle saturation
if (OutSamp0>AUDIO_SAMPLE_MAX)
{
OutSamp0=AUDIO_SAMPLE_MAX;
}
else if (OutSamp0<AUDIO_SAMPLE_MIN)
{
OutSamp0=AUDIO_SAMPLE_MIN;
}
#endif
}
((LHWSAMPLE *)pBuffer)[0] = (LHWSAMPLE)OutSamp0;
pBuffer += sizeof(LHWSAMPLE);
}
Exit:
m_dwByteCount += (pCurrData - m_lpCurrData);
m_lpCurrData = pCurrData;
m_CurrT = CurrT;
m_PrevSamp[0] = PrevSamp0;
m_CurrSamp[0] = CurrSamp0;
return pBuffer;
}
//-----------------------------------------------------------------------------
// Member function: OutputStreamContextM16M::Render2
//
// This function renders the next buffer-full of data to the given buffer.
// This class renders from mono 16-bit to mono.
//
// Parameters:
// pBuffer the start of the output buffer.
// pBufferEnd the end of the output buffer.
// pBufferLast the current high-water mark in the buffer. This is the
// furthest point in the buffer which has had data rendered
// into it.
//
// Returns: PBYTE
// The end point rendered to by this stream. This is used to update
// pBufferLast when rendering several streams to the same buffer.
//-----------------------------------------------------------------------------
PBYTE OutputStreamContextM16M::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
LONG CurrT = m_CurrT;
LONG DeltaT = m_DeltaT;
LONG CurrSamp0 = m_CurrSamp[0];
LONG PrevSamp0 = m_PrevSamp[0];
PBYTE pCurrData = m_lpCurrData;
PBYTE pCurrDataEnd = m_lpCurrDataEnd;
LONG fxpGain = m_fxpGain[0];
LONG OutSamp0;
while (pBuffer < pBufferEnd)
{
while (CurrT >= DELTA_OVERFLOW)
{
if (pCurrData>=pCurrDataEnd)
{
goto Exit;
}
CurrT -= DELTA_OVERFLOW;
PrevSamp0 = CurrSamp0;
PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
CurrSamp0 = (LONG)pSampleSrc->m16.sample;
pCurrData+=2;
}
OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> DELTAFRAC);
OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
CurrT += DeltaT;
// Commented out for (possible) debug build optimisation
// DEBUGMSG(ZONE_VERBOSE, (TEXT("PrevSamp0=0x%X, CurrSamp0=0x%X, CurrT=0x%X, OutSamp0=0x%X\r\n"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
if (pBuffer < pBufferLast)
{
OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
#if USE_MIX_SATURATE
// Handle saturation
if (OutSamp0>AUDIO_SAMPLE_MAX)
{
OutSamp0=AUDIO_SAMPLE_MAX;
}
else if (OutSamp0<AUDIO_SAMPLE_MIN)
{
OutSamp0=AUDIO_SAMPLE_MIN;
}
#endif
}
((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
pBuffer += sizeof(HWSAMPLE);
}
Exit:
m_dwByteCount += (pCurrData - m_lpCurrData);
m_lpCurrData = pCurrData;
m_CurrT = CurrT;
m_PrevSamp[0] = PrevSamp0;
m_CurrSamp[0] = CurrSamp0;
return pBuffer;
}
//-----------------------------------------------------------------------------
// Member function: OutputStreamContextM16MW::Render2
//
// This function renders the next buffer-full of data to the given buffer.
// This class renders from mono 16-bit to mono 32-bit.
//
// Parameters:
// pBuffer the start of the output buffer.
// pBufferEnd the end of the output buffer.
// pBufferLast the current high-water mark in the buffer. This is the
// furthest point in the buffer which has had data rendered
// into it.
//
// Returns: PBYTE
// The end point rendered to by this stream. This is used to update
// pBufferLast when rendering several streams to the same buffer.
//-----------------------------------------------------------------------------
PBYTE OutputStreamContextM16MW::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
LONG CurrT = m_CurrT;
LONG DeltaT = m_DeltaT;
LONG CurrSamp0 = m_CurrSamp[0];
LONG PrevSamp0 = m_PrevSamp[0];
PBYTE pCurrData = m_lpCurrData;
PBYTE pCurrDataEnd = m_lpCurrDataEnd;
LONG fxpGain = m_fxpGain[0];
LONG OutSamp0;
while (pBuffer < pBufferEnd)
{
while (CurrT >= DELTA_OVERFLOW)
{
if (pCurrData>=pCurrDataEnd)
{
goto Exit;
}
CurrT -= DELTA_OVERFLOW;
PrevSamp0 = CurrSamp0;
PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
CurrSamp0 = (LONG)pSampleSrc->m16.sample;
pCurrData+=2;
}
OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> DELTAFRAC);
OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
CurrT += DeltaT;
// Commented out for (possible) debug build optimisation
// DEBUGMSG(ZONE_VERBOSE, (TEXT("PrevSamp0=0x%X, CurrSamp0=0x%X, CurrT=0x%X, OutSamp0=0x%X\r\n"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
if (pBuffer < pBufferLast)
{
OutSamp0 += ((LHWSAMPLE *)pBuffer)[0];
#if USE_MIX_SATURATE
// Handle saturation
if (OutSamp0>AUDIO_SAMPLE_MAX)
{
OutSamp0=AUDIO_SAMPLE_MAX;
}
else if (OutSamp0<AUDIO_SAMPLE_MIN)
{
OutSamp0=AUDIO_SAMPLE_MIN;
}
#endif
}
((LHWSAMPLE *)pBuffer)[0] = (LHWSAMPLE)OutSamp0;
pBuffer += sizeof(LHWSAMPLE);
}
Exit:
m_dwByteCount += (pCurrData - m_lpCurrData);
m_lpCurrData = pCurrData;
m_CurrT = CurrT;
m_PrevSamp[0] = PrevSamp0;
m_CurrSamp[0] = CurrSamp0;
return pBuffer;
}
//-----------------------------------------------------------------------------
// Member function: OutputStreamContextS8S::Render2
//
// This function renders the next buffer-full of data to the given buffer.
// This class renders from stereo 8-bit to stereo.
//
// Parameters:
// pBuffer the start of the output buffer.
// pBufferEnd the end of the output buffer.
// pBufferLast the current high-water mark in the buffer. This is the
// furthest point in the buffer which has had data rendered
// into it.
//
// Returns: PBYTE
// The end point rendered to by this stream. This is used to update
// pBufferLast when rendering several streams to the same buffer.
//-----------------------------------------------------------------------------
PBYTE OutputStreamContextS8S::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
LONG CurrT = m_CurrT;
LONG DeltaT = m_DeltaT;
LONG CurrSamp0 = m_CurrSamp[0];
LONG CurrSamp1 = m_CurrSamp[1];
LONG PrevSamp0 = m_PrevSamp[0];
LONG PrevSamp1 = m_PrevSamp[1];
PBYTE pCurrData = m_lpCurrData;
PBYTE pCurrDataEnd = m_lpCurrDataEnd;
LONG fxpGain[2];
fxpGain[0] = m_fxpGain[0];
fxpGain[1] = m_fxpGain[1];
LONG OutSamp0;
LONG OutSamp1;
while (pBuffer < pBufferEnd)
{
while (CurrT >= DELTA_OVERFLOW)
{
if (pCurrData>=pCurrDataEnd)
{
goto Exit;
}
CurrT -= DELTA_OVERFLOW;
PrevSamp0 = CurrSamp0;
PrevSamp1 = CurrSamp1;
PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
CurrSamp0 = (LONG)pSampleSrc->s8.sample_left;
CurrSamp0 = (CurrSamp0 - 128) << 8;
CurrSamp1 = (LONG)pSampleSrc->s8.sample_right;
CurrSamp1 = (CurrSamp1 - 128) << 8;
pCurrData+=2;
}
OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> DELTAFRAC);
OutSamp0 = (OutSamp0 * fxpGain[0]) >> VOLSHIFT;
OutSamp1 = PrevSamp1 + (((CurrSamp1 - PrevSamp1) * CurrT) >> DELTAFRAC);
OutSamp1 = (OutSamp1 * fxpGain[1]) >> VOLSHIFT;
CurrT += DeltaT;
// Commented out for (possible) debug build optimisation
// DEBUGMSG(ZONE_VERBOSE, (TEXT("PrevSamp0=0x%X, CurrSamp0=0x%X, CurrT=0x%X, OutSamp0=0x%X\r\n"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
if (pBuffer < pBufferLast)
{
OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
#if USE_MIX_SATURATE
// Handle saturation
if (OutSamp0>AUDIO_SAMPLE_MAX)
{
OutSamp0=AUDIO_SAMPLE_MAX;
}
else if (OutSamp0<AUDIO_SAMPLE_MIN)
{
OutSamp0=AUDIO_SAMPLE_MIN;
}
if (OutSamp1>AUDIO_SAMPLE_MAX)
{
OutSamp1=AUDIO_SAMPLE_MAX;
}
else if (OutSamp1<AUDIO_SAMPLE_MIN)
{
OutSamp1=AUDIO_SAMPLE_MIN;
}
#endif
}
((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
pBuffer += 2*sizeof(HWSAMPLE);
}
Exit:
m_dwByteCount += (pCurrData - m_lpCurrData);
m_lpCurrData = pCurrData;
m_CurrT = CurrT;
m_PrevSamp[0] = PrevSamp0;
m_PrevSamp[1] = PrevSamp1;
m_CurrSamp[0] = CurrSamp0;
m_CurrSamp[1] = CurrSamp1;
return pBuffer;
}
//-----------------------------------------------------------------------------
// Member function: OutputStreamContextS16S::Render2
//
// This function renders the next buffer-full of data to the given buffer.
// This class renders from stereo 16-bit to stereo.
//
// Parameters:
// pBuffer the start of the output buffer.
// pBufferEnd the end of the output buffer.
// pBufferLast the current high-water mark in the buffer. This is the
// furthest point in the buffer which has had data rendered
// into it.
//
// Returns: PBYTE
// The end point rendered to by this stream. This is used to update
// pBufferLast when rendering several streams to the same buffer.
//-----------------------------------------------------------------------------
PBYTE OutputStreamContextS16S::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
LONG CurrT = m_CurrT;
LONG DeltaT = m_DeltaT;
LONG CurrSamp0 = m_CurrSamp[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -