dosbox-staging / dosbox-staging

DOSBox Staging is a modern continuation of DOSBox with advanced features and current development practices.
https://www.dosbox-staging.org/
Other
1.31k stars 155 forks source link

Tyrian: Crackling SFX with Gravis UltraSound and some with music; both FluidSynth and GUS #1524

Closed RavenMacDaddy closed 2 years ago

RavenMacDaddy commented 2 years ago

Are you using the latest Dosbox-Staging Version?

Different version than latest?

No response

What Operating System are you using?

Windows 11

If Other OS, please describe

No response

Relevant hardware info

DAC: RME ADI-2 DAC | Speakers: EVE Audio SC205

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

Running Tyrian with GUS selected for SFX will produce sound that's constantly crackling.

This is both in its setup and when running the game, and since there are no parameters for GUS to adjust regarding its playback of sound, I've not been able to troubleshoot that component specifically - but with this said, comparable amount of crackling is present in the DOSBox-X fork and therefore the issue seems to be the core of DOSBox and not for example some fork specific enhancement.

I also noticed some instruments crackling depending on the soundfont that's being used with FluidSynth.

Using GUS as the music device also seems to crackle a whole lot, which is worth noting.

Changing the blocksize to 1024 and the prebuffer to 25 (as well as other values for the mixer to rule that out) according to the known issues list doesn't help at all it seems.

For reference I've also tried with the default rate of 48kHz, although I otherwise run with 44.1kHz when I'm not troubleshooting.

I've confirmed that the emulation is at a rock-solid 100% all the time with auto cycles always choosing 'max' as the setting.

Steps to reproduce the behaviour.

Explain how to reproduce

  1. The game is freeware - see either GOG or Jason Emery's (developer) dedicated site here.
  2. Run setup.exe
  3. Turn off either Music or SFX depending on what you want to troubleshoot/reproduce.
  4. For GUS, change SFX playback to Gravis as the device, then navigate around the menu with Up and Down on the keyboard to easily notice the crackling just from those small SFX.
  5. For MIDI, use FluidSynth with for example the recommended SF Arachno and try playing different songs. With the SF Arachno, song 11 in the setup's Jukebox most consistently crackled, while other soundfonts might crackle with instruments used in other songs - so keep that in mind.
  6. Also try GUS as the music device for reference regarding that part of the issue.

Your configuration

No response

Provide a Log

GUS log

Code of Conduct & Contributing Guidelines

GranMinigun commented 2 years ago

I don't think anyone on the team have an external DAC, so this issue might stay open for a while. It's possible that SDL's audio handling somehow misbehaves, but it'll take time to replace, in case it'll be decided to do so.

Can you please also play with Windows' audio sampling rate setting? How vanilla DOSBox behaves? Other SDL games and programs? Other games that can work with GUS and/or GM/Sound Canvas? RetroArch's dosbox-core, in case you have it installed?

RavenMacDaddy commented 2 years ago

I'll try to adress your concerns and questions as they were written;

kcgen commented 2 years ago

Thanks for this report @RavenMacDaddy .

My hunch is that there's a problem with the game's GUS audio driver/mixer, because the cracking is present even if we disable the music and reduce the SFX volume to the lowest level using the following:

2022-01-13_17-24

To test this, now crank up your PC volume (yes - quite loud!) so you can hear the effects: they will still contain pops and crackles.

Staging keeps track of the loudest samples played for the entire lifetime of the process - and in the above case, it reports GUS only achieved 3% of the peak volume:

2022-01-13_17-34

With such low sample amplitudes, there's no risk of clipping or truncation.

I also disabled the other audio devices to ensure errant audio signals weren't coming into play:

[speaker]
pcspeaker=false
tandy=off
disney=false

[sblaster]
sbtype=none

[midi]
mididevice = none

If we take a closer look at the signal, we can see the discontinuities:

2022-01-13_17-32

Notice the curve isn't close to the top and bottom edge; there's still ~20% headroom available. So my hunch is the clipping is occurring inside Tyrian prior to it sending the samples into the GUS for playback.

Another source of crackle is buffer underruns or overruns: Staging will report these events quite loudly on the console log "Audio buffer needed X by have Y samples". however, I see none of these when running Tyrian, so our buffer is being kept fully populated with back-to-back samples from the GUS.

If someone has a physical GUS card, they could verify this is the case.

kcgen commented 2 years ago

Even with the sound blaster disabled, it appears that Tyrian is using some kind of SB-compatible mode when using the GUS:

2022-01-13_17-52

RavenMacDaddy commented 2 years ago

Very interesting stuff.

Thank you for the analysis and insights so far @kcgen.

RavenMacDaddy commented 2 years ago

I would also expect the same SB compatible behavior for Windows Sound System in that case, even if that's not possible to test at the moment. Is that kind of support something on the roadmap by the way; WSS that's?

kcgen commented 2 years ago

WSS was very much like a Sound Blaster 16 "value edition": simple 8-bit and 16-bit PCM output + OPL3 FM support. Because it would be using PCM output, I would imagine Tyrian's WSS drivers would behave like its Sound Blaster driver, and sound exactly the same as if Tyrian was configured for Sound Blaster.

Tyrian's PCM samples are only 8-bit + stereo + <22 KHz, so there's no differentiation these cards can offer in the sound-effect department:

RavenMacDaddy commented 2 years ago

Once again, appreciate your insight - it's very interesting for me personally.

kcgen commented 2 years ago

I think we're as far as we can go here; suggest this be closed.

PS- Was reading a bit more about Tyrian, and it's music was composed for OPL3, so although it's interesting to hear how its drivers convert the FM music to MIDI equivalents (and as a further conversion to Ultramid's MIDI instruments banks), the optimal listening would be with SB16 or the SB Pro2. Both offer OPL3, and we know Tyrian's sound effects aren't 16-bit/44 kHz, so no harm in using sbpro2!