audio stats functions

This commit is contained in:
MihailRis 2024-03-19 13:42:38 +03:00
parent f2c26aed19
commit d5c39a05fb
3 changed files with 33 additions and 0 deletions

View File

@ -193,3 +193,13 @@ audio.set_velocity(speakerid: integer, x: number, y: number, z: number)
-- also returns 0, if duration is unknown (example: radio)
audio.get_duration(speakerid: integer) -> number
```
### Other functions
```lua
-- get current number of alive speakers
audio.count_speakers() -> integer
-- get current number of playing streams
audio.count_streams() -> integer
```

View File

@ -194,3 +194,12 @@ audio.set_velocity(speakerid: integer, x: number, y: number, z: number)
audio.get_duration(speakerid: integer) -> number
```
### Другие функции
```lua
-- получить текущее число живых спикеров
audio.count_speakers() -> integer
-- получить текущее число проигрываемых аудио-потоков
audio.count_streams() -> integer
```

View File

@ -391,6 +391,18 @@ static int l_audio_get_velocity(lua_State* L) {
return 0;
}
// @brief audio.count_speakers() -> integer
static int l_audio_count_speakers(lua_State* L) {
lua_pushinteger(L, audio::count_speakers());
return 1;
}
// @brief audio.count_streams() -> integer
static int l_audio_count_streams(lua_State* L) {
lua_pushinteger(L, audio::count_streams());
return 1;
}
const luaL_Reg audiolib [] = {
{"play_sound", lua_wrap_errors<l_audio_play_sound>},
{"play_sound_2d", lua_wrap_errors<l_audio_play_sound_2d>},
@ -414,5 +426,7 @@ const luaL_Reg audiolib [] = {
{"get_duration", lua_wrap_errors<l_audio_get_duration>},
{"get_position", lua_wrap_errors<l_audio_get_position>},
{"get_velocity", lua_wrap_errors<l_audio_get_velocity>},
{"count_speakers", lua_wrap_errors<l_audio_count_speakers>},
{"count_streams", lua_wrap_errors<l_audio_count_streams>},
{NULL, NULL}
};