Commit Graph
106 Commits
Author SHA1 Message Date
Coen Rampen 6a9fc73962 AUDIO: Small MIDI driver enhancements and fixes
This commit adds the following functionality to the MIDI drivers:

- Add checking if a driver is ready to process MIDI events for a specific
source (rather than any source). To facilitate this, SysExes can now be sent
using a source number. This is stored with the SysEx data in the SysEx queue
and can be checked when isReady is called with a source number.
- Allow specifying controller default values per MIDI channel. Currently this
is only implemented for program.
- The OPL dynamic channel allocation algorithm will now respect statically
allocated channels, in case a subclass uses combined static and dynamic channel
allocation.

It also fixes the following bugs:

- Instrument remapping can now be specified using const arrays.
- OPL instrument writing code is refactored to a separate function.
- OPL note on with velocity 0 would be handled as a note off, and then
continued to be processed as a note on.
- OPL writeFrequency would always write key on bit, even if the note is not
active.
- MT-32 default channel volume was incorrect.
2022-05-09 17:19:43 +02:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Coen Rampen cb97a47828 GROOVIE: Add MIDI controller defaults for T7G and 11H
The 7th Guest uses the orchestra drumkit by setting it during initialization,
but not at the start of each track. Some tracks temporarily change the drumkit;
if these tracks are stopped at a bad moment, this changed drumkit remains in
effect. This commit sets the drumkit default to the orchestra drumkit to make
sure it is applied at the start of each track.

Some of the MIDI tracks of The 11th Hour use the modulation controller, but not
all tracks reset this controller at the start. This commit sets the modulation
default to 0 to make sure it is reset at the start of each track.
2021-11-17 21:55:09 +01:00
Coen Rampen d042315d0b GROOVIE: Stop current song before playing new song
When playing a new song, ScummVM would update the volume to the standard value
before stopping playback of the current song. This would cause a volume change
right before stopping a song. This commit stops the current song before setting
the volume, which removes the unnecessary volume change.
2021-11-17 21:53:44 +01:00
Coen Rampen 649cb7b450 GROOVIE: Set correct Miles version for 11th Hour
This changes the Miles version for The 11th Hour to version 3. This sets the
pitch bend range to the correct 2 semitones.
2021-11-17 21:53:43 +01:00
Orgad Shaneh 0909948281 GROOVIE: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
Filippos Karapetis e775552e9d GROOVIE: Fix overridden class members 2021-10-24 17:30:14 +03:00
Filippos Karapetis 692bad517f GROOVIE: Restructure GroovieV2 game logic
- Move Groovie2 mini-game logic orchestration inside script opcode 0x42
- Move 11h mousetrap logic into a separate file
- Move music file names for MusicPlayerClan inside music.cpp
- Remove the now obsolete ClanGame and T11hGame classes
2021-10-23 02:42:39 +03:00
Misty De Meo 562c0f7c8c GROOVIE: check for USE_MAD for MP3
The groovie engine is unconditionally trying to acess the
`Audio::makeMP3Stream` method, which won't exist if ScummVM is
being compiled without MAD. Other consumers use this `#ifdef` to
determine if they should try to call it, so I've made the same
change here.
2021-10-13 23:52:24 +03:00
Die4Ever 7f001a7966 GROOVIE: fix Clan music on Mac/iOS 2021-09-16 22:44:14 -05:00
Filippos Karapetis 8cf46e2f7f GROOVIE: Restructure game-specific logic code and video code 2021-09-16 09:25:47 +03:00
Die4Ever 5415539dba GROOVIE: Clandestiny fix music for m4a files 2021-09-16 09:21:24 +03:00
Die4Ever 0c66948292 GROOVIE: fix Clandestiny music on Mac 2021-09-16 09:21:24 +03:00
Filippos Karapetis 8f3d07b05e GROOVIE: Initial work on UHP. 7/13 mini-tames are currently functional
From the 12+1 mini-games:
- Crypts (T7G) works
- Cake (T7G) works
- Spiders (T7G) works
- High Lights (T7G) works
- Blood and Honey / beehive (11H) misses game logic
- The Amazing Labyrinth / mousetrap (11H) misses game logic
- Book Checkers (11H) works
- SwitchBoard (11H) works
- Cursed Coins (Clan) misses game logic
- Trade Winds (Clan) crashes with missing resources
- Statue Paths (Clan) crashes with missing resources
- Leap Frogs (Clan) works
- The final puzzle is not accessible yet
2021-09-16 00:07:40 +03:00
Filippos Karapetis c97f524b77 GROOVIE: Silence bogus warning when using digital music tracks 2021-09-15 23:00:21 +03:00
Die4Ever 9b490a0864 GROOVIE: unset _waitingForInput and cleanup
Unset _waitingForInput to make the game more responsive. Also some cleanup of old commented out code.
2021-09-15 19:13:57 +03:00
Die4Ever 1a9cd3e900 GROOVIE: fix uses of ENABLE_GROOVIE2
Fixing compiler errors when groovie2 was disabled
2021-09-15 19:13:57 +03:00
Die4Ever 1dd7a5f66a GROOVIE: code review feedback
fixes for MusicPlayerTlc

