Difference between revisions of "SCI/Specifications/Sound/SCI0 Resource Format"

Jump to navigation Jump to search
m (Improved table formatting, linkify section)
(added information about kq4/1988 xmas sound header)
Line 129: Line 129:


==File Format==
==File Format==
Sound files follow the same format as all extracted SCI0 resources. The first two bytes of the file contain a magic number identifying the resource type. The rest of the file contains a dump of the uncompressed data. The identifier is the resource type (<tt>04h</tt> for sound) OR-ed with <tt>80h</tt> and stored as a word. The result will be <tt>84h 00h</tt> in extracted sound files.
There are 2 formats used in SCI0 games. One is an early format used in a version of kq4 and 1988 xmas card. The other one is used in all other SCI0 titles.
 
The first two bytes of the file contain a magic number identifying the resource type. The rest of the file contains a dump of the uncompressed data. The identifier is the resource type (<tt>04h</tt> for sound) OR-ed with <tt>80h</tt> and stored as a word. The result will be <tt>84h 00h</tt> in extracted sound files.


The sound resource data itself is a header with channel initialization followed by a series of MIDI events.
The sound resource data itself is a header with channel initialization followed by a series of MIDI events.
The header provides the sound driver with 2 pieces of information about each channel.
==Header (kq4, 1988 xmas card)==
The first byte is a digital sample flag. Afterwards 1 byte follows for each channel (totals in 17 bytes).
The upper 4 bits of that byte specify how many voices each logical MIDI channel will be playing. The lower 4 bits specify which drivers should react on that channel. Bit 0 set means adlib shall react. Bit 1 set means PCjr shall react. MT32 will react on all channels. Bit 3 signals the control channel.
The original sierra driver needs bit 3 set and bit 0 unset to find the control channel. Also the adlib driver needs bit 3 to be unset, otherwise the driver will ignore the channel even if bit 0 is set.
Currently its not known if the digital sample flag behaves the same as in the SCI0 header.
==Header (all other SCI0 titles)==
The first byte is a digital sample flag. Afterwards 2 bytes follow for each channel (totals in 33 bytes).


=== Header ===
The first of those bytes specifies how many voices each logical MIDI channel will be playing. For MIDI synths, this information is not really necessary and is probably ignored. The same goes for beepers. This byte is only useful for non-MIDI synths which must know how many hardware channels each logical MIDI channel will need. This value is only an initial setting. Sound files can request changes to the mapping later with control changes. Requesting more hardware channels than are actually available can cause errors on some drivers.
The header provides the sound driver with 2 pieces of information about each channel. The first is a byte which specifies how many voices each logical MIDI channel will be playing. For MIDI synths, this information is not really necessary and is probably ignored. The same goes for beepers. This byte is only useful for non-MIDI synths which must know how many hardware channels each logical MIDI channel will need. This value is only an initial setting. Sound files can request changes to the mapping later with control changes. Requesting more hardware channels than are actually available can cause errors on some drivers.


The second byte describes how the user's sound hardware should treat the channel. It is the combination of bit flags which may be OR-ed together. If the appropriate bit is set for the currently selected sound device, the channel will be played. If it is not, the channel will be silent. The driver decides which bit it will use as the play flag, and the table under Sound Devices lists the flag used by each driver. Drivers ignore the first byte (used to request hardware channels) on MIDI channels they don't play.
The second byte describes how the user's sound hardware should treat the channel. It is the combination of bit flags which may be OR-ed together. If the appropriate bit is set for the currently selected sound device, the channel will be played. If it is not, the channel will be silent. The driver decides which bit it will use as the play flag, and the table under Sound Devices lists the flag used by each driver. Drivers ignore the first byte (used to request hardware channels) on MIDI channels they don't play.