Commit graph

23 commits

Author SHA1 Message Date
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
Bastien Bouclet
553d2968bb SCI: Add override keywords 2020-02-09 12:43:16 +01: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
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
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
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
a2ead7c4a4 SCI32: Fix include path 2017-06-09 22:48: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
766d46153a SCI32: Implement known-used portions of kPlayDuck 2017-03-30 19:46:27 -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
6a13adb638 SCI32: Fix sign comparison warning 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
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
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