SNC Creator

V1.0

By Jobby

What is the SNC Creator ?

The SNC Creator is a little program that allows you to build a SNC file from a simple script written under any ascii text editor, like notepad. The SNC format being a bit complicated (see the SNC tutorial), this should ease the creation of the most complex scripts.

The SNC creator can be downloaded from SBF.

Some parts of this help file are taken from the SNC tutorial, since both are linked.

 

What is a SNC file ?

If you want to create your own FM or entire game, and add your own musics, the use of the SNC files represents a necessary step. The Thief Editors could certainly use them too, but they all prefer ambiant samples…

Each level of SS2 refers to one (and ONE ONLY !) SNC file. This file tells the Dark Engine in which order to play the WAVs included in the SND.CRF zip file. SNC files are in fact little scripts with loops, tests, jumps, and declarations of all the WAVs to use.

These scripts allow the music to start/stop according to triggers set inside the level that uses the song.

 

Where are the SNC files ?

They’re all gathered in the SONG.CRF zip file.

NOTE : ALWAYS put you SNC files inside SONG.CRF, and nowhere else. Do not use any space in your own SNC filenames.

 

Interactions between Dark Engine and the SNC files (Music Markers)

As I said, each level of SS2 refers to one SNC file. You can edit the name of the SNC file used in a level, through the ‘Editors’ menu of Dromed -> ‘Mission Parameters’ -> ‘Song parameters’. One little box will show you the file to load. Do not write the .SNC extension in this box.

Very important, the SNC files react to markers set inside the levels. Those markers are called Music Markers (-1444), and each possesses three values set by the level editor (or you). One of them indicates the ‘mood’ of the atmosphere, or a more ‘serious’ indication. ‘begin’, ‘quiet’, ‘end’ are the most used in SS2, but nothing prevents you from using : ‘scary’, ‘cold’, or references to the places where the player will encounter the markers : ‘reactor’, ‘freezer’, ‘storage’…

NOTE : don’t use any space in the Music Markers value. 8 characters max. Use only lower characters (Perhaps those limitations are useless, but I assure that no bug will occur in these conditions).

You can find Music Markers in every level, generally near important areas, and near beginnings/ends of a level (needless to say : like all markers, Music Markers are invisible). Edit the ones in SS2, or create a new one through ‘Editors’ -> ‘Object hierarchy’ -> ‘Marker’ -> ‘Music Theme’. The property that interests us is the ‘AmbientHacked’. If you’ve created your own Marker, then you must add this property : ‘Add’ -> ‘A’ -> ‘AmbientHacked’. Edit it. Only three things interest us : the Radius, the Flags, and the Schema Name.

The Radius defines the area the Marker covers. I generally set it to 4, but if you have a Marker in the middle of a huge corridor, you can increase this value to be sure the player will meet it.

Since the AmbientHacked is used for a lot of others things, only ‘Music’ must be ticked inside the Flag property.

The Schema Name is most useful. It will indicate the Dark Engine what ‘mood’ to send to the SNC file script. You can write ‘begin’, ‘end’, or whatever, as I said before. Just know how you want to organise the music according to your vision of the level. Don’t hesitate to look at the SS2 levels, they’re ‘full of wonderful ideas…’.

NOTE : Remember the Schema Names you used, they’ll be used inside the SNC files (the name you gave to your Music Markers are for you convenience only).

Very important : The Marker Flag. Well, it’s the name I gave to the internal flag the Dark Engine uses to save the value of the last Music Marker encountered by the player. When the player enters a level, the Flag is set to Null (I guess). When he touches one of your Music Marker, the Flag takes the value (begin, end, quiet, gloomy...) of the Schema Name Property set inside. There is only one Marker Flag ! And it only changes when the player encounters another Music Marker !

 

What can do the SNC Format ? How advanced is it ?

The SNC format is quite effective, and its limitations only come for the Dark Engine that can only send it info through the Music Markers.

Every Schema Name a SNC file receives can trigger a part of the song in consequence. The scripts list the names of the samples to play, but between each are tests : which sample to play now ? Should it be looped a certain number of time ? Did the player encounter another Marker ?

You can also create some random tests : this sample has 50% of chance to be played, this one 25%, and this one 25%… Nice feature, the game often uses it.

 

 

Building you first script

Create a new file under notepad. Our first script will be based on the REC1 song, whose SNC file is song07.snc, and samples are '07beg.wav', '07quiet.wav', '07lo.wav', and '07end.wav'.

Another sample is ALWAYS used in EVERY song : empty.wav. As its name can tell, there's nothing to hear in this sample, but it's used when no song is played in the game. Yeah, when you don't hear any music, this sample is in fact playing in loop...

