Commit graph

910 commits

Author SHA1 Message Date
Coen Rampen
27e14762e7 AUDIO: Add Casio MT-540/CT-460/CSM-1 MIDI driver
This adds a MIDI driver for the Casio MT-540, CT-460 and CSM-1 devices. These
are supported by Elvira 1 and several Sierra SCI0 games as well as Altered
Destiny and Les Manley 1.
2022-05-09 17:19:44 +02:00
Coen Rampen
5e1905f5f6 AGOS: Waxworks OPL3 mode instrument attack fix
This fixes the slow attack for several instruments, which causes some barely
audible notes in OPL3 mode.
2022-05-09 17:19:44 +02:00
Coen Rampen
d0c56f0bbc AUDIO: Remove GMF support from SMF MidiParser
This removes the code for the GMF MIDI format used by Simon The Sorcerer from
the SMF MIDI parser. The GMF format now has its own parser.
2022-05-09 17:19:44 +02:00
Coen Rampen
13da6f9cb5 AUDIO: Move null MidiDriver remove timer proc 2022-05-09 17:19:43 +02:00
Coen Rampen
32ba866499 AUDIO: Move MIDI parser source handling to superclass
This commit moves the source handling from the SMF and XMIDI parsers to the
MIDI parser superclass. This reduces code duplication.
2022-05-09 17:19:43 +02:00
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
Coen Rampen
00a907f524 MIDI: Fix parser auto loop skipping first event
The auto loop functionality of the MIDI parser would call jumpToTick to jump
back to the start of the MIDI stream, then call parseNextEvent to read the
first MIDI event. However, jumpToTick already makes sure the first MIDI event
after the jump point is parsed. Calling parseNextEvent again would discard the
first and parse the second MIDI event.
Fixed this by removing the call to parseNextEvent after jumping to the start.
2022-05-09 17:19:43 +02:00
Coen Rampen
b55b1da128 AUDIO: Add arbitrary MIDI instrument remapping
This commit adds a function to the multisource MIDI drivers for specifying an
arbitrary instrument map for remapping the instruments in the MIDI data.

This is used for remapping instruments from two Simon 2 GM tracks to MT-32
because they are missing from the MT-32 MIDI data set.
2022-05-09 17:19:42 +02:00
Coen Rampen
8c4c80d844 AUDIO: Add determineDataSize to XMIDI parser
This is needed for Simon 2.
2022-05-09 17:19:42 +02:00
Coen Rampen
1f0e905160 AGOS: Add MIDI parsers for GMF and Windows
This commit adds MIDI parser subclasses for the Simon 1 GMF format and for the
SMF variant used by the Windows versions of Simon 1 and 2.

The GMF format was handled by the SMF parser, which can now be removed from
that class. It also fixes the tempos not matching the DOS interpreter.

The Simon Windows SMF variant was handled in the AGOS midi class. Moving it to
a separate parser allows for some cleaner code in that class. It now also
corrects the tempos to match those of the DOS interpreter.
2022-05-09 17:19:41 +02:00
Coen Rampen
734817597b AUDIO: Add rhythm mode support to AdLib MS driver
This adds support for the OPL rhythm mode to the AdLib multisource MIDI driver.
Some games (f.e. Simon 1) use this to generate the rhythm sounds of their music.
2022-05-09 17:19:41 +02:00
D G Turner
9af3ef5e88 AUDIO: MT32: Fix Undefined Macro Compiler Warnings
These were emitted by GCC when -Wundef was passed.
2022-03-21 21:37:04 +00:00
D G Turner
a1de9a95c6 AUDIO: MT32: Fix Internal Sample Rate Converter Code
This was previously disabled implicitly by the missing define
symbols in the SampleRateConvertor module. This has now been enabled
to use the internal rate convertor code.

This was generating undefined macro warnings from GCC when -Wundef
was passed.
2022-03-20 22:54:04 +00:00
NMIError
221fa4c841
AUDIO: Add support for RetroWave OPL3
This commit adds support for the SudoMaker RetroWave OPL3 sound card. Requires
the retrowave library.

