Commit Graph
49 Commits
Author SHA1 Message Date
Cameron Cawley 9f4f22b3bf AUDIO: Support mono audio output in the mixer 2022-11-18 17:17:00 +01:00
sluicebox 0d16892c1d SCI32: Fix GK2 lockups when music volume is turned off
Fixes a bug in the original that locks up many scenes and room
transitions if the music volume slider is lowered all the way
2022-05-12 14:59:53 -04:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
Filippos Karapetis bd7e708fc3 SCI: Move resource related functionality into a separate folder 2020-11-29 14:34:55 +02:00
sluicebox d592a67125 SCI32: Add kDoAudio support for Mac AIFF patch files
Fixes LSL6 hires Mac aerobics room and end credits
2020-09-01 10:31:32 -07:00
Eugene Sandulenko 7a152e9af4 JANITORIAL: #include "engine.h" -> "engines/engine.h" 2020-05-10 23:45:43 +02:00
Bastien Bouclet 553d2968bb SCI: Add override keywords 2020-02-09 12:43:16 +01:00
sluicebox 4b13347df8 SCI32: Add support for AIFF audio
Used by at least LSL6 Mac CD for voices
2019-10-21 11:13:24 -07:00
sluicebox 4d5699a8e7 SCI32: Add support for Mac SND resource playback
Used by at least GK1 Mac, which can now be started without erroring
2019-10-11 14:19:43 -07:00
Colin Snover 93c8044f69 SCI32: Clean up Audio32
* Rewrap comments to 80 columns
* Remove resolved TODOs
* Use containers and smart pointers where appropriate
2017-10-06 22:10:52 -05:00
Colin Snover 7feccaaa98 SCI32: Implement SCI3-variant volume handling
Trying to find differences in Lighthouse's audio sample playback,
I discovered that SCI3 had its own variant of handling volumes and
sending this volume information back to game scripts. It is not
known if this fixes any sound bug.
2017-09-27 20:27:33 -05:00
Colin Snover 21337e4cf6 SCI32: Implement per-channel audio panning
Used by RAMA, in various places, starting with the refrigerator
at base camp after the cable car at the beginning of the game.
2017-09-24 22:56:57 -05:00
Colin Snover 836f1bdf44 SCI32: Add audio dump debugger command 2017-09-19 19:54:29 -05:00
Colin Snover e0aa906804 SCI32: Fix bad audio looping
Fixes Trac#10182.
2017-09-10 02:08:22 -05:00
Colin Snover e137d01967 SCI32: Fix Phant2 movie-vs-game playback volumes
This update should give the game the default mix it receives in
Windows. If necessary, the half-volume audio bug in the DOS
interpreter can be added as an additional hack for this game, since
there are still some sub-par audio mixes that might need additional
correction (like Curtis talking to Blob when taking her out of the
cage in his apartment at the start of the game) which were also
bad in the Windows version of the game.

Fixes Trac#10165.
2017-09-09 23:29:57 -05:00
Colin Snover 74738489ec SCI32: Fix SFX volume being misapplied to music & speech in some games
This was happening in games with game scripts that control the
master volume themselves by applying the master volume to each
channel sent to the kernel, instead of relying on the kernel to
manage the master volume for them.
2017-08-26 18:09:46 -05:00
Colin Snover caa8293fce SCI32: Make sure audio is not paused from the future
This can occur when a save game from the past is loaded and the
audio system was paused prior to loading the save game. This was
fixed eventually in SSCI somewhere around GK2, since it pauses
all audio before restoring a game and then resumes it after the
save game is loaded (after all of the audio channels have been
added from the save game). Since this would seem to be a problem
for earlier games as well, this change is applied universally
instead of being conditionally applied only to the games with
interpreters containing this change.

This patch contains some additional sanity checks that emit
warnings if individual channels end up being started from the
future. There was never such checking in SSCI, and it does not
seem likely to ever happen, but it is unclear right now if this is
an actual problem or not.
2017-07-30 19:22:35 -05:00
Colin Snover 2005ed79d6 SCI32: Emit a warning when an audio resource cannot be found
Refs Trac#9976.
2017-07-23 16:01:19 -05:00
Colin Snover dcb6c32215 SCI32: Destroy audio streams in Audio32 using DisposeAfterUse flag
Since Resource::makeStream returns a MemoryReadStream which will
not attempt to free the resource memory, it is fine to always
dispose those streams and get rid of the separate resourceStream
property, which was a holdover from some past WIP resource design
which no longer exists.
2017-07-17 23:56:21 -05:00
Colin Snover 2528ecf26e SCI32: Fix playback of looped audio
This fixes at least Lighthouse audio 808 in room 270, and audio
801 in room 810.
2017-07-17 22:42:18 -05:00
Colin Snover d556dcc57b SCI: Switch SCI2 games to use Audio32
Upon investigation of Sound code across SCI32 games, it was
determined that there are actually (at least) 3 different
revisions, not just a single SCI2.1 version. This patch only
changes the parts of Sound code that are relevant to the correct
use of Audio32.