optimizations and cleanup in roq.cpp

lots of cleanup in tlcgame.cpp
2021-09-15 19:13:57 +03:00
Die4Ever 038758a7f2 GROOVIE: Clandestiny music
Clandestiny uses a hardcoded lookup table for song filenames
2021-09-15 19:13:57 +03:00
Die4Ever c7e4c851f6 GROOVIE: some cleanup 2021-09-15 19:13:57 +03:00
Christian Lindemann 6525123663 GROOVIE: TLC Music / Small Bugfixes / Better Comments 2021-09-15 19:13:57 +03:00
Coen Rampen 935c421d76 GROOVIE: Simplify XMI player Miles driver usage
This simplifies the way the MusicPlayerXMI uses the Miles MIDI drivers by using
the common superclass MidiDriver_Multisource. User volume scaling is moved to
the MIDI driver for this player.
2021-07-13 22:11:58 +02:00
Orgad Shaneh a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
NMIError cdd2d58361 GROOVIE: Fix starting background music
The check to see if background music should be started was implemented as part
of the input processing. As a result, background music would not start if the
game was not getting any input. F.e. on the main menu after starting the game,
if you let the music play until it finishes without doing anything, the game
will go silent. Only after moving the mouse will the background music track
start. The original interpreter starts the background music without needing
user input.

I've fixed this by moving the check to start background music to the timer
loop of the MusicPlayer. I've added a check to prevent background music from
starting while the game is not accepting input.
2020-08-21 00:03:09 +02:00
NMIError 4ed78ef114 GROOVIE: Fix music when loading game
When loading a savegame, the current background music would play for a few
seconds before the game would set the music for the room that just loaded.
This change stops the music when loading a savegame to prevent this.
2020-08-21 00:03:09 +02:00
NMIError 2d87adbed4 GROOVIE: Fix music fade-out behavior
When fading out a music track, the original interpreter would keep playing the
track at volume 0. ScummVM would instead stop playing the track, which would
cause the background music track to start playing, while there would be no
music in the original interpreter. Also, when starting playback of a new track,
the original interpreter would restore the volume first, then start playback of
the new track, causing a short part of the old track to be played before the
new track starts. ScummVM would turn the volume back up, but not actually apply
this to the MIDI device, causing new tracks to sometimes play at volume 0.

This change fixes these issues. After fading out, actual playback on the MIDI
device is stopped, but the state of the music player keeps indicating that
music is playing. This prevents the background music from starting. Because
playback is actually stopped, the original interpreter issue of playing a short
bit of the old track when the new track starts is prevented. When resetting
volume when starting a new track, the new volume is now applied to the MIDI
device, which fixes the issue of the new track playing at volume 0.
2020-08-21 00:03:09 +02:00
NMIError dcdcca3d31 GROOVIE: Initialize MIDI on direct game load
The 7th Guest has MIDI initialization files for GM and the MT-32 that need to
run for these devices to sound correctly. When loading a game from the ScummVM
main menu, MIDI initialization was not performed.

