Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DMG envelop change without retriggering sounds wrong #3067

Closed
copyrat90 opened this issue Nov 15, 2023 · 5 comments
Closed

DMG envelop change without retriggering sounds wrong #3067

copyrat90 opened this issue Nov 15, 2023 · 5 comments
Labels
hardware:audio Issues in the audio subsystem
Milestone

Comments

@copyrat90
Copy link

copyrat90 commented Nov 15, 2023

In the hardware, the envelop starts as expected, but in mGBA the envelop never starts.

Hardware -> mGBA recording

hardware_mgba.mp4

Test ROM

F0_F7_no_retrig.zip

Code

#include <tonc.h>

int main(void) {
    irq_init(NULL);
    irq_enable(II_VBLANK);

    REG_SNDSTAT = SSTAT_ENABLE;
    REG_SNDDSCNT = SDS_DMG100;
    REG_SNDDMGCNT = SDMG_LVOL(7) | SDMG_RVOL(7) | SDMG_LSQR1 | SDMG_RSQR1;

    REG_SND1CNT = SSQR_IVOL(15) | SSQR_TIME(0);
    REG_SND1FREQ = SFREQ_RESET | SFREQ_RATE(416);

    int wait = 45;
    while (1) {
        if (--wait == 0)
            REG_SND1CNT = SSQR_IVOL(15) | SSQR_TIME(7);
        VBlankIntrWait();
    }
}
@endrift endrift added the hardware:audio Issues in the audio subsystem label Nov 19, 2023
@endrift endrift added this to the mGBA 0.10.4 milestone Nov 19, 2023
@profi200
Copy link

Almost forgot. I wanted to mention that this specific regression also exists on DS and 3DS GBA hardware since it's not documented anywhere. So technically it's accurate emulation just not of GBA/GBA SP behavior. GB micro is unknown/untested.

@Dartz150
Copy link

Almost forgot. I wanted to mention that this specific regression also exists on DS and 3DS GBA hardware since it's not documented anywhere. So technically it's accurate emulation just not of GBA/GBA SP behavior. GB micro is unknown/untested.

I must add that this works correctly in GBmicro, so only the DS/3DS GBA hardware modes have this bug.

@Gericom
Copy link

Gericom commented Dec 20, 2023

The problem might be that _writeEnvelope does not update nextStep. When the envelope changes from dead to not dead it should probably do that, because otherwise the envelope update will not happen (or I guess only after a very long wait depending on overflow behavior).

It's kinda peculiar that mgba has the same bug as ds and 3ds hw btw.

@endrift
Copy link
Member

endrift commented Dec 20, 2023

I'm unsure this change is correct, but I'll do a bit more in-depth checking later. I'm not 100% sure how writing to the envelope on an active channel works, but generally it's understood to be "buggy"

@profi200
Copy link

Good to know the GB micro is unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardware:audio Issues in the audio subsystem
Projects
None yet
Development

No branches or pull requests

5 participants