Note : all the samples are inside the 'songs' folder of the SND.CRF zip file.

Samples declarations :

The first thing to is to declare the samples we're going to use. This is done like this :

 

<samples>

0 empty.wav

1 07beg.wav

2 07quiet.wav

3 07lo.wav

4 07end.wav

 

WARNING :

 

The main script :

Now, the real things are beginning. We must take each sample we listed above and give them one script each. Let me give you a nice script. This must be typed just after the lines above :

 

<main>

   
     
 

sample 0

'sample 0 is empty.wav

 

if begin

'If the player finds the 'begin' marker

 

jump 1

'Then goto sample 1

     

else

'else, jump to sample 0

 

jump 0

'(which is empty.wav again)

     
     
 

sample 1

'sample 1 is 07beg.wav

 

if end

'if the player finds the 'end' marker

 

jump 4

'then goto sample 4

     
 

if creepy

'if the player finds the 'creepy' marker

 

jump 2

'then goto sample 2

     

else

'else

 

jump 1

'goto sample 1

     
     
 

sample 2 *2

'sample 2 is 07quiet.wav

   

'it's played twice

 

if end

'if the player finds the 'end' marker

 

jump 4

'then goto sample 4

     

if terrific

'if the player finds the 'end' marker

jump 3

'then goto sample 3

     
 

else

 
 

jump 1

;else return to sample 1

     
     
 

sample 3

'sample 3 is 07lo.wav

 

if end

'if the player finds the 'end' marker

jump 4

'then goto sample 4

     
 

if creepy

'if the player finds the 'creepy' marker

 

jump 2

'then goto sample 2

     
 

else

 
 

jump 3

;else play sample 3 in loop !

     
     
 

sample 4

;sample 4 is 07end.wav

 

jump 0

;return to empty.wav

     

<end>

   

 

I think it's pretty simple, no ?

When the player enters the level, the first sample (empty.wav) is played in loop, so nothing can be heard. But when he encounters the 'begin' Marker, then the music begins with the sample 1 (07beg.wav) !

This sample is played in loop, unless Google finds a 'end' or a 'creepy' marker.

Have a look at the fifth sample (07end.wav). Just after it's played, the script jumps to 'empty.wav', so no more music is heard. Our 'end' simulation is well rendered.

Also, look at the third sample (07quiet.wav). The '*2' means that the sample is played twice.

Notice that the 'else' must only be used if at least one 'if' is used. In the case of 'sample 4', there's no 'else' because no 'if' has been used.

The <end> marks... the end of the script. Do not forget it ! Nothing written after is read.

NOTE ABOUT SAMPLES : When a sample is played, the script isn't read anymore. So, if the player encounters 5 Music Markers during one sample, only the last marker will be tested ! If your WAVs are 2 minutes long (like some SS2's wavs are), nothing can happen during these 2 minutes. Conclusion : the shorter your samples are, the more 'dynamic' your script gets. Very important too, NOTHING can break the loop of a sample. When the Dark Engine has finished playing the first iteration, it begins the second one immediately after.

Let's see now the last thing to know:

The Random Jumps :

These one are very simple to write and quite powerful. The principle is as follows : instead of using normal jumps, we will use a random value to chose where we're going to jump. Here's a little (and incomplete) script to show you how it works :

...

   

sample 2

   
 

if end

'if the player finds the 'end' marker

 

10% 1

'10% of chance to go to the sample 1

 

50% 3

'50% to the sample 3

 

40% 2

'40% to the sample 2

     
 

if terrific

 
 

jump 3

 
     
 

else

 
 

50% 1

 
 

50% 3

 
     

sample 3

   
 

20% 1

 
 

40% 2

 
 

20% 3

 
 

20% 4

 
     

sample 4

   
 

...

 

Understood ? You can replace any normal jump with these. Just make sure that the sum of your probabilities equals 100%, which would be logical. Not doing it shouldn't crash the Engine, but could provoke strange behaviours.

 

NOTES :

 

 

Running your script :

Well, when your script is finished, just type :

SNCreate yourscript.txt theSNCfiletocreate.SNC

... and I pray for it to work !

 

 

The End

Ok, now it's over ! This program is very sensitive to the structure, so be careful. The creation of the SNC file should take one or two seconds max, so if it's been working for more than that, your script has something wrong (...and my code too !) !

And as I am in a good mood today, you should find somewhere with this document a zipped file with the scripts of four SS2 songs ! I hope it will be useful to you.

If you've got any remark, suggestion, bug report, if your script doesn't work and you don't know why, just send it to me, I'll find where the bug is.

That’s all for today !

Jobby.