summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 043af90)
raw | patch | inline | side by side (parent: 043af90)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 1 May 2019 17:07:15 +0000 (20:07 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 1 May 2019 17:07:15 +0000 (20:07 +0300) |
src/engine/e_sound_fmod.inc | patch | blob | history | |
src/engine/e_sound_sdl.inc | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_sound.pas | patch | blob | history |
index d0db4fed1fa09f7332b8b70cd4dd798127d8bbff..36d4932387d1f73e120a12368b460dc9079aba10 100644 (file)
function e_InitSoundSystem(NoOutput: Boolean = False): Boolean;
-function e_LoadSound(FileName: string; var ID: DWORD; bLoop: Boolean): Boolean;
-function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; bLoop: Boolean): Boolean;
+function e_LoadSound(FileName: string; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
+function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
function e_PlaySound(ID: DWORD): Integer;
function e_PlaySoundPan(ID: DWORD; Pan: Single): Integer;
end;
end;
-function e_LoadSound(FileName: String; var ID: DWORD; bLoop: Boolean): Boolean;
+function e_LoadSound(FileName: String; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
var
find_id: DWORD;
res: FMOD_RESULT;
find_id := FindESound();
- if bLoop then
+ if isMusic and not ForceNoLoop then
bt := FMOD_LOOP_NORMAL
else
bt := FMOD_LOOP_OFF;
- if not bLoop then
+ if not isMusic then
res := FMOD_System_CreateSound(F_System, PAnsiChar(FileName),
bt + FMOD_2D + FMOD_HARDWARE,
nil, e_SoundsArray[find_id].Sound)
end;
e_SoundsArray[find_id].Data := nil;
- e_SoundsArray[find_id].isMusic := bLoop;
+ e_SoundsArray[find_id].isMusic := isMusic;
e_SoundsArray[find_id].nRefs := 0;
ID := find_id;
Result := True;
end;
-function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; bLoop: Boolean): Boolean;
+function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
var
find_id: DWORD;
res: FMOD_RESULT;
soundExInfo.cbsize := sz;
soundExInfo.length := Length;
- if bLoop then
+ if isMusic and not ForceNoLoop then
bt := FMOD_LOOP_NORMAL
else
bt := FMOD_LOOP_OFF;
- if not bLoop then
+ if not isMusic then
res := FMOD_System_CreateSound(F_System, pData,
bt + FMOD_2D + FMOD_HARDWARE + FMOD_OPENMEMORY,
@soundExInfo, e_SoundsArray[find_id].Sound)
end;
e_SoundsArray[find_id].Data := pData;
- e_SoundsArray[find_id].isMusic := bLoop;
+ e_SoundsArray[find_id].isMusic := isMusic;
e_SoundsArray[find_id].nRefs := 0;
ID := find_id;
index ade82620b1dd0bec1c121a52b7e43ed28b787428..eb42c8bfea70d0374e304fe7546847db33d60b49 100644 (file)
Sound: PMix_Chunk;
Music: PMix_Music;
isMusic: Boolean;
+ Loops: Boolean;
nRefs: Integer;
end;
function e_InitSoundSystem(NoOutput: Boolean = False): Boolean;
-function e_LoadSound(FileName: string; var ID: DWORD; isMusic: Boolean): Boolean;
-function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean): Boolean;
+function e_LoadSound(FileName: string; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
+function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
// returns channel number or -1
function e_PlaySound(ID: DWORD): Integer;
end;
end;
-function e_LoadSound(FileName: String; var ID: DWORD; isMusic: Boolean): Boolean;
+function e_LoadSound(FileName: String; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
var
find_id: DWORD;
begin
e_SoundsArray[find_id].Data := nil;
e_SoundsArray[find_id].isMusic := isMusic;
+ e_SoundsArray[find_id].Loops := isMusic and not ForceNoLoop;
e_SoundsArray[find_id].nRefs := 0;
if isMusic then
Result := True;
end;
-function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean): Boolean;
+function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
var
find_id: DWORD;
rw: PSDL_RWops;
e_SoundsArray[find_id].Data := pData;
if isid3 then e_SoundsArray[find_id].Data := nil;
e_SoundsArray[find_id].isMusic := isMusic;
+ e_SoundsArray[find_id].Loops := isMusic and not ForceNoLoop;
e_SoundsArray[find_id].nRefs := 0;
if isMusic then
function e_PlaySound (ID: DWORD): Integer;
var
res: Integer = -1;
+ loops: Integer = 0;
begin
Result := -1;
if not SoundInitialized then Exit;
begin
if e_SoundsArray[ID].nRefs >= gMaxSimSounds then Exit;
Inc(e_SoundsArray[ID].nRefs);
- res := Mix_PlayChannel(-1, e_SoundsArray[ID].Sound, 0);
+ if e_SoundsArray[ID].Loops then loops := -1;
+ res := Mix_PlayChannel(-1, e_SoundsArray[ID].Sound, loops);
if res >= 0 then
begin
ChanSIds[res].id := ID;
begin
if not e_isMusic(ID) then Exit;
Mix_HaltMusic();
- res := Mix_PlayMusic(e_SoundsArray[ID].Music, -1);
+ if e_SoundsArray[ID].Loops then loops := -1;
+ res := Mix_PlayMusic(e_SoundsArray[ID].Music, loops);
if res >= 0 then res := N_MUSCHAN;
if SoundMuted then Mix_VolumeMusic(0) else Mix_VolumeMusic(MusVolume);
Result := res;
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index d8aab5c9eb7b30a89f8152d38561c733f9d54b8b..081d97e892b2af312e668557e532308f8cbfed02 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
g_Game_SetLoadingText(_lc[I_LOAD_MUSIC], 0, False);
g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD+':MUSIC\INTERMUS', True);
g_Sound_CreateWADEx('MUSIC_MENU', GameWAD+':MUSIC\MENU', True);
- g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True);
+ g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True, True);
g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD+':MUSIC\ENDMUS', True);
g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False);
diff --git a/src/game/g_sound.pas b/src/game/g_sound.pas
index ad514c197fdea6e31142abb975bf88d571a4ef54..094df0f80756b710312f6c19dfdb4b1aec05e99c 100644 (file)
--- a/src/game/g_sound.pas
+++ b/src/game/g_sound.pas
function g_Sound_PlayExAt(SoundName: ShortString; X, Y: Integer): Boolean;
function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
-function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
function g_Sound_CreateFile(var ID: DWORD; FileName: string; isMusic: Boolean = False): Boolean;
-function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
procedure g_Sound_Delete(SoundName: ShortString);
function g_Sound_Exists(SoundName: string): Boolean;
Result := e_LoadSound(FileName, ID, isMusic);
end;
-function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateFileEx(SoundName: ShortString; FileName: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
var
find_id: DWORD;
begin
find_id := FindSound();
- if not e_LoadSound(FileName, SoundArray[find_id].ID, isMusic) then
+ if not e_LoadSound(FileName, SoundArray[find_id].ID, isMusic, ForceNoLoop) then
Exit;
SoundArray[find_id].Name := SoundName;
Result := True;
end;
-function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
+function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False; ForceNoLoop: Boolean = False): Boolean;
var
WAD: TWADFile;
FileName: string;
if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
begin
- if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic) then
+ if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic, ForceNoLoop) then
begin
SoundArray[find_id].Name := SoundName;
SoundArray[find_id].IsMusic := isMusic;