Tutorial: Making Music Play in Maps Last edited 9 months ago2023-06-20 15:43:20 UTC

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

Note
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 GoldSrc's one. You need to have an MP3 with a sample rate of 44100 Hz. Your MP3 file needs to be in the media folder of your game. Next, you need to set its file name. GoldSrc 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 27 filenames: You can apply any metadata, including album artwork and composer info to your MP3s. It won't affect 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 Name (targetname) key. In the Track to play (health) key, there are tracks 1-30, though you can only really use tracks 2-28. Track 29 is hardcoded to automatically play upon launching the game.
Value Track (or action)
-1 Stop
1 None (data track)
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
29 Gamestartup.mp3
30 None (only available via Red Book CD audio)
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.

Comments

You must log in to post a comment. You can login or register a new account.