ayFX replayer, leaving a tiny sound after play a SFX

Por albs_br

Champion (456)

Imagen del albs_br

29-09-2022, 18:42

Hi guys, I have this problem as specified on title: after I call to play a sound FX using ayFX replayer it leaves a continuos tone playing on speaker, as if something wasn't ended correctly.

Is there a tutorial with the steps required to setup and play SFXs using ayFX replayer? I copied my code from some place but it fells like I'm doing something wrong.

Login sesión o register para postear comentarios

Por theNestruo

Champion (387)

Imagen del theNestruo

29-09-2022, 18:48

I have had the same problem when the PT3 player is not playing background music.

Por SjaaQ

Champion (366)

Imagen del SjaaQ

29-09-2022, 19:56

I used a track without any sound (called silence.pt3 of course) to work around this issue (see Dot Attack msxdev2020 when it is in the ingame demo).

Por aoineko

Paladin (706)

Imagen del aoineko

29-09-2022, 20:49

If I remember correctly, I had modified the ayFX replayer to fix the problem in MSXgl.
I will try to find the modification.

EDIT:
I think it's line 228. If the sound ended and don't loop, I call the ayFX_Finish callback that point to the sound mute function by default:
https://github.com/aoineko-fr/MSXgl/blob/main/engine/src/ayf...

Por albs_br

Champion (456)

Imagen del albs_br

29-09-2022, 21:26

You guys on MSX.org are the best.

I'm struggling with this bug for almost one year, always thinking it was some mistake made by me.

I adapted the code to pure ASM and it worked on the first try:

; Stop the sound playback and mute the channel
AYFX_MUTE:
    ; --- End of an ayFX stream ---
    ld		a, 255				; Lowest ayFX priority
    ld		(ayFX_PRIORITY), a	; Priority saved (not playing ayFX stream)

    ; Silence the current ayFX channel
    ld		hl, ayFX_CHANNEL	; Next ayFX playing channel
    ld		b, (hl)				; Channel counter
    xor		a
.StopCheck1:
    ; If playing channel was 1, silence channel C
    djnz	.StopCheck2			; Decrement and jump if channel was not 1
    ld		(AYREGS + 10), a		; Volume copied in to AYREGS (channel C volume)
    ret
.StopCheck2:
    ; If playing channel was 2, silence channel B
    djnz	.StopCheck3			; Decrement and jump if channel was not 2
    ld		(AYREGS + 9), a		; Volume copied in to AYREGS (channel B volume)
    ret
.StopCheck3:
    ; If playing channel was 3, silence channel A
    ld		(AYREGS + 8), a		; Volume copied in to AYREGS (channel A volume)
    ret

Thanks for all help!