Difference between revisions of "Adding Sound Support"

From SCI Wiki
Jump to navigationJump to search
Line 61: Line 61:
 
* Currently there's no way to create CMS instrument patch banks. But both DOSBox and ScummVM emulate it perfectly. Its patch file (PATCH.101) is the least complex of the supported devices and is likely easy to reverse engineer. So that might be possible to target as a supported device in the future!
 
* Currently there's no way to create CMS instrument patch banks. But both DOSBox and ScummVM emulate it perfectly. Its patch file (PATCH.101) is the least complex of the supported devices and is likely easy to reverse engineer. So that might be possible to target as a supported device in the future!
 
* Stereo is supported but only 3 settings of panning: Center, 100% left, or 100% right. I believe the panning output is determined by the average of whatever the channel's panning is set to (ie- 0-50% panned right = Ctr, 51%-100% panned right == hard pan R).
 
* Stereo is supported but only 3 settings of panning: Center, 100% left, or 100% right. I believe the panning output is determined by the average of whatever the channel's panning is set to (ie- 0-50% panned right = Ctr, 51%-100% panned right == hard pan R).
 +
  
 
=== Tandy 3-Voice ===
 
=== Tandy 3-Voice ===
Line 84: Line 85:
 
</blockquote>
 
</blockquote>
 
&nbsp;
 
&nbsp;
 
 
  
 
==<br /> Adding the Music/SoundFX Resource ==
 
==<br /> Adding the Music/SoundFX Resource ==

Revision as of 14:43, 23 April 2024

Note: various tools for working with sound for SCI games can be found on the SCI Sound Utilities Page


By Brandon Blume


Introduction

What I've learned so far I've seen from opening up sound resources from Sierra games in SoundBox. A proper MIDI file engineered to run through SoundBox to create an SCI0 sound resource will not sound correct when played through a MIDI player because there are multiple copies of instruments on different channels to playback through the different sound drivers (ADL.DRV, STD.DRV, MT32.DRV, etc). Here are some guidelines I've learned.


Standard General MIDI Support

This is the MIDI support used in Jummybummy. NOTE: You cannot have digital sound effects with this method

You can completely ignore the huge guidelines list above if you go this method. It's actually very very simple. If you just want to run a General MIDI file through SoundBox you can do that instead and have it support General MIDI rather than PC Speaker, Adlib, Tandy, MT-32, etc.

Notes

You just need to make sure, however you play the game, that you're going to have a General MIDI device (whether physical or virtual) connected to the appropriate system MIDI output to be able to hear anything. So that's probably not going to work with Command Prompt in Win2k, XP, Vista, or 7. If you're using DOSBox you'd have to set up your DOSBox settings to point to the correct MIDI device on your system (or the MIDI Mapper). Your sound resource won't be compatible with Adlib, MT-32, PC Speaker, etc if you go with this method.


Classic Adlib/MT-32/PC Speaker/Tandy 3-voice Support

You can use the ADDWave.EXE program included in Ravi's Sound Utilities to append a digital sound file to a sound resource with this method and if you're using SNDBLAST.DRV or MTBLAST.DRV you will hear it in-game instead of the MIDI sound.


Common Details

  • You can use a single channel for multiple device outputs (MT-32, Adlib, Tandy, etc) and it will work on each device as long as the channel follows the rules for each device.
  • Most of the time the Adlib/FB-01/IMFC (and sometimes CMS) channels are the same as the MT-32 channels in Sierra games but there are exceptions. One being if an MT-32 channel has too many voices/notes playing at once for the FM devices. This means you'll have to either trim down the complexity of your MT-32 channels or you can duplicate that instrument in another channel and designate it as Adlib/FB-01/IMFC-only and engineer it to use less voices to stay under those devices' polyphony limits.
  • You can use any channel to output to any music device except the MT-32 (see below) and except for channel 16. Channel 16 is reserved for the SCI interpreter to read specific sound resource controller data from such as cues (for triggering scripted sequences) and loop points.
  • The Initial Voices field in SoundBox's Channel Properties dialogue window is meant only for FM devices (Adlib/FB-01/IMFC/CMS). It is ignored by all other devices.
  • Nobody is quite sure why, but channel 10 always has an Initial Voices setting of 128 in Sierra's sound resources. I recommend keeping it this way in all sound resources just in case it matters somewhere. Soundbox will also set this automatically when importing a standard MIDI file.


