.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

The Star & the Crescent- Save $9.00
winSPWW2- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening > Scenarios, Maps and Mods

Reply
 
Thread Tools Display Modes
  #1  
Old October 29th, 2007, 12:27 PM

MischiefMaker MischiefMaker is offline
Private
 
Join Date: Jan 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
MischiefMaker is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old October 29th, 2007, 12:34 PM

Sombre Sombre is offline
BANNED USER
 
Join Date: Feb 2007
Posts: 5,463
Thanks: 165
Thanked 324 Times in 190 Posts
Sombre is on a distinguished road
Default Re: Does the new patch allow music modding?

Nope.
Reply With Quote
  #3  
Old October 30th, 2007, 08:30 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default 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.
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
  #4  
Old February 18th, 2008, 12:34 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default 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... 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 which was easier than expected with copy&paste from examples. Here's the straight-forward approach to playback the game audio files:

Code:
#! /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()


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:

Code:
#! /bin/env python

import sys, string
if len(sys.argv)!= 2:
print "Usage: "+sys.argv[0]+" <filename>"
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)


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:
Code:
$ mpg123 -v -y --stereo --rate 11025 -w kukkuger.pcm kukkuger.mp3
$ python2.5 convert.py kukkuger.pcm


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!
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
  #5  
Old February 18th, 2008, 01:38 AM
Saulot's Avatar

Saulot Saulot is offline
Sergeant
 
Join Date: Dec 2003
Location: New York City
Posts: 340
Thanks: 0
Thanked 3 Times in 3 Posts
Saulot is on a distinguished road
Default Re: Music modding solved

Simply incredible lch.

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
Reply With Quote
  #6  
Old February 18th, 2008, 06:16 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default 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.
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.
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:58 PM.


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