Author Topic: Adding music with WeiDU - by Talon  (Read 4708 times)

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Adding music with WeiDU - by Talon
« on: April 01, 2004, 03:29:47 AM »
Adding music with WeiDU  

At the very least, you’ll need a program that can convert WAV files to ACM files, such as Infinity Sound Converter or DLTCEP, WeiDU, and a basic sound program (the Sound Recorder that comes with windows works fine). However, Near Infinity also helps when it comes to making sure it all works.

The first step is getting WAV format music into BG’s ACM format. Upon running it straight through ISC, you get music that is way too slow. To recify this, open up your music in sound recorder, and select Increase Speed (100%) under the edit menu. Save this, and run it through ISC. Once this is done, test it to make sure it’s OK (using ISC again). For this tutorial, call it MxTestA.acm

The second step is producing a MUS file. An MUS file is sort of like a “playlist”. If you are making music for, say, a romance, this is easy. For area/combat music it’s somewhat harder – the music loops sections, has an ending that may occur anywhere during the music, and so on. For the purposes of this tutorial, we’ll only look at the simple ones.
The playlist file ends up in the music directory, and from there it runs whatever acm files (from within the music directory) that it needs. A look at a simple one (Viconia’s romance music) gives this:

MXVICON
1
A @TAG END


What this means is that it looks in the directory MXVICON for the acms to use, that there is only 1 file to play, and the first file to play is the one that ends in A (the file is MXVICONA.acm), then ends. To make the MUS file for our tutorial, just enter:

MxTest
1
A @TAG END


Save this as MxTest.mus

Create a new folder in the BG2 directory (call it musictest), place MxTest.mus and MxTestA.acm into the root of that folder, and create tp2 as you would for any MOD, and into the tp2 add:

MKDIR ~music/MxTest~
COPY ~musictest/MxTest.acm~ ~music/MxTest/MxTestA.acm~

ADD_MUSIC ~MxTest~ ~musictest/MxTest.mus~



The WeiDU command to add music adds the music name and the MUS file to the bottom of Songlist.2da, but what it fails to do is copy the necessary acm files. As the copy command cannot create the directory in the music folder, that has to be done first, then the copying.

This creates a working music into BG2, but to get it working in scripts takes more work.

Say we had a script called walkandsong.bcs that played our music and told our NPC to talk to the player the first time an NPC with the script attached saw the player. We would have something like:


IF
See(Player1)
GLOBAL(“firstmeet”,“LOCALS”,0)
THEN
RESPONSE #100
SETGLOBAL(“firstmeet”,“LOCALS”,1)
Playsong(777777)
Interact(Player1)
END



The 777777 bit is what we’re interested in – the music stuff. All songs have a number – eg, Viconia’s is 40, and in her script it says “Playsong(40). However, we don’t have that luxury - when WeiDU does an ADD_MUSIC, it assigns the song a number that hasn’t been taken yet. Therefore, each person who installs your mod may have a different number for your song. Rather than assume your will be, say, 84 (which could result in disaster), use a temporary number in your scripts. What you use isn’t important – it’s only temporary. What is important, is that you DO NOT use that number again in the same script (unless it’s your song again).

In your tp2 file, right after the ADD_MUSIC command, add


COPY ~musictest/walkandsong.bcs~ ~override/walkandsong.bcs~
REPLACE TEXTUALLY 777777 ~%MxTest%~



What this does is use the number that WeiDU assigned to your song, and replace all the occurances of “777777” in your script with that number. TA DA. All done.

If you want to work with more complicated MUS files, I suggest opening one up in context or notepad. They’re pretty self-explanatory, for instance BM1:

BM1
11
A @TAG ZA
B1 @TAG ZB
B2 @TAG ZB
C1 @TAG ZB
C2 @TAG ZB
D1 @TAG ZB
D2 @TAG ZB
E1 @TAG ZB
F1 @TAG ZB
G1 @TAG ZA
H1 B2 @TAG ZA
# B2 is loop (B1 could also work)
Earn Money Sleeping.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: