Please help - cant play new sample sounds from cat file

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Please help - cant play new sample sounds from cat file

Post by keys »

Hi, I am trying to write my first script.
Its to add radio chatter (similar to orbiter) using the following:

play sample xxxx

I've created the script, and only run it manually from the script editor. Thats OK and it works if I replace the file number with something that is already in catalog 03 - say 'play sample 901' works and I get the sample played back.

Now when I add a new sample sound (e.g. 2000.wav from orbiter) to the 03.cat 's' folder with the mod manager - I can see it in 03.cat, I can extract it and play it in media player, but when I select it in the play sample command I only get silence.

I have checked all the other catalogs for samples and made sure I am using a unique number. I've tried creating a new catalog - 20.cat ( I have the xtd mod and that was the last cat at 11.cat) and can add samples to 20.cat, but again they will not play.

Am I doing something wrong? Please help - I really miss atc radio chatter!

Many thanks.
Keys.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

a few things to note. I wouldn't edit or change, or add anything to the existingfiles, ie 03.cat

also, if your last mod is at 11.cat, then naming it 20.cat will not work, it has to be in sequence, so it'll have to be 12.cat

but, for sounds, its far easier to put it in the S directory rather than using the mod manager to put it into a cat file.

there is also a file you need to edit, the sounds.pck/txt file.
It lists all the samples that it can use.

and one last thing, the sound format for samples in X3 is very fussy, simply putting a wav file to play will not work. You have to make sure it matches exactly with the format otherwise it wont work.

there was a post in the tutorials section, either in x2 or x3, i cant remember, but it describes the process of making the sound files into the correct format
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

Thanks for your reply Cycrow - fast too!
The reason I put the sample into 03.cat was because I dont have an 'S' folder in my X3 Reunion folder - I only have maps, MOV, mods, t etc. - no 's' .

Should I just create an s folder and put my wav's in there?
Do you know where I can find out what format the samples have to be in?

Anyway, I'll follow what you suggest and see how it goes. I couldnt find the tuturial you mention - if anyone else knows where to find it please?
Thanks again.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

yeah just create the directory and put it in there.

as for the format, there was an old post about it somewhere, i cant remember where thou, it should be on the forum, possibly linked from one of the stickies.

the format is the same for both X3 and X2
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

Thanks, I'm searching for the format now. I'll let you know how I get on!
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

UPDATE:
Well I've created an s folder and put my sound file inside as 1014.wav
I've unpacked sounds.txt from 11.cat (xtd mod) into the types folder and found the line for sound 1014 as this...
250;155;NULL;0;0;0;0; // 1014 (unused)

In my script I have play sample 1014
and it does play - but VERY quietly. (Its loud in media player).
I tried sample 901 (built in missile explosion) and it plays LOUD so my script is definately playing the right sample. I noted the sound 901 has a different set of flags in sounds.txt, so I've copied it as follows into the 1014 line in sounds.txt...

250;512;NULL;-20;20;0;200000; // 1014 (unused)

But sound 1014 still plays very quietly.
Do I have to do anything else please?
Do you think this is a format issue? It does play fine, but not loud enough.
Thanks for your help,
Keys.

EDIT:: Ive just found the tutorial that Cycrow suggested - FYI its here..
http://forum.egosoft.com/viewtopic.php?t=106264

It works a treat! Basically, it appears I'm able to include ANY wav file WITHOUT copy/paste onto an existing one from the catalog as suggested in the tutorial (so format must be ok then), the main thing that made it all work at the right level was to create a separate mod and have the s folder with my wavs and a types folder with my modified sounds.pck. Having the wav in an s folder and the sounds.txt in the types folder didnt work (maybe because the other catalogs are not expanded?).

Now I just need to get the sript working for wavs at random times when I'm in cockpit mode!

continues...
User avatar
Elffin
Posts: 371
Joined: Wed, 18. May 05, 22:34
x3tc

Post by Elffin »

Really like your idea. BTRL (Batllestar Galactica mod for freepspace) use a lot of chat/comms to create atmosphere (whether its random I dont know?).

I would really be interested to see how your modding idea develops - could be useful in the future XTM BSG mod
Laureati
Posts: 140
Joined: Sat, 20. May 06, 11:42
x3tc