This change adds this. It runs a slightly changed copy of the game's MIDI init
script when loading a game using the ScummVM menus. It also tracks if MIDI init
has been performed, so it doesn't run a second time when loading a game.

I don't know if the script works properly for the Mac and iOS versions of the
game (or if it is even needed), so I've only enabled it for the DOS versions of
the game for now.
2020-07-25 00:35:47 +02:00
NMIError 5da83d8ea0 GROOVIE: Pause music when ScummVM menu is open
The MIDI music would keep playing while the ScummVM menu was open. This would
cause the music for cutscenes to go out of sync. I've added pausing to the
MusicPlayerMidi to fix this.
2020-07-25 00:35:47 +02:00
NMIError 3ad8c85af2 MIDI: Prevent duplicate MIDI messages
The MIDI parser would send All Notes Off events on all MIDI channels as a
safety measure when stopping playback in various situations without first
checking if a track was actually playing. Depending on the specifics of the
code driving the MIDI parser, this could generate many duplicate All Notes Off,
Sustain off and/or Pitch Bend center messages. This is a problem for slow MIDI
hardware like the MT-32, which needs some time to process all these messages.
As a result, the timing at the beginning of the next track could be wrong.

I've introduced checks in stopPlaying, setTrack, unloadMusic and the MIDI
parser destructor so that allNotesOff is called once when a track is playing,
and not a second time when playback has already stopped. Similarly, unloadMusic
does not execute when no music is loaded to prevent duplicate Pitch Bend
messages.
2020-07-25 00:35:47 +02:00
NMIError 315bbc7b5b MIDI: Use driver-specific impl. for stopping all notes
When the MIDI parser wanted to stop all notes on a MIDI device, it would send
an All Notes Off message and, optionally, a Sustain off message on all 16 MIDI
channels. This is inefficient for devices like the MT-32, which uses only 9
channels. The MT-32 hardware is also quite slow, so it is more responsive if it
has to process less messages.

I've added a generic stopAllNotes message to the MIDI driver using the old
method, which can be overriden by more specific implementations in subclasses.
The Miles MIDI driver implementation sends All Notes Off only on the channels
used by the MT-32. There are probably also more efficient implementations
possible for f.e. AdLib.
2020-07-25 00:35:47 +02:00
NMIError 0856c04bfa GROOVIE: Remove dead music code
The Groovie engine implemented some functionality which was later reimplemented
in the generic Miles drivers. These are now used by the engine, but the old
code is still present. I've removed this to clean up the audio code.
2020-07-25 00:35:47 +02:00
NMIError 848d8315a6 MIDI/GROOVIE: Refactor XMIDI timbre chunk loading
XMIDI timbre chunk processing was implemented using a callback. This
reimplements this using an interface for the necessary driver method, which is
a somewhat cleaner solution.
2020-07-25 00:35:47 +02:00
NMIError b38f1f00ac MIDI/GROOVIE: Fix MT-32 XMIDI timbre init delays
XMIDI data for the MT-32 can contain a timbre chunk which contains the custom
timbre numbers used for a track. Before starting playback of the track, the
timbres must be loaded into the MT-32 using SysEx messages. Each SysEx message
needs a delay before sending the next message to give the MT-32 enough time to
process it.

The delays between the messages were generated using the OSystem::delayMillis
function. This throws off the timing of the MidiParser, which causes MIDI
messages to "pile up", in this case at the start of the track. This change adds
a queue to the Miles MIDI driver, which can store the SysEx messages that must
be executed. The MidiParser suspends playback until the driver has sent all
messages in the queue.

This fixes the start of tracks in The 7th Guest, which had incorrect timing.

Because of the new SysEx queue, MT-32 initialization of The 7th Guest takes a
bit longer than it did before. The game plays an animation of a fixed length
and aborts the initialization if it is not done by the end of the animation.
This problem was already fixed for the GM initialization, so I've applied the
same fix for the MT-32.
2020-07-25 00:35:47 +02:00
NMIError dd0090dc7a GROOVIE: Use new Miles MIDI driver functionality
This adds using the updated Miles MIDI driver for GM music and using the driver
for source volume scaling.

