How to add sounds & MIDI

You might want to start with a clean Blood folder before you install these files!

In the Blood folder, create a project folder called MYSTUFF.
Open notepad and type the following:


resource "MYSTUFF\RAW\LAUGH.raw";
data "LAUGH.SFX" as 12000: 100, 0x10000, 0x0, 5, -1, "LAUGH";


On the first line a new resource is declared with the full path to the rawfile.
Don't forget to end the line with a semicolon!

On the second line the SFX properties are declared, here's what the numbers mean:

 
as 12000:
This is the sound number used in mapedit.
It's best to use 12000 and up for your own, but you can also replace existing sounds. Don't forget to type a colon behind the number!
 
100
Is the volume of the sound. 100 is sufficient when the waveform itself is already normalized (has maximum volume)
 
10000
Is the pitch at which the sound is played. (doesn't seem to do much)
Make sure '0x' preceeds it..
 
0x0
The '0' behind the '0x' is the amount of random pitch. (doesn't seem to do much)
 
5
The format:
1 = 8bit, mono, 11025hz
5 = 8bit, mono, 22050hz

Note: it seems that not all SOUND TYPES react properly to this setting.
 
-1

This number represents the start of the loop. '-1' means 'no loop',
any positive number is the position (in bytes) where the loop should start.
Once the sound comes to an end it starts playing from this point again.

Because of the loop, it seems as if there are 3 stages;
- 2 in the transition from one state to another (busyTime) where the beginning of the sample acts as the 1st and the loop as the 2nd.
- and when a State is reached, the 2nd sample being the 3rd stage.

 
"LAUGH";
The RAW name (max length = 9 chars)
Make sure the RAW name always equals that of the FILE name!
   

Save the file as SND.RFS in the MYSTUFF folder.

Inside the MYSTUFF folder, create 2 folders; RAW and MID.

Download MIDRAW and open the ZIP, put the LAUGH.RAW in
the RAW folder and the GRABBAG.MID in the MID folder.

Add another line to the SND.RFS so it looks like this


resource "MYSTUFF\RAW\LAUGH.raw";
data "LAUGH.SFX" as 12000: 100, 0x22050, 0x0, 5, -1, "LAUGH";

resource "MYSTUFF\MID\GRABBAG.MID";

 

And remember:
never forget the semicolon behind the quote!
Now save the file once again.

Next we need an install script, open Notepad and type


@ECHO OFF
CLS

COPY MYSTUFF\SND.RFS
COPY MYSTUFF\SNDTEST.INI
COPY MYSTUFF\SNDTEST.MAP

BARF SOUNDS.RFF @SND.RFS

BLOOD -INI SNDTEST.INI

DEL SND.RFS
DEL SNDTEST.INI
DEL SNDTEST.MAP
DEL SOUNDS.RFF

REN SOUNDS.BAK SOUNDS.RFF

 

Save it as SNDTEST.BAT in the BLOOD folder.

In order to make the MIDI file work, we also need an .INI file.
Open Notepad and type:


[EPISODE1]
TITLE = SOUND TEST
MAP1 = SNDTEST

[SNDTEST]
TITLE = SOUND TEST
AUTHOR = BME/ILMHB 2012
SONG = GRABBAG


Save it as SNDTEST.INI in the MYSTUFF folder.

Now we need a map, open Mapedit, create a room and then insert a sprite,
change its TYPE to 711: PLAYER SFX, its RX ID to 100 and its DATA1 field to 12000.

Then insert a button sprite Alt S and click on Misc, then select a button,
change its TX ID to 100, CMD to TOGGLE, Send When to X GOING ON and X GOING OFF
and 'Trigger On' to X PUSH.

Make sure the white arrow is inside the room and then press Scroll Lock
Save the map as SNDTEST, then exit Mapedit.

Finally, move SNDTEST.MAP to the MYSTUFF folder.
Now you're ready to run the map with SNDTEST.BAT

Download Adding New Sounds and MIDI to get a ready-made example


The parameters Volume, Pitch, Random and Loop don't have any effect in Mapedit,
so you have to run your map in Blood to properly test all parameters.
An easy way to test is to place a toggle switch on the map with DATA1 and DATA2 set.

It is also possible to make 2 sounds out of 1 resource. Let's say you want to have the same sound
as a loud and a soft one then you simply define the SFX line twice, like this


resource "MYSTUFF\RAW\LAUGH.raw";
data "LAUGH1.SFX" as 12000: 100, 0x10000, 0x0, 5, -1, "LAUGH";
data "LAUGH2.SFX" as 12001: 050, 0x10000, 0x0, 5, -1, "LAUGH";



Make sure the RAW name (at the end of the DATA lines) equals that of the RESOURCE name!

Try to experiment also with the the Pitch, Random, Format and Loop value of the 2nd sound.


If you want to create your own samples then take a look at creating sounds

For easy playback of RAW files you might want to use SCHISM TRACKER
it's also great for exporting sounds to other formats like WAV.


Back to PREVIOUS page

BACK TO MAIN PAGE