uli / dragonbasic

Dragon BASIC compiler for Game Boy Advance
Other
42 stars 7 forks source link

Volume control for music and sound. #12

Open supercom32 opened 6 years ago

supercom32 commented 6 years ago

Possible enhancement identified using the latest version of Dragon Basic under Linux (Commit ID: d2ce042366068083a5fe3089873a22221fffbc26)

When working with Dragon Basic, I noted that for music and sound there is no way to control the volume of Direct Sound channels. That means users can't fade in/out music as gameplay/scenes change and the only recourse is to abruptly stop it. Looking at the GBA registers for sound, it sounds like "REG_SOUNDCNT_H" only allows for the following options:

Output sound ratio for chan.1-4 (0=25%,1=50%,2=100%) Direct sound A output ratio (0=50%, 1=100%) Direct sound B output ratio (0=50%, 1=100%) Unused Direct sound A to right output Direct sound A to left output Direct sound A Sampling rate timer (timer 0 or 1) Direct sound A FIFO reset Direct sound B to right output Direct sound B to left output Direct sound B Sampling rate timer (timer 0 or 1) Direct sound B FIFO reset

Seems like unless some extra processing is involved in software, the hardware can only set the output volume to 50% or 100%. I know some GBA module/tracker libraries can manipulate volume, but that might all be done in software. This is probably a hard enhancement to fill, but I thought I'd mention it for informational and tracking purposes anyway.