Esempio n. 1
0
void SndBuffer::timeStretchWrite()
{
    // data prediction helps keep the tempo adjustments more accurate.
    // The timestretcher returns packets in belated "clump" form.
    // Meaning that most of the time we'll get nothing back, and then
    // suddenly we'll get several chunks back at once.  Thus we use
    // data prediction to make the timestretcher more responsive.

    PredictDataWrite((int)(SndOutPacketSize / eTempo));
    CvtPacketToFloat(sndTempBuffer);

    pSoundTouch->putSamples((float *)sndTempBuffer, SndOutPacketSize);

    int tempProgress;
    while (tempProgress = pSoundTouch->receiveSamples((float *)sndTempBuffer, SndOutPacketSize),
           tempProgress != 0) {
        // Hint: It's assumed that pSoundTouch will return chunks of 128 bytes (it always does as
        // long as the SSE optimizations are enabled), which means we can do our own SSE opts here.

        CvtPacketToInt(sndTempBuffer, tempProgress);
        _WriteSamples(sndTempBuffer, tempProgress);
    }

#ifdef SPU2X_USE_OLD_STRETCHER
    UpdateTempoChangeSoundTouch();
#else
    UpdateTempoChangeSoundTouch2();
#endif
}
Esempio n. 2
0
void SndBuffer::timeStretchWrite()
{
	bool progress = false;

	// data prediction helps keep the tempo adjustments more accurate.
	// The timestretcher returns packets in belated "clump" form.
	// Meaning that most of the time we'll get nothing back, and then
	// suddenly we'll get several chunks back at once.  Thus we use
	// data prediction to make the timestretcher more responsive.

	PredictDataWrite( (int)( SndOutPacketSize / eTempo ) );
	CvtPacketToFloat( sndTempBuffer );

	pSoundTouch->putSamples( (float*)sndTempBuffer, SndOutPacketSize );

	int tempProgress;
	while( tempProgress = pSoundTouch->receiveSamples( (float*)sndTempBuffer, SndOutPacketSize),
		tempProgress != 0 )
	{
		// Hint: It's assumed that pSoundTouch will return chunks of 128 bytes (it always does as
		// long as the SSE optimizations are enabled), which means we can do our own SSE opts here.

		CvtPacketToInt( sndTempBuffer, tempProgress );
		_WriteSamples( sndTempBuffer, tempProgress );
		progress = true;
	}

#ifdef SPU2X_USE_OLD_STRETCHER
	UpdateTempoChangeSoundTouch();
#else
	UpdateTempoChangeSoundTouch2();
#endif

	if( MsgOverruns() )
	{
		if( progress )
		{
			if( ++ts_stats_logcounter > 150 )
			{
				ts_stats_logcounter = 0;
				ConLog( " * SPU2 > Timestretch Stats > %d percent stretched. Total stretchblocks = %d.\n",
					( ts_stats_stretchblocks * 100 ) / ( ts_stats_normalblocks + ts_stats_stretchblocks ),
					ts_stats_stretchblocks);
				ts_stats_normalblocks = 0;
				ts_stats_stretchblocks = 0;
			}
		}
	}
}