This reduces the amount of MIDI volume messages when fading, because they are
now only sent on active MIDI channels and if they are different from the
current channel volume. This fixes problems with hardware MIDI devices like the
MT-32 and SC-55, which have trouble dealing with the high number of messages.
2020-07-25 00:35:47 +02:00
NMIError e11d408f0a GROOVIE: Add Roland GS invalid drumkit correction
The GM music for The 7th Guest contains several drumkit selection
messages which use an incorrect drumkit number. This relied on a
correction mechanism of the Roland SC-55, which would correct these
numbers to valid selections. This mechanism was not present in later
GS and GM devices, causing error messages and wrong drumkits.

I've fixed this by adding code which simulates the correction
mechanism of the SC-55.
2020-03-16 01:40:10 +02:00
NMIError a7082b15fa GROOVIE: Send GS SysEx messages
The 7th Guest sends several SysEx messages for Roland GS devices during
startup. ScummVM did not send these messages.

The Groovie MusicPlayerMidi class encapsulates the MidiDriver which is
actually used for sending MIDI events. However, it did not implement the
sysEx method, so the empty implementation of MidiDriver_BASE was used.
I've added a sysEx method which forwards the messages to the actual
MidiDriver.
2020-03-16 01:40:10 +02:00
Eugene Sandulenko 829e62a9fe GROOVIE: Clean initialization for few classes 2016-05-28 15:26:31 +02:00
Matthew Hoops 030e4d0608 AUDIO: Make Rewindable- and SeekableAudioStream inherit virtually 2015-08-30 19:53:53 -04:00
Martin Kiewitz bf180101a6 GROOVIE: add support for TIMB chunk
also fix MT32 instrument filename (which was "fatFAT.MT" by accident)
2015-06-30 16:11:26 +02:00
Matthew Hoops 30de61dcce GROOVIE: Silence a gcc warning 2015-06-28 20:05:24 -04:00
Martin Kiewitz 7ecf553e24 GROOVIE: add support for Miles Audio MIDI driver
- currently optional, to enable set milesAudioEnabled to true
2015-06-28 01:16:43 +02:00
D G Turner d8751516cc GROOVIE: Remove engine-specific "all" debugflag. Minor naming cleanup.
This is now uneeded as the GUI debugger superclass implements the same
functionality and this removes a bunch of complexity from the Groovie
engine debug calls. Also, removed groovie prefix from the debug flag
naming as unecessary as these are within the Groovie namespace.
2014-06-05 03:01:12 +01:00
Johannes Schickel 8f55aed475 GROOVIE: Make GPL headers consistent in themselves. 2014-02-18 02:39:35 +01:00
Matthew Hoops 7d684d1166 GROOVIE: Add a MusicPlayerMac_v2 for 11H Mac 2012-09-12 18:02:58 -04:00
Matthew Hoops 72a1140d57 GROOVIE: Rename MusicPlayerMac to MusicPlayerMac_t7g 2012-09-09 12:43:29 -04:00
Eugene Sandulenko 0dafa7f80f ALL: Reduce audio/ header dependency 2011-08-06 11:30:42 +01:00
Eugene Sandulenko 78f1ea7690 OSYSTEM: extended installTimerProc() with timer ID parameter 2011-08-06 11:28:35 +01:00
Max Horn 88913c0139 ALL: Remove trailing whitespaces
This tries to make our code a bit more compliant with our code formatting
conventions. For future use, this is the command I used:
  git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//'
2011-06-20 00:59:48 +02:00
Scott Thomas ae4b298bbb GROOVIE: Fix MusicPlayerIOS volume not correctly restoring on new song 2011-06-03 19:49:56 +09:30
Matthew Hoops 5bb4ef13c5 GROOVIE: Rename MusicPlayerMPEG4 to MusicPlayerIOS
More fitting now that other music formats can be used now
2011-05-31 14:25:20 -04:00