Fixes Trac#9736, Trac#9756, Trac#9767, Trac#9791.
2017-06-18 21:42:58 -05:00
Colin Snover 733eaeb499 SCI32: Minor tweaks to improve code clarity & consistency 2017-06-18 21:42:58 -05:00
Colin Snover dc9522eae0 SCI32: Fix Audio32 mix volumes
The previous code for attenuating audio channels was not accurate,
so samples were quieter than they were supposed to be when mixed
together. Robots were also being mixed without attenuation, which
was incorrect.
2017-06-18 21:41:48 -05:00
Colin Snover 85e35943fe SCI32: Implement kLock & kDoAudio(1) for SCI32
1. Unlocking all resources of a type using a resource ID of -1 is
   gone in SCI32;
2. Audio locks need to be serialized starting in GK2 for the game's
   modified kDoAudio(1) call;
3. Audio locks in SCI3 must work more like SSCI, since at least
   Lighthouse's `BackMusic::fade` method will attempt to unlock
   audio that was never locked by a script. In SSCI (and now in
   ScummVM too) this is a no-op; previously in ScummVM, it would
   remove Audio32's own lock on the audio resource, resulting in a
   use-after-free;
4. kDoAudio(1) starting in GK2 returns the number of active
   *not-in-memory* channels being played, not the total number of
   active channels.

Fixes Trac#9675.
2017-06-09 23:00:14 -05:00
Colin Snover 8bdfb78895 SCI32: Add debugger command to list digital audio samples 2017-04-23 13:07:25 -05:00
Colin Snover eb9965274d SCI32: Fix race conditions in Audio32 2017-04-23 13:07:25 -05:00
Colin Snover a867fb70dd SCI32: Fix audio playback with monitored channel in SCI3
SCI3 changes the way that monitored channel works. In SCI2/2.1,
when a channel is monitored, it is the only audible channel. In
SCI3, monitored channels mix normally.

This is very noticeable in LSL7, where music disappears totally
during speech if the monitored channel is the only channel played
back.
2017-04-23 13:07:25 -05:00
Colin Snover 3303a88139 SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.

1. Fixes audio volumes syncing erroneously to ScummVM in games
   that modify the audio volume without user action (e.g. SCI1.1
   talkies that reduce music volume during speech playback). Now,
   volumes will only be synchronised when the user interacts with
   the game's audio settings. This mechanism works by looking for
   a known volume control object in the stack, and only syncing
   when the control object is present. (Ports and planes were
   researched and found unreliable.)

2. Fixes audio syncing in SCI32 games that do not set game
   volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
   GK2, Phant1, and Torin.

3. Fixes speech/subtitles syncing in SCI32 games that do not use
   global 90, like LSL6hires.

4. Fixes in-game volume controls in SCI32 games reflecting
   outdated audio volumes when a change is made during the game
   from the ScummVM launcher.

5. Fixes SCI32 games that would restore volumes from save games
   or reset volumes on startup, which caused game volumes to be
   out-of-sync with ScummVM when started.

6. ScummVM integration code for audio sync has been abstracted
   into a new GuestAdditions class. This keeps the ScummVM-
   specific code all in one place, with only small hooks into the
   engine code. ScummVM integrated save/load code should probably
   also go here in the future.

