Simplify dummy synth processing loop
This commit is contained in:
parent
517be463ae
commit
3f5914e094
@ -530,41 +530,29 @@ static void DSynth_processQueue(DSynth *self, ALuint64 time)
|
|||||||
static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*restrict UNUSED(DryBuffer))
|
static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*restrict UNUSED(DryBuffer))
|
||||||
{
|
{
|
||||||
MidiSynth *synth = STATIC_CAST(MidiSynth, self);
|
MidiSynth *synth = STATIC_CAST(MidiSynth, self);
|
||||||
ALuint total = 0;
|
|
||||||
|
|
||||||
if(synth->State == AL_INITIAL)
|
if(synth->State != AL_PLAYING)
|
||||||
return;
|
|
||||||
if(synth->State == AL_PAUSED)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while(total < SamplesToDo)
|
synth->SamplesSinceLast += SamplesToDo;
|
||||||
|
synth->SamplesToNext -= SamplesToDo;
|
||||||
|
while(synth->SamplesToNext < 1.0f)
|
||||||
{
|
{
|
||||||
if(synth->SamplesToNext >= 1.0)
|
ALuint64 time = synth->NextEvtTime;
|
||||||
|
if(time == UINT64_MAX)
|
||||||
{
|
{
|
||||||
ALuint todo = minu(SamplesToDo - total, fastf2u(synth->SamplesToNext));
|
synth->SamplesToNext = 0.0;
|
||||||
|
break;
|
||||||
total += todo;
|
|
||||||
synth->SamplesSinceLast += todo;
|
|
||||||
synth->SamplesToNext -= todo;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ALuint64 time = synth->NextEvtTime;
|
|
||||||
if(time == UINT64_MAX)
|
|
||||||
{
|
|
||||||
synth->SamplesSinceLast += SamplesToDo-total;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
synth->SamplesSinceLast -= (time - synth->LastEvtTime) * synth->SamplesPerTick;
|
synth->SamplesSinceLast -= (time - synth->LastEvtTime) * synth->SamplesPerTick;
|
||||||
synth->SamplesSinceLast = maxd(synth->SamplesSinceLast, 0.0);
|
synth->SamplesSinceLast = maxd(synth->SamplesSinceLast, 0.0);
|
||||||
synth->LastEvtTime = time;
|
synth->LastEvtTime = time;
|
||||||
DSynth_processQueue(self, time);
|
DSynth_processQueue(self, time);
|
||||||
|
|
||||||
synth->NextEvtTime = MidiSynth_getNextEvtTime(synth);
|
synth->NextEvtTime = MidiSynth_getNextEvtTime(synth);
|
||||||
if(synth->NextEvtTime != UINT64_MAX)
|
if(synth->NextEvtTime != UINT64_MAX)
|
||||||
synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick;
|
synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user