Skip to content

Gravis UltraSound enhancements

Hugo Locurcio edited this page Jul 11, 2023 · 3 revisions
Table of contents (click to expand)

Introduction

Gravis UltraSound (GUS) emulation within DOSBox has been very well programmed to replicate playback behavior of the original hardware, often matching algorithms documented in component processor specifications. The DOSBox-X project has expanded on this by including timed DMA transfers, mixing capabilities, and recording - all of which are necessary for improved emulation under Windows 3.1 and 95.

Motivation

All of that goodness aside, there are still concerns with GUS emulation:

Hardware accuracy

Addressing some of these involved deviating from the current hardware-accurate implementation. Why would we consider such blasphemy? A quote says it well:

"The pieces of software that people want to enjoy are largely important works of digital art from a bygone era. Art is meant to be enjoyed. Presenting art in a format which is not acceptable in the current day and age is doing the artwork and its creators a great disservice" -- @heydojo.

To that end, the dosbox-staging project strives to meet today's expectations on modern hardware. If that means not strictly matching original hardware behavior, then we will do so if it stays faithful to the game authors' intentions.

[Top]


Development

The DOSBox Staging project has addressed these GUS issues through the following changes:

  • Provides large DMA transfers of up to 8 KB/each.

  • Uses PCM samples as-is without bit-shifting them upward or downward in volume.

  • Handles the samples' fractional "inter-wave" portion using floating-point math.

  • Performs volume dampening using floating point values ranging from 1.0 down to 0.0.

  • Performs -3 dB constant power panning per the Gravis SDK.

  • Accumulates the set of active voices using floating-point math.

  • Detects and soft-limits (instead of clips) the left and right channels independently when accumulations exceed the 16-bit sample range.

  • Implements three runtime states: halt, initialize, and play (previously called "Reset"). The mixer's audio channel is only activated during the play state.

  • Produces an output stream at a rate defined by the number of active voices, which is adjusted on the fly.

  • Generates a 16-bit signed stereo stream (not 32-bit) fed into dosbox's mixer.

  • Produces informative and actionable audio information during playback and after shutdown. For example:

    --- (during play) ---
    GUS: Activated 16 voices at 38588 Hz
    
    --- (after shutdown) ---
    GUS: Audio comprised of 8-bit samples from 13 voices
    GUS: Peak amplitude reached 55% of max
    GUS: If it should be louder, use: mixer gus 183
    

Structurally, the GUS source has been brought more in-line with the dosbox-staging coding style:

  • Variable names and cases have been adjusted slightly.
  • All #defines have been replaced with constexprs.
  • Globals and static functions have been replaced with structs, classes and calling member functions
  • Smart containers and pointers are used for dynamically allocated objects (such as the gus device and voices).
  • The voice wave and volume controls are now types of a common struct.
  • The voice functions that manipulate the wave and volume controls have been collapsed into common functions, which removed some code duplication.
  • Various warning and effective C++ cleanups.

Scope

Similar to the DOSBox project, the above changes are meant for gaming; they are not meant to provide exhaustive demo-scene compatibility, hardware accuracy and quirks, or to emulate the GUS within Windows 3.1 or 95 (all of which involves significantly more code, complexity, performance, and other tradeoffs). Those looking for this level of realism should use DOSBox-X.

Those who prioritize hardware compliance above other factors should continue to use DOSBox or DOSBox-X.

Credits

The DOSBox Staging project would not have been able to even attempt these admittedly topical adjustments without the huge technical foundation provided by the DOSBox and DOSBox-X teams. Thank you.

[Top]


Audio comparisons

The following is a small comparison of what can be expected when using GUS emulation:

All tests were performed by only changing the dosbox executable. The same dosbox.conf, game files, and their configuration/settings were used without changes between runs.

Category Title Audio Sequence DOSBox-X DOSBox-SVN dosbox-staging
Demo 2nd Reality Scene 3 🔈 flac 🔈 flac 🔈 flac
MOD CapaMOD When Heaven Falls 🔈 flac 🔈 flac 🔈 flac
Native StarCon2 Commander Scene 🔈 flac 🔈 flac 🔈 flac
Native StarCon2 Melnorme Scene 🔈 flac 🔈 flac 🔈 flac
Native StarCon2 Pkunk Scene 🔈 flac 🔈 flac 🔈 flac
Native OMF 2097 Intro + Play 🔈 flac 🔈 flac 🔈 flac
Native Silverball Intro + Play 🔈 flac 🔈 flac 🔈 flac
Wavetable RoTT Intro + Play 🔈 flac 🔈 flac 🔈 flac

Visual comparison (Silverball)

DOSBox-X:

Silverball-DOSBox-X

DOSBox:

Silverball-DOSBox

DOSBox Staging:

Silverball-DOSBox-Staging

[Top]


Clone this wiki locally