dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
351 stars 33 forks source link

v5 ReSID resampling broken, fill level hits periodically zero #804

Closed mithrendal closed 1 month ago

mithrendal commented 1 month ago

https://csdb.dk/release/?id=241359

on resampling

image

the fill level of audio buffer runs periodically to zero

image

resulting stuttering sound with crackling noises

sound works fine on setting fast and interpolate

also affects https://vc64web.github.io

mithrendal commented 1 month ago

ReSID resampling works fine when switching back to a v4.5 emulation core

image

I did some more tests on ReSID resampling mode

findings

  1. the ReSID resampling in v5 draws more computing power. When using Macbook M1 solely on battery, energy saving measurements seems to kick in. With these measurements it is not able to sufficiently compute sound samples, vAmiga.app activity hits 100%. Resulting in audio buffer underruns... fill level drops periodically to 0. When on power line again vAmiga.app activity drops to 67%, fill level stable.

  2. there is a constantly crackling noise which does not come from buffer underruns. It is just there.

dirkwhoffmann commented 1 month ago

Culpript for the cracking noise is commit 2ce74bc

dirkwhoffmann commented 1 month ago

The crackling noise was caused by this function:

void
ReSID::setClockFrequency(u32 frequency)
{
    if (clockFrequency != frequency) {

        clockFrequency = frequency;
        sid->set_sampling_parameters((double)clockFrequency,
                                     (reSID::sampling_method)samplingMethod,
                                     (double)sampleRate);
        trace(SID_DEBUG, "Setting clock frequency to %d\n", frequency);
    }

    assert((u32)sid->clock_frequency == clockFrequency);
}

In the faulty implementation, the line

     if (clockFrequency != frequency) {

was missing. As a result, reSID got reinitialized in every frame.

mithrendal commented 1 month ago

merged latest commits into vc64web. You fixed the issue. ✌️