Fixes Trac#9700.
2017-04-21 19:00:27 -05:00
Colin Snover 0826501ef6 SCI32: Fix audio, wave, VMD, Duck, CLUT, TGA, ZZZ, Etc patches
Specifically, audio patches are used in at least PQ:SWAT
(40103.AUD), Lighthouse (9103.AUD), and the GK2 demo (300.AUD).
2017-03-30 19:46:27 -05:00
Colin Snover 8987d9a889 SCI32: Enable playback of stereo audio 2017-01-09 19:34:54 -06:00
Colin Snover 34bd1bcaa9 SCI32: Split out detection of features that cross SSCI versions 2016-10-20 11:33:29 -05:00
Colin Snover 3cf16c0a7f SCI32: Explicitly instantiate MIN/MAX templates 2016-09-29 19:39:16 -05:00
Colin Snover 21ffb62f80 SCI32: Guard against dynamic_cast failure
CID 1361762, 1361763, 1361764, 1361765.
2016-09-29 19:39:16 -05:00
Colin Snover 0f2748b15a SCI32: Implement kRobot 2016-08-19 14:08:22 -05:00
Colin Snover 949919bebd SCI32: Remove VMD flags from Audio32 mixer
The VMD decoder sends audio directly to the system mixer.
2016-08-06 11:37:18 -05:00
Colin Snover e4588a7134 SCI32: Silence non-monitored channels while monitoring is active 2016-07-11 10:39:50 -05:00
Colin Snover ec73fa1e4a SCI32: Fix audio deadlocks
Several functions in Audio32 would call into the mixer to pause
or resume the audio handle, which would cause a deadlock if the
mixer's mixCallback timer fired while one of these functions was
running on the main thread.

To address this, calls to mixer to pause/unpause the digital audio
handle have been removed. Since this was just an optimisation to
prevent unnecessary calls to fill the audio buffer, the only
problem now is that a tiny amount of CPU is wasted on unnecessary
callbacks to read from the empty SCI mixer.
2016-07-11 10:39:50 -05:00
Colin Snover 1714cf8aa5 SCI32: Minor Audio32 cleanup 2016-07-11 10:39:50 -05:00
Colin Snover b7dcf5f6c1 SCI32: Use better audio fading algorithm
Using the one from SCI2.1mid makes fades very slow because SDL has
a larger audio buffer than SSCI DOS. This new algorithm is based on
wall time so will always fade at the correct speed, although the
larger buffers will have a coarser granularity so the fades may
not be as smooth as in the original engine. If anyone cares, the
fade volume could be mixed into individual samples in `readBuffer`
instead of applying just once per complete buffer. SSCI did not
do this, however, so this implementation should be pretty accurate.
2016-07-01 12:43:39 -05:00
Colin Snover 28d97d0f55 SCI32: Specify default hardware rates
This normally happens in SSCI when the audio hardware is
initialised.

CID 1357048
2016-06-30 15:15:12 -05:00
Colin Snover c5914eb80d SCI32: Fix hang when playing auto-play audio channels 2016-06-26 10:56:36 -05:00
Colin Snover 6ec206ccee SCI32: Fix race condition when freeing audio resources
It's not possible to call any ResourceManager methods from any
thread other than the main thread because it is not thread-safe.
2016-06-26 10:53:45 -05:00
Filippos Karapetis 2e58e6d09f SCI32: Properly initialize pausedAtTick inside Audio32::play()
Fixes audio not playing in later SCI32 games that use Audio32
2016-06-25 17:42:19 +03:00
Filippos Karapetis 5ffafbb9b8 Revert "SCI32: Properly initialize AudioChannel inside Audio32::play()"
This reverts commit 5eaea05a2b.
2016-06-25 17:37:43 +03:00
Filippos Karapetis 5eaea05a2b SCI32: Properly initialize AudioChannel inside Audio32::play()
Fixes audio issues caused by uninitialized variables
2016-06-23 21:58:13 +03:00
Filippos Karapetis e80f1bb115 SCI32: Fix potentially uninitialized variable 2016-06-23 21:07:27 +03:00
Filippos Karapetis 97c50fcfb8 SCI32: Const correction in Audio32's readBuffer() implementation 2016-06-23 21:07:01 +03:00
Colin Snover 46551fd4b5 SCI32: Rewrite digital audio engine
This provides a complete implementation of kDoAudio through
SCI2.1mid, plus partial implementation of SCI3 features.

Digital audio calls shunted through kDoSound have also been
updated to go through the SCI32 audio mixer, though these shunts
are a bit hacky because the ScummVM implementation of kDoSound
does not currently match how SSCI kDoSound is designed.

It is probably possible in the future to just replace the SCI1.1
audio code (audio.cpp) with the new SCI32 code, since the major
differences seem to be that (1) SCI1.1 only supported one digital
audio playback channel (this is configurable already), (2) it
had extra commands for CD audio playback and queued sample
playback.
2016-06-20 21:02:21 -05:00