forked from boriswinner/raycaster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
usound.pas
49 lines (42 loc) · 975 Bytes
/
usound.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
unit usound;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, SquallSound;
const
LevelPrefix = 'level_';
var
SoundSystem: TSoundSystem;
SoundManager: TSoundManager;
SLevelSound: TSound;
SoundPath: String;
procedure PlayLevelMusic(LevelNumber: UInt32);
procedure StopLevelMusic;
procedure FinishSoundModule;
implementation
procedure PlayLevelMusic(LevelNumber: UInt32);
begin
SLevelSound := SoundSystem.AddSound(SoundPath + LevelPrefix +
IntToStr(LevelNumber) + '.ogg',st2D, 1);
SLevelSound.Volume:=100;
SLevelSound.Play(true);
end;
procedure StopLevelMusic;
begin
if SLevelSound <> nil then
SLevelSound.Stop;
end;
procedure FinishSoundModule;
begin
StopLevelMusic;
if SLevelSound <> nil then
SLevelSound.Destroy;
SoundManager.Destroy;
SoundSystem.Stop;
SoundSystem.Destroy;
end;
initialization
SoundSystem := TSoundSystem.Create;
SoundManager := TSoundManager.Create(SoundSystem);
SoundPath:= './res/sounds/';
end.