Post by Laureati »

X3 is kind of sensitive to the .wav format but not so much that anyone who's done wave file editting before can't handle. Basically any .wav that has a sample rate of 22kHz/44kHz, 8-bit/16-bit, mono will do. I've made sounds from scratch before. What's most important is "adding" the sound to the sounds.pck. This can be done by replacing an (unused) sound, overwriting an unwantd one, or adding a new one.

I'd becareful about replacing "unused" sounds as some modders/scripters do use some of these sounds. Some unused sounds don't mean a sound doesn't exist. It just means that it's not used in vanilla X3.

(1014 looks okay though as it doesn't even exist as a .wav, so only a mod would have it, if at all.]

There's a list of custom sound slots. This is in pool 800, between the ambient sound lists and ship sounds lists (900+) it's best to insert new sounds there.

Becareful of the values you set for your sounds. Details of what each value means is shown at the top of the sounds.pck. Judging from the last set of values you listed for your 1014 sound ... you're going to get a little surprise once you start doing whatever it is you plan to do with your radio chatter.

Added Note: - The Sounds.pck file is EXTREMELY sensitive. It must be perfectly formatted or it won't work, at all.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

i do plan to adda feature in the Plugin Manager to be able to add new sounds into the game.

Elffin, the most likly reason it didn't work when you had sounds in the types folder, is because another file of the same name would take priority and override it. IT should be fine having the wav file in the s directory thou, as long as you load the sounds file in the latest fake patch or in the selected mod
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

HI, thanks for the feedback - its much appreciated! Noted the remark regarding the sound modifiers - understand that now :wink:

Anyway, I've just got the basic script working - I can play 1 of 100 sample atc sounds randomly - I used a new sound pool 300-399. I've got them packed into a new catalog along with a new sounds.pck. Mine is the highest number catalog (12).

All works fine and I get what is expected and it really does increase the immersion for me at least!

Next, I will have a look at having radio chatter played back only when I'm in 'flying' mode - i.e. not docked - Thats proving more challenging as I need to find the reference material which identifies game variable/constant meanings - i.e. how do I test to see if I'm flying or docked?

Am thinking of adding certain type of chatter at the right times - engaging enemies, approaching stations etc. but I really need to understand how I test for these conditions. :(

Thanks, Keys.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22437
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

Code: Select all

if [PLAYERSHIP] -> is docked
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

Hey thanks Cycrow!
So thats what is meant by 'general object commands'
Perfect! :D

Works beautifully. Now I'm really getting the bit between my teeth :) I do have to be careful with my while...end statements tho' looks like you always need to put a 'wait x ms' in to relinquish the cpu...
Laureati
Posts: 140
Joined: Sat, 20. May 06, 11:42
x3tc

Post by Laureati »

Sounds like you got the sounds down, keys. Nice. Just be sure you set your distance to '0'. Since you want to sounds to only play on the playership, would be useless having the CPU number crunch sound propogation for the 200m shown in your 1014 example. heh.
250;512;NULL;-20;20;0;200000; // 1014 (unused)


It's also missing a variable... but I think you know that by now.

:)
Laureati
Posts: 140
Joined: Sat, 20. May 06, 11:42
x3tc

Post by Laureati »

Thought I should update this with some information I learnt adding yet more sounds into my game.

Sample format:

2 different sample formats are compatible with the game, in different circumstances.

Launch laser sounds: i.e. any sound originating from a 'gun'.
These sounds can be 22kHz at 16 bit mono.

3D or SFX sounds:
These are any sounds to do with the environment or effects. From my limited experience and troubleshooting it seems these sounds MUST be in 44.1kHz 16-bit mono format. I suspect it's got something to do with EAX.

To sum up, though you may have a sound sample that works in some circumstances, it may not work in others. To be safe, it's best to work with 44.1kHz 16-bit mono sounds.
keys
Posts: 50
Joined: Tue, 9. Aug 05, 09:52
x3

Post by keys »

Thanks, I've just had a look a some of the samples I am using for radio chatter (played by play sample xxx and they include 8bit mono @ 11Khz sample rate, 16bit mono @8Khz, 16bit mono 48Khz. All play fine as sound effects in this script.
Keys.

Return to “X³: Reunion - Scripts and Modding”