Add the following settings to scummvm.ini:
retrowaveopl3_bus=serial
retrowaveopl3_port=<port> f.e. COM3 or ttyACM0
2022-01-29 17:33:29 +01:00
Paweł Kołodziejski
20cb0ae228
ALL: Cleanup ResidualVM -> ScummVM 2021-12-26 21:19:38 +01:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Filippos Karapetis
9473b382b5 AUDIO: Remove unused variable
Thanks to eientei for reporting this
2021-12-24 03:25:22 +02:00
Quietust
3f4d59800d AUDIO: Add Paula per-channel DMA interrupts
These will be needed for proper emulation of the Amiga SCUMM V2/V3
sound engines.
2021-12-13 20:53:21 +01:00
D G Turner
1dd7e98be3 AUDIO: Fix GCC Warning by Removing Redundant Assertion from Mixer
The output buffer size variable is unsigned so an assertion of
greater than or equal to zero will always be true, which generates
a type limits compiler warning.
2021-12-11 20:50:05 +00:00
Andrea Boscarino
f37489dd80 AUDIO/BACKENDS: Store output audio buffer size in Mixer 2021-12-09 22:03:40 +01:00
Paweł Kołodziejski
2bc3d7f4ed
AUDIO: Fixed compiler warning, this is always true 2021-12-05 16:17:20 +01:00
Coen Rampen
b70ab20fc8 AUDIO: MIDI controller defaults on track start
This commit adds a feature to the multisource MIDI drivers which allows setting
a default value for most controllers. This default is then applied at the start
of every new track, which ensures controllers are in the correct state.
This can be used for games which use some controller, but do not reset it at
the start of each track, which can lead to incorrect playback.
2021-11-17 21:54:59 +01:00
Orgad Shaneh
2bd0347968 AUDIO: Use override
Using clang-tidy modernize-use-override
2021-11-14 20:14:11 +02:00
Orgad Shaneh
af529f568b AUDIO: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 13:41:02 +02:00
Orgad Shaneh
7a4e5612de JANITORIAL: Replace new[]/memset with new[]()
Mostly done using the following Ruby script:

