Zelda HLE: Implement saw wave generation (sample source 0001).

Fixes issue 7961.
This commit is contained in:
Pierre Bourdon 2014-12-20 04:11:10 +01:00
parent 91fade5e89
commit 34341af17d
1 changed files with 17 additions and 1 deletions

View File

@ -476,8 +476,12 @@ struct ZeldaAudioRenderer::VPB
enum SamplesSourceType
{
// Simple square wave at 50% amplitude and 16KHz.
// Simple square wave at 50% amplitude and frequency controlled via the
// resampling ratio.
SRC_SQUARE_WAVE = 0,
// Simple saw wave at 100% amplitude and frequency controlled via the
// resampling ratio.
SRC_SAW_WAVE = 1,
// Samples stored in ARAM at a rate of 16 samples/9 bytes, AFC encoded,
// at an arbitrary sample rate (resampling is applied).
SRC_AFC_HQ_FROM_ARAM = 9,
@ -772,6 +776,18 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb)
break;
}
case VPB::SRC_SAW_WAVE:
{
u32 pos = vpb->current_pos_frac;
for (size_t i = 0; i < buffer->size(); ++i)
{
(*buffer)[i] = pos & 0xFFFF;
pos += (vpb->resampling_ratio) >> 1;
}
vpb->current_pos_frac = pos & 0xFFFF;
break;
}
case VPB::SRC_AFC_HQ_FROM_ARAM:
DownloadAFCSamplesFromARAM(raw_input_samples.data() + 4, vpb,
NeededRawSamplesCount(*vpb));