MT-32

  • All MT-32 MIDI data must be on channels 2-10 (10 being the drum channel).
  • The MT-32 has a technical timbre/voice polyphony limit of 32. But in practice, it's more like ~18-22. This is because many instruments use more voice polyphony in their timbres than others. Nevertheless, the MT-32 has the highest polyphony of any of the default supported music devices and you probably won't run into it. Though, it's not as a high as something that's General MIDI (a Sound Canvas, soundfont, or VSTi, for instance).
  • Channel 10 will always playback on the MT-32 regardless of whether it is set for it or not.


FM Devices

(Adlib/Sound Blaster & Yamaha FB-01/IMFC)

  • In SCI, Adlib does not have rhythm/drum voices (even though Adlib does support it) because of the way Sierra chose to implement it. So channel 10, while usually being the standard drum channel of most MIDI devices, is a melodic channel for Adlib and not actually a drum channel. As a result, it's not recommended to set channel 10 as an Adlib channel because that's the MT-32's drum channel, and as pointed out above, anything on channel 10 will playback on the MT-32 regardless of the device designation set by the user.
  • Adlib and Yamaha each have a maximum limit of 8 voices in SCI. For Adlib that means 8 notes at a time. But for Yamaha that can be more complex as multiple voices can be used for one instrument. This doesn't just work out of the box like the non-FM devices, though. Each Adlib and Yamaha channel must have their Initial Voices fields set in the Channel Properties dialogue window or no sound will be heard at all in-game. You can change the number of voices at any point in the song by adding voice control changes in the same dialogue by inputting the number of ticks the command is to take place and the value (number of voices). But it must add up to 8 in total at any one time across all channels. So you have to compose those channels in such a way that there are never more than 8 voices playing at the same time otherwise notes will be cut off by the most recent notes if the limit is reached. This can make for a very sub-par listening experience.
  • In Adlib's case, the above rules only apply when using the ADL driver which was designed for the OPL2 chip (which is also mono). If you use the SCI0 SNDBLAST driver instead which is designed for the superior OPL3 chip you will have a much higher voice limit (16 instead of 8!) and it ignores the "initial voices" and voice controller data. Instead it simply plays as many voices as it can, prioritizing the most recent notes if necessary. It will also respect panning and thus you'll get stereo Adlib!
  • OPL2 actually natively supports 9 voices (as well, OPL3 supports 18) but in SCI it only supports 8. I surmise that this must be somehow due to the fact that Adlib support is limited to melodic instruments as opposed to rhythm/percussion. Usually in Adlib 6 voices are reserved for melodic and 3 for rhythm.


CMS/Game Blaster

  • The CMS/Game Blaster device only has a maximum of 12 voices at a time. There's no designation capability implemented for this in SCI (and therefore, not in SoundBox either). Instead this device will use the channels designated for Adlib and just play as many voices as it can.
  • Currently there's no way to create CMS instrument patch banks. But both DOSBox and ScummVM emulate it perfectly. Its patch file (PATCH.101) is the least complex of the supported devices and is likely easy to reverse engineer. So that might be possible to target as a supported device in the future!
  • Stereo is supported but only 3 settings of panning: Center, 100% left, or 100% right. I believe the panning output is determined by the average of whatever the channel's panning is set to (ie- 0-50% panned right = Ctr, 51%-100% panned right == hard pan R).