(Dir.glob('**/*.cpp') + Dir.glob('**/*.h')).each do |file|
  s = File.read(file, encoding: 'iso8859-1')
  t = s.gsub(/(([\w_.\[\]]+)\s*=\s*new\s+\S+?\[[^\]]+?\](?!\())([^\{\}]*?)\n\s+memset\(\s*\2\s*,\s*0\s*,[^;]*;/m, '\1()\3')
  if t != s
    File.open(file, 'w') { |io| io.write(t) }
  end
end
2021-11-10 19:53:15 +01:00
Coen Rampen
e4887696a9 AUDIO: Fix ineffective version prop on Miles AdLib
Setting the Miles driver version property to 3 was meant to set the pitch bend
range to 2. In the AdLib driver, the pitch bend range was set during
construction, before the version property could be set, so this did not work
properly. This is fixed by moving the MIDI data initialization from the
constructor to the open function.
2021-11-04 22:15:38 +01:00
Alexandre Detiste
6044504762 JANITORIAL: typos
some in the variable names, some in the comments;
no change for the strings that interract with original games assets
2021-10-31 20:46:31 +01:00
D G Turner
46ca3865f0 AUDIO: (FM-TOWNS): Update Comment on Dead Code 2021-10-31 18:51:10 +00:00
Coen Rampen
952de88758 SCUMM: Fix Sam & Max OPL3 pitch bend
The pitch bend in Sam & Max was exaggerated when using the OPL3 driver. The
OPL3 functionality was apparently implemented by examining just the original
driver code and not the MIDI processing code in the interpreter. The pitch bend
values sent to the driver are not standard MIDI pitch bend values, but have
been processed by the interpreter, so the driver logic cannot be directly
applied to the pitch bend values from the MIDI data.

This commit fixes the pitch bend calculations to produce the same results as
the original interpreter. It also restores the pitch bend range functionality.
This was disabled for OPL3, probably because it is implemented in the
interpreter instead of the driver. It is used in several Sam & Max MIDI tracks.
2021-10-30 21:34:27 +02:00
D G Turner
6a3310eb6f AUDIO: (FM-TOWNS): Fix Duplicated Branch GCC Warning 2021-10-29 18:02:59 +01:00
Torbjörn Andersson
338b3c6dee AUDIO: Fix check for OPL3 capable emulation
Both DOSBox and Nuked OPL should handle OPL3. Only the old MAME one
doesn't.
2021-10-20 13:34:31 +02:00
Coen Rampen
d8491ecea4 AUDIO: Add default for OPL channel volume
This adds an option to the AdLib multisource driver to set the MIDI channel
volume that will be used to initialize to OPL 4x registers.
2021-10-09 16:59:44 +02:00
Coen Rampen
111b237e02 AUDIO: Fix Roland GS emulation not using MT-32 drumkit
The Roland GS MT-32 emulation option would not select the MT-32 drumkit on the
GS device, because the drumkit change was filtered out in the MT32GM driver.
This commit fixes this by adding an exception for this drumkit change when GS
MT-32 emulation is active.
2021-10-09 16:59:44 +02:00
Coen Rampen
2661548758 AUDIO: Fix stray ; and some warnings 2021-09-27 23:40:54 +02:00
Coen Rampen
5362b1b302 AUDIO: Add command queue to PC speaker emulator
This adds a command queue to the PC speaker emulator for PWM-style sounds that
need timing of less than a millisecond. The play method only supports
milliseconds and requires real time control, which is difficult to achieve with
microsecond timings.
The new playQueue method allows you to queue up playback instructions with
microsecond timing, which are executed when audio samples need to be generated.
2021-09-27 21:45:40 +02:00
Cameron Cawley
c2bbccd1db AUDIO: Support using .wav files for extracted Audio CD tracks 2021-09-07 14:35:43 +03:00
Eugene Sandulenko
198975a007
AUDIO: Fix message format 2021-08-23 16:26:31 +02:00
Coen Rampen
c0388b833c AUDIO/MIDI: Fix OPL empty instrument check
The empty OPL instrument check would check only the ADSR envelope fields for 0,
assuming this would mean the instrument would produce no sound. However, some
of these fields are flipped, i.e. max value would produce no sound. So this
shortcut was invalid. It is replaced by checking all fields for 0.
2021-08-14 21:48:10 +02:00
Coen Rampen
1b6b124c57 AUDIO/MIDI: Clear timer registers in OPL driver init 2021-08-14 21:48:10 +02:00
djsrv
22775dff7e AUDIO: Create Mixer::loopChannel() 2021-08-12 13:18:27 -04:00
Coen Rampen
dfb8db2ae2 AUDIO/MIDI: Add dual OPL2 support to Miles AdLib driver
This adds support for the dual OPL2 chip configuration to the Miles AdLib MIDI
driver.
2021-08-12 14:30:52 +02:00
Coen Rampen
0245ae15b0 AUDIO/MIDI: Add reset source volume to multisource drivers
This adds a convenience function to reset the source volume to the source
neutral volume.
2021-08-08 22:12:06 +02:00
Coen Rampen
7fb83e71b5 AUDIO/MIDI: Add timer proc to null multisource driver
This adds a timer proc to the null multisource MIDI driver to drive the fading
process. The null driver does not have any audio to fade, but without this the
fades will just hang and isFading will remain true. The fades are now
effectively timers so game behavior will remain consistent whether MIDI is
turned on or off.
2021-08-08 22:12:06 +02:00
Coen Rampen
994609e91c AUDIO/MIDI: Make Miles pitch bend range v3 specific
Miles version 3 introduced support for the MIDI pitch bend range RPN using the
data entry MSB controller. The ScummVM implementation would also process this
controller for Miles version 2 games. This caused a problem in Ultima 8, which
used Miles 2 and which had MIDI data that contained some (probably leftover)
data entry MSB events. These had no effect in the original interpreter, but in
ScummVM they caused the pitch bend range to change, resulting in incorrect
playback.

This is fixed by only processing the data entry MSB controller events when
Miles version is set to 3.
2021-08-08 22:12:06 +02:00
Max Horn
1d7d03bd6e AUDIO: fix global constructor warnings 2021-08-07 10:46:14 +02:00
Coen Rampen
d65edaa6b3 AUDIO/MIDI: Fix Miles default source volume
The default source neutral volume for the Miles MIDI driver is set at 256.
However, the default source volume was the same as that of the regular MT-32/GM
driver: 255. This would cause a small volume decrease if a game did not set
source volume.

This commit fixes this issue by setting the default source volume for the Miles
MIDI driver at 256.
2021-08-06 21:01:09 +02:00
Coen Rampen
54663b953a AUDIO/MIDI: Fix Miles AdLib initialization
The ScummVM Miles AdLib driver would write some different initialization values
to the OPL registers than the original Miles drivers did. The most significant
difference was the amplitude and vibrato depth.

This commit changes the Miles AdLib driver to set the same values as the
original drivers. It also adds support for initializing a dual OPL2
configuration.
2021-08-06 21:01:09 +02:00
Coen Rampen
d73b19b9b3 AUDIO/MIDI: Fix Miles 3 AdLib pitch bend range
Miles 2 uses the default MT-32 pitch bend range of 12 semitones for its AdLib
driver. Miles 3 switched to the default GM pitch bend range of 2 semitones for
AdLib. ScummVM would always use the Miles 2 pitch bend range, which caused
pitch bend for Miles 3 games to sound wrong on AdLib.

To fix this, a property was added to the Miles AdLib driver to specify which
Miles version to emulate. Depending on the value of this option, the correct
default pitch bend range is set.
2021-08-06 21:01:08 +02:00
Max Horn
34523aba7e JANITORIAL: Fix some typos 2021-08-04 15:43:15 +02:00
Coen Rampen
2edc3773bc AUDIO/MIDI: Fix Miles AdLib fades
This fixes some issues which caused the fades in the Miles AdLib driver to not
work properly:
- _timerRate was not set
- end of track meta event was not handled, so active fades were not aborted by
deinitializing the source on end of track
The timerProc fields and onTimer function were removed because they duplicate
functionality from the MidiDriver_Multisource base class.
2021-07-29 20:24:42 +02:00