Make Sierra Audio AdPlug Compliant

From Video Game Music Preservation Foundation Wiki
Jump to: navigation, search

Make Sierra Audio AdPlug Compliant is a script that will rename audio files extracted from a Sierra SCI game to a naming convention that is compliant with AdPlug. This is necessary because AdPlug requires a matching prefix of at least three-characters for all audio and patch files in order for it to play correctly. This script will rename all the files for you so you don't have to rename them individually.

Using the Script

  1. Obtain the file, either by downloading the zip file and extracting the .js file, or by pasting the source into an empty text file, see Source Code.
  2. Place the file in the same folder as all the sound and patch files.
  3. Right-click on the file, and choose Edit to open the script in Notepad.
  4. Go to line 2 which reads: var Prefix = "KQ4";
  5. Replace the three-character code inside of the quotation marks to match whatever game files you're working with (KQ5, PQ2, SQ4, etc.).
  6. Save the document and close Notepad.
  7. Double-click the Make Sierra Audio AdPlug Compliant.js file.
  8. All of your sound.001, sound.002, etc. files will now be renamed to KQ4 - 001.sci, KQ4 - 002.sci, etc.
  9. Note that the only patch file that will be renamed will be the patch.003 file. This is because only it contains the AdLib instructions.
  10. You can now play the songs in AdPlug properly.

Source Code

If you want to make your script directly from the source code, do the following:

  1. Open Notepad, or equivalent.
  2. Highlight the code below, right-click, and choose Copy from the menu.
  3. Right-click into Notepad and choose Paste from the menu.
  4. The source code will be pasted into Notepad.
  5. Save the document as Make Sierra Audio AdPlug Compliant.js in the folder with the audio files.
  6. Close Notepad.
  7. The script file will probably have a .txt extension, you must remove it.
  8. If you can't see the extension, you need to turn off "Hide extensions for known file types".
  9. The file will now be recognized as a JScript file instead of a text document.
  10. Follow the instructions for Using the Script.
// Change this prefix to whatever game you're workig with.
var Prefix = "KQ4";

// Get the files in the current folder.
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
var Folder = oFSO.GetFolder(".\\");
var FileObject = Folder.Files;
var FileList = new Enumerator(FileObject);

// Loop through all the files in the current folder.
for(; !FileList.atEnd(); FileList.moveNext()) {
 	var Path = FileList.item().ParentFolder;
	var FileName = FileList.item().Name;

	// Give the sound files a prefix and the *.sci extension.
	if(FileName.substr(0, 5).toUpperCase() == "SOUND") {
		var JustName = FileName.substr(0, 5);
		var Ext = FileName.substr(6, 3);
		var NewFile = Path + "\\" + Prefix + " - " + Ext + ".sci";
		oFSO.MoveFile(FileName, NewFile)
	// Give the patch file the prefix.
	if(FileName.toUpperCase() == "PATCH.003") {
		var NewFile = Path + "\\" + Prefix + "patch.003";
		oFSO.MoveFile(FileName, NewFile)

See Also