Tandy 3-Voice

  • Like the PC Speaker, Tandy channels can only have one voice playing at a time. Doubled up notes in the same channel will be cut off by the most recent notes if the limit is reached.
  • A good trick is setting one of the three Tandy channels to double as PC Speaker to save on channel consumption. The other two channels can be any you want (but channel 10 is not recommended for the same reason as Adlib/Yamaha).
  • Though it does not have a corresponding PATCH resource, Tandy "instruments" can indeed be defined somehow. The SN76489/SN76496 chip that the Tandy uses is basically just a tone generator. But each channel does have a volume control. This can be utilized by a driver to set volume envelopes for each tone. One of Sierra's leaked tools is designed to create these envelopes but I do not yet know how it is implemented and recognized by the interpreter.
  • Tandy 3-voice actually supports a sort of 4th channel in the form of a 3-pitch (low, mid, and high) noise channel which also can have a volume envelope (and a different one for each pitch!). AGI uses this extensively in its sounds such as the crashing waves in KQ2, the Arcada doors in SQ1, or the gunshots in the intro of PQ1. But sadly SCI does not, so it's unusable. :(


PC Speaker

  • The PC Speaker channel cannot have more than one note playing at a time. Overlapping notes will be cut off by the most recent note.
  • The PC Speaker channel should carry the fundamental of the theme of the sound file. The lead instrument, if you will. It should contain everything that makes the theme recognizable. You can make this an alternate channel (instead of doubling up with an Adlib or MT-32 channel, for instance) and rework it so it efficiently contains both lead and accompanying melodic notes. Think of how SCUMM games sound in PC Speaker where there's never more than 1 note playing at a time but you can hear lead and melodic elements playing. Though difficult, it's possible to match this type of sound. It can certainly be a difficult process to master, however, and requires a lot of careful planning, skill, and lots of patience.


Notes

All the channels I've referenced here are the proper MIDI channel designations (1-16). SoundBox numbers them from 0-15 instead as a programmer would, so just be aware of that when you're creating your MIDI file and running it through SoundBox.

 


Adding the Music/SoundFX Resource

Note: this part is a stub. If you can help, please expand it.
 

To insert/import a sound resource into a game and utilize it after creating it and after you have your midi and ran it through Soundbox, you should have a SOUND.000 file. Using either Studio or Companion use the "Add resource" and select the new resource. Save the resource as whatever number you want. Use it in your game with gTheMusic, gTheSoundFX, or a sound instance of your own creation.

Code:
(send gTheSoundFX:number(XXX)loop(1)play())


This does not take into account anything like loop points etc.


Digital Sounds

SCI0 originally did not directly support the use of digital samples. Instead all of the sound effects were generated by MIDI. Towards the end of the SCI0 era, Sierra started adding digital sounds to the resources. Initially, these were appended onto a SOUND resource and played with the SoundBlaster driver. There is also a MTBLAST driver will play both the MT-32 music as normal and also the PCM sample through the SB if it exists. Examples of the embedded PCM samples can be found in Space Quest III (Rodger's "Where am I") and in later games such as Quest for Glory II (genie's laugh in the intro).

AddWav

The AddWav utility can embed a digital sample in a SOUND resource to include in an SCI0 game. This method has some limitations. The WAV file must be 8-bit mono and the resulting sound resource must be no bigger than 65536 bytes. Also, the game's configuration file (RESOURCE.CFG) must be set to either SNDBLAST.DRV or MTBLAST.DRV drivers for the digital sound to be played.

The SCI Sound Utilities includes a GUI interface for AddWav to simplify appending a PCM sample to a SOUND resource. It uses an empty SOUND file and will automatically downsample your WAV file to be small enough to embed. It can also do bulk processing of multiple PCM WAV files.

 

sciAudio

An add-on utility made by Gumby makes use of the Google app Narrate and SCI0's ability to output text to a file to be able to use external audio resources controlled by your SCI scripts. The sciAudio app makes it easy to use a range of audio formats.


See also

 

< Previous: Cloudee1's SCI Point and Click Tutorial Back to Tutorials Index >