Skipping samples and song length detection with playptmod is now a lot faster
This commit is contained in:
parent
1b9fc96ed1
commit
e8766f1594
1 changed files with 31 additions and 47 deletions
|
@ -2683,26 +2683,6 @@ static void processTick(player *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pulsateSamples(player *p, int samples)
|
|
||||||
{
|
|
||||||
if (p->sampleCounter == 0)
|
|
||||||
{
|
|
||||||
processTick(p);
|
|
||||||
p->sampleCounter += p->samplesPerTick;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->sampleCounter -= samples;
|
|
||||||
if (p->sampleCounter < 0)
|
|
||||||
{
|
|
||||||
int retSamples = samples + p->sampleCounter;
|
|
||||||
p->sampleCounter = 0;
|
|
||||||
|
|
||||||
return retSamples;
|
|
||||||
}
|
|
||||||
|
|
||||||
return samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
void playptmod_Render(void *_p, int *target, int length)
|
void playptmod_Render(void *_p, int *target, int length)
|
||||||
{
|
{
|
||||||
player *p = (player *)_p;
|
player *p = (player *)_p;
|
||||||
|
@ -2714,11 +2694,23 @@ void playptmod_Render(void *_p, int *target, int length)
|
||||||
while (length)
|
while (length)
|
||||||
{
|
{
|
||||||
int tempSamples = CLAMP(length, 0, soundBufferSamples);
|
int tempSamples = CLAMP(length, 0, soundBufferSamples);
|
||||||
tempSamples = pulsateSamples(p, tempSamples);
|
|
||||||
length -= tempSamples;
|
|
||||||
|
|
||||||
|
if (p->sampleCounter)
|
||||||
|
{
|
||||||
|
tempSamples = CLAMP(tempSamples, 0, p->sampleCounter);
|
||||||
|
if (target)
|
||||||
|
{
|
||||||
outputAudio(p, target, tempSamples);
|
outputAudio(p, target, tempSamples);
|
||||||
if ( target ) target += (tempSamples * 2);
|
target += tempSamples * 2;
|
||||||
|
}
|
||||||
|
p->sampleCounter -= tempSamples;
|
||||||
|
length -= tempSamples;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
processTick(p);
|
||||||
|
p->sampleCounter = p->samplesPerTick;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2730,19 +2722,12 @@ void playptmod_Render16(void *_p, short *target, int length)
|
||||||
int tempBuffer[512];
|
int tempBuffer[512];
|
||||||
int * temp = ( target ) ? tempBuffer : 0;
|
int * temp = ( target ) ? tempBuffer : 0;
|
||||||
|
|
||||||
if (p->modulePlaying == true)
|
|
||||||
{
|
|
||||||
static const int soundBufferSamples = soundBufferSize / 4;
|
|
||||||
|
|
||||||
while (length)
|
while (length)
|
||||||
{
|
{
|
||||||
int i, tempSamples = CLAMP(length, 0, soundBufferSamples);
|
int i, tempSamples = CLAMP(length, 0, 256);
|
||||||
tempSamples = CLAMP(length, 0, 256);
|
playptmod_Render(p, temp, tempSamples);
|
||||||
tempSamples = pulsateSamples(p, tempSamples);
|
|
||||||
length -= tempSamples;
|
length -= tempSamples;
|
||||||
|
|
||||||
outputAudio(p, temp, tempSamples);
|
|
||||||
|
|
||||||
if ( target )
|
if ( target )
|
||||||
for (i = 0; i < tempSamples * 2; ++i)
|
for (i = 0; i < tempSamples * 2; ++i)
|
||||||
{
|
{
|
||||||
|
@ -2753,7 +2738,6 @@ void playptmod_Render16(void *_p, short *target, int length)
|
||||||
|
|
||||||
if ( target ) target += (tempSamples * 2);
|
if ( target ) target += (tempSamples * 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *playptmod_Create(int samplingFrequency)
|
void *playptmod_Create(int samplingFrequency)
|
||||||
|
|
Loading…
Reference in a new issue