INTRODUCTION
So, let's say you're midway through making your map and you want your own epic soundtrack to play, or you want music from the original
Half-Life. This tutorial will show you how to make music play during your map.
PREPARING THE MUSIC FOR PLAYBACK
You can skip this step if you're not using your own music.First, you need to prepare the music. There's nothing much you have to do like adding cue points, etc. because music playback uses the Miles Sound System and not GoldSource's one. You need to have an MP3 with a sample rate of 44100Hz. Next, you need to set its file name. GoldSource only supports certain filenames for your MP3 files. If you set the filename to gamestartup.mp3, the track will play in a loop on the main menu when the game starts. You need to use one of these 28 filenames:
- Half-Life01.mp3
- Half-Life02.mp3
- Half-Life03.mp3
- Half-Life04.mp3
- Half-Life05.mp3
- Half-Life06.mp3
- Half-Life07.mp3
- Half-Life08.mp3
- Half-Life09.mp3
- Half-Life10.mp3
- Half-Life11.mp3
- Half-Life12.mp3
- Half-Life13.mp3
- Half-Life14.mp3
- Half-Life15.mp3
- Half-Life16.mp3
- Half-Life17.mp3
- Prospero01.mp3
- Prospero02.mp3
- Prospero03.mp3
- Prospero04.mp3
- Prospero05.mp3
- Suspense01.mp3
- Suspense02.mp3
- Suspense03.mp3
- Suspense05.mp3
- Suspense07.mp3
You can apply any metadata, including album artwork and composer info to your MP3s. It won't effect in-game playback.
Once you have prepared your music for playback, we will now make it play in-game.
MAKING THE MUSIC PLAY
In your map, there are two ways to make music play. You can use the brush entity
trigger_cdaudio to make the music play when the player walks through it, or you can use the
target_cdaudio point entity to make the music play when it is triggered. Both entities have the exact same properties. If you're using
target_cdaudio, you will need to add something in the
targetname/Name key. In the
Track to play key, there are tracks 1-30, though you can only really use tracks 2-28.
Value | Mp3 file to play |
---|
1 | None |
2 | Half-Life01.mp3 |
3 | Prospero01.mp3 |
4 | Half-Life12.mp3 |
5 | Half-Life07.mp3 |
6 | Half-Life10.mp3 |
7 | Suspense01.mp3 |
8 | Suspense03.mp3 |
9 | Half-Life09.mp3 |
10 | Half-Life02.mp3 |
11 | Half-Life13.mp3 |
12 | Half-Life04.mp3 |
13 | Half-Life15.mp3 |
14 | Half-Life14.mp3 |
15 | Half-Life16.mp3 |
16 | Suspense02.mp3 |
17 | Half-Life03.mp3 |
18 | Half-Life08.mp3 |
19 | Prospero02.mp3 |
20 | Half-Life05.mp3 |
21 | Prospero04.mp3 |
22 | Half-Life11.mp3 |
23 | Half-Life06.mp3 |
24 | Prospero03.mp3 |
25 | Half-Life17.mp3 |
26 | Prospero05.mp3 |
27 | Suspense05.mp3 |
28 | Suspense07.mp3 |
Once you've set up the entity correctly corresponding to your MP3, you can compile your map. If the MP3 files aren't in your mod folder, the game will play the files from the
valve folder.