.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Scenarios, Maps and Mods (http://forum.shrapnelgames.com/forumdisplay.php?f=146)
-   -   Does the new patch allow music modding? (http://forum.shrapnelgames.com/showthread.php?t=36627)

MischiefMaker October 29th, 2007 12:27 PM

Does the new patch allow music modding?
 
Does the new patch allow music modding? It's not that I don't like the soundtrack, there just isn't enough of it.

Sombre October 29th, 2007 12:34 PM

Re: Does the new patch allow music modding?
 
Nope.

lch October 30th, 2007 08:30 AM

Re: Does the new patch allow music modding?
 
You can replace the music files (*.al in rawsound) with your own. They're A-law encoded raw data at 11025 Hz and 16 bits stereo. However, the game seems to render them a little differently than the programs I have tried (Adobe Audition and Steinberg WaveLab), which results in some distortion: If I play the game sounds with those programs, they sound a little dull, and if I replace the music with something that I saved myself then that has a high pitch with some distortion ingame. Either the game processes the sounds in some way or it uses the algorithms a little differently than the standard. Maybe it's some adaptive or differential format instead of PCM?

I agree that the music does get on your nerve if you play over a long period due to lack of variation (we need MORE music!) so I have turned it off except for battles.

lch February 18th, 2008 12:34 AM

Music modding solved
 
Somebody asked about this on another forum which made me curious to have a look at the problem again, wasted 3 hours of sleep on this... http://forum.shrapnelgames.com/image...ies/tongue.gif Dealing with the programming from the game before, I expected that it would probably be faithful to the specs - JK is pretty straight forward in this regard, and that all those programs that I used for a-law encoding were to blame for not really writing raw data.

Turns out that my hunch was right. Following a link from the Wikipedia article on A-law encoding (Finland is in Europe, and *.al is a suggestive filename) I had a look at the compression tutorial at http://hazelware.luggle.com/tutorial...mpression.html and then looked if somebody had already implemented something in that direction since I didn't want to write a C/C++ program from scratch. Then I found the audioop module in Python which has A-law since Python 2.5, so I only had to learn Python http://forum.shrapnelgames.com/images/smilies/wink.gif which was easier than expected with copy&paste from examples. Here's the straight-forward approach to playback the game audio files:

<font class="small">Code:</font><hr /><pre>#! /bin/env python
import audioop
alaw_data = open('/opt/dominions3/rawsound/draam13.al', 'r')
pcm = audioop.alaw2lin(alaw_data.read(), 2)

from ossaudiodev import open as ossOpen
dsp = ossOpen('/dev/dsp','w')
try:
from ossaudiodev import AFMT_S16_NE
except ImportError:
if byteorder == "little":
AFMT_S16_NE = ossaudiodev.AFMT_S16_LE
else:
AFMT_S16_NE = ossaudiodev.AFMT_S16_BE

dsp.setparameters(AFMT_S16_NE, 2, 11025)

dsp.write(pcm)
dsp.close()</pre><hr />
I'm not sure if the game audio files are mono at 22050 Hz or stereo at 11025 Hz, I guess it's the latter. The playback is pretty faithful to in-game.

If you convert your source material to raw PCM data, then you can use the following Python script to convert it to raw A-law data:

<font class="small">Code:</font><hr /><pre>#! /bin/env python

import sys, string
if len(sys.argv)!= 2:
print "Usage: "+sys.argv[0]+" &lt;filename&gt;"
sys.exit()
else:
inputfile = sys.argv[1]
name1 = str.split(inputfile, '.')
outputfile = string.join(name1[:len(name1)-1])+'.al'

import audioop
pcm_data = open(inputfile, 'r')
alaw_data = audioop.lin2alaw(pcm_data.read(), 2)

alaw = open(outputfile, 'w')
alaw.write(alaw_data)</pre><hr />
Now I looked for some demo input, MP3s on the net and found some Old Tatar Songs which are already at 11kHz. Converting them to *.al format:
<font class="small">Code:</font><hr /><pre>$ mpg123 -v -y --stereo --rate 11025 -w kukkuger.pcm kukkuger.mp3
$ python2.5 convert.py kukkuger.pcm</pre><hr />
Then copied it over /opt/dominions3/rawsound/draam13.al - sounds good!
Here's the demo file: http://www.mediafire.com/?9h2xnxprb1t

Somebody make a better Python program out of this, maybe with a nice GUI. I learned Python just 2 hours ago! http://forum.shrapnelgames.com/images/smilies/happy.gif

Saulot February 18th, 2008 01:38 AM

Re: Music modding solved
 
Simply incredible lch. http://forum.shrapnelgames.com/images/smilies/happy.gif

Not to undermine your efforts, but for me, it's ten times easier to just run some music in winamp in the background while the game is playing. ;p

lch February 18th, 2008 06:16 AM

Re: Music modding solved
 
That wouldn't be half as fun as it was for me to find out these things, though. I even learned something new from it. http://forum.shrapnelgames.com/images/smilies/happy.gif
It wasn't the problem that bugged me, it was the allure to find out how it is done. Plus, you can't fade in/out music when a battle starts with playback. Some people might even experience no in-game sounds if the playback is locking the audio device. But sure, this is just for the tech-heads. I remember that some games that I played, like car racing games, allowed you to insert an audio cd for playback in the background...

On an unrelented note, if you don't know how to convert your input to raw PCM, the file format detection tells me that it is "RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 11025 Hz", so converting into this might be as well.

Ballbarian February 18th, 2008 10:29 PM

Re: Music modding solved
 
Great job Ich!

By chance have you tried this format/technique with replacing the game's sample files (smp)?

Being able to change the sound or volume of things like elephants and Illithid's mind blast would be a major act of kindness to my ears. http://forum.shrapnelgames.com/images/smilies/happy.gif

lch February 18th, 2008 11:33 PM

Re: Music modding solved
 
Funny, Sombre asked exactly the same. Those aren't encoded at all. They're raw PCM data. The only thing that I don't know is their frame rate. sling.sw, the sound for the sling shots, is probably 11kHz stereo (or 22kHz mono), as is earth.smp, which I think is the sound that the earth elementals make when trampling. But howl.smp, for example, does have at most half that rate. growl.smp might be 6kHz mono or something, same for elefant.smp, the elephant sound.

So yes, I think I could normalize those sounds a bit. I'd have to look if the frame rate is saved in the game or in the files, which should be quite easy to do (just rename some). An easier fix is to just overwrite elefant.smp with muller.smp or earth.smp, which are easier on the ears.

Ballbarian February 21st, 2008 01:55 AM

Re: Music modding solved
 
1 Attachment(s)
Spent some time playing around with some utilities that I had on my system and managed to find a magic combination of settings &amp; hacks to capture &amp; replace sounds.

Attached is a quick alternative to "fear.smp". This is the sound used by mind blast and some other spells. In my current game using LA R'lyeh, my hordes of Illithids have been piercing my ears all week so I am now using this alternative sound.

Oh, and just in case:
BE SURE TO BACK UP YOUR OLD AUDIO FILE BEFORE REPLACING IT WITH THIS ONE!

Foodstamp February 21st, 2008 01:58 AM

Re: Music modding solved
 
Yeah right. I KNOW you have replaced it with the "OMG that Elephant just saw a mouse" sound. Nice try.

Ballbarian February 21st, 2008 02:02 AM

Re: Music modding solved
 
???

Foodstamp February 21st, 2008 02:04 AM

Re: Music modding solved
 
The annoying elephant attack sound.

P.S. did you have to put 900 xp in all your gan files?

Ballbarian February 21st, 2008 02:13 AM

Re: Music modding solved
 
lol http://forum.shrapnelgames.com/images/smilies/happy.gif
No, it is for real. I used a smaller, shorter &amp; less obtrusive sound from Age of Wonders: Shadow Magic. If I remember right, the original was named "i_vertigo" or something like that.

Remember to uncheck the "Fiddle XP" box (in RanDom v2.03) before randomizing your map. You should only have to do this once and the program will remember your settings. This will solve your xp problems. http://forum.shrapnelgames.com/images/smilies/wink.gif

Foodstamp February 21st, 2008 02:16 AM

Re: Music modding solved
 
Good stuff http://forum.shrapnelgames.com/images/smilies/happy.gif. Now if you really wanted to do something with the elephant sound, I would not be opposed http://forum.shrapnelgames.com/images/smilies/wink.gif. I believe the Nomads in Shadow Magic have an elephant unit that may work.

Ballbarian February 21st, 2008 03:11 AM

Re: Music modding solved
 
1 Attachment(s)
Ask and ye shall receive.
New "elefant.smp" attached. http://forum.shrapnelgames.com/images/smilies/happy.gif

lch February 21st, 2008 07:09 AM

Re: Music modding solved
 
I found an old post from Dominions 2 times where JK even wrote about the sounds... http://forum.shrapnelgames.com/images/smilies/happy.gif
I think the only difference is that now most, if not all, of these files are at 6kHz instead of 22kHz, mono. The *.al files seem to be mono, to, thus at 22kHz. Does this coincide with what you found out, Ballbarian?

Sombre wanted the f_death.smp replaced with something else, too. If you manage to find a less shrieking death cry...

Ballbarian February 21st, 2008 09:52 AM

Re: Music modding solved
 
So far I have found 6kHz &amp; 11.025kHz, but the program that I am using seems to barf when I try to save the new sound at 6kHz. The original elephant sound was 6kHz, but I saved it as 11.025kHz (mono) and it sounds fine in game.

Would f_death be the shriek of the lovely ladies when the perish? That one is already high on my list of irritating sounds. http://forum.shrapnelgames.com/images/smilies/happy.gif It will likely be tonight before I can get to it.

lch February 21st, 2008 10:16 AM

Re: Music modding solved
 
Yeah. My advice was to replace elefant.smp with emuller.smp and f_death.smp with f_death2.smp. Another sound that people complain about is the sling.sw from the slingshot.

Endoperez February 21st, 2008 11:54 AM

Re: Music modding solved
 
Quote:

lch said:
Yeah. My advice was to replace elefant.smp with emuller.smp and f_death.smp with f_death2.smp. Another sound that people complain about is the sling.sw from the slingshot.

:angry: Slingshot isn't sling! :angry:


Other than that, this is great. A compiled original/new sounds should be uploaded somewhere, and a link put into some sticky thread for all to enjoy.

Agrajag February 21st, 2008 12:10 PM

Re: Music modding solved
 
Quote:

Ballbarian said:
The program that I am using seems to barf when I try to save the new sound at 6kHz.

My program crashed as well trying to save some of the files (I converted all of the musics to .ogg so I can listen to them while playing Dominions without enabling sound http://forum.shrapnelgames.com/image...ies/tongue.gif).
It turned out that the first ~0.3s of each song, and the silent parts at the end of some songs, contain information that causes the program to crash when trying to reencode it. The solution was merely to delete those bits at the start and then save. (The bits in the end weren't really a problem, since the program crashed but still produced a usable file before doing so.)

Hopefully this is not some sort of primitive protection method that I'm being bad by helping break :S

lch February 21st, 2008 12:12 PM

Re: Music modding solved
 
Quote:

Endoperez said:
:angry: Slingshot isn't sling! :angry:

Yuh-uh, it is.

Endoperez February 21st, 2008 01:03 PM

Re: Music modding solved
 
Quote:

lch said:
Yuh-uh, it is.

Slingshot is a modern toy made from rubber, and can be used to hunt small game (small rodents and birds at ranges up to 25 metres according to wikipedia). "A typical heavy pull band slingshot should be used with 9mm (3/8") to 12mm (1/2") steel balls."

Sling is an ancient weapon, more accurate and able to fire farther than the bows Persians used against the Greek. I don't know whether the Greek used leaden of stone ammo against the Persian archers. Bow technology evolved until bows had completely replaced slings as weapons of war, excluding the use of the same mechanism in staff-slings and in siege engines such as trebutchet, in the Middle Ages. "Almond shaped leaden sling-bullets were typically about 35 mm (1 3/8 in) long and about 20 mm (3/4 in) wide."

Also, I can hit a small tree with a slingshot, if I'm close enough. I can hit a barn with a sling, but if I'm not far enough the stone will ricochet and hit me in the head.

lch February 21st, 2008 01:09 PM

Slingshots != Slings, OH NOES
 
Aaach, pfft, you were talking about the nomenclature. I thought you were talking about the file names.

Ballbarian February 21st, 2008 04:01 PM

Re: Slingshots != Slings, OH NOES
 
1 Attachment(s)
New f_death.sw attached.
I have not been able to test this in game yet. Let me know if it works (or does not work). I will check it when I get back home tonight.

Edit:
Tested and it required a rework. The new sound file has replaced the old.

Ballbarian February 22nd, 2008 01:42 AM

Re: Slingshots != Slings, OH NOES
 
1 Attachment(s)
Alternative sound for the sling attached.
Rather than hijack this thread any longer than I already have, I will create a new topic for any future additions or changes.

I must say that all of the different formats are making this much harder than it should be... (*grumble*) http://forum.shrapnelgames.com/image...ies/tongue.gif

Foodstamp February 22nd, 2008 02:55 AM

Re: Slingshots != Slings, OH NOES
 
I am going to give these alternate sounds a go tomorrow. I do have one more request if it is not too much trouble. The attack sound for the Wyrm is pretty annoying, is there anyway you could replace that as well? http://forum.shrapnelgames.com/images/smilies/happy.gif


All times are GMT -4. The time now is 09:13 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.