mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-21 07:22:33 +00:00
Merge branch 'music-debug' into 'master'
Music debugging, devmode music See merge request KartKrew/Kart!885
This commit is contained in:
commit
d42fdd0346
16 changed files with 96 additions and 44 deletions
|
|
@ -103,7 +103,7 @@ std::optional<float> Gme::loop_point_seconds() const
|
|||
if (loop_point_ms == -1)
|
||||
return std::nullopt;
|
||||
|
||||
return loop_point_ms / 44100.f;
|
||||
return loop_point_ms / 1000.f;
|
||||
}
|
||||
|
||||
float Gme::position_seconds() const
|
||||
|
|
|
|||
|
|
@ -314,6 +314,8 @@ public:
|
|||
return ogg_inst_->position_seconds();
|
||||
if (gme_inst_)
|
||||
return gme_inst_->position_seconds();
|
||||
if (xmp_inst_)
|
||||
return xmp_inst_->position_seconds();
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,16 @@ float Xmp<C>::duration_seconds() const
|
|||
return static_cast<float>(info.total_time) / 1000.f;
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
float Xmp<C>::position_seconds() const {
|
||||
SRB2_ASSERT(instance_ != nullptr);
|
||||
SRB2_ASSERT(module_loaded_ == true);
|
||||
|
||||
xmp_frame_info info;
|
||||
xmp_get_frame_info(instance_, &info);
|
||||
return static_cast<float>(info.time) / 1000.f;
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
void Xmp<C>::seek(int position_ms)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public:
|
|||
void looping(bool looping) { looping_ = looping; };
|
||||
void reset();
|
||||
float duration_seconds() const;
|
||||
float position_seconds() const;
|
||||
void seek(int position_ms);
|
||||
|
||||
~Xmp();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,12 @@ float XmpPlayer<C>::duration_seconds() const
|
|||
return xmp_.duration_seconds();
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
float XmpPlayer<C>::position_seconds() const
|
||||
{
|
||||
return xmp_.position_seconds();
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
void XmpPlayer<C>::seek(float position_seconds)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
void looping(bool looping) { xmp_.looping(looping); }
|
||||
void reset() { xmp_.reset(); }
|
||||
float duration_seconds() const;
|
||||
float position_seconds() const;
|
||||
void seek(float position_seconds);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "lua_script.h" // Lua stuff
|
||||
#include "m_cond.h" // Emblem constants
|
||||
#include "v_video.h" // video flags (for lua)
|
||||
#include "i_sound.h" // musictype_t (for lua)
|
||||
#include "g_state.h" // gamestate_t (for lua)
|
||||
#include "r_data.h" // patchalphastyle_t
|
||||
#include "k_boss.h" // spottype_t (for lua)
|
||||
|
|
@ -6783,18 +6782,6 @@ struct int_const_s const INT_CONST[] = {
|
|||
{"MA_NOCUTSCENES",MA_NOCUTSCENES},
|
||||
{"MA_INGAME",MA_INGAME},
|
||||
|
||||
// music types
|
||||
{"MU_NONE", MU_NONE},
|
||||
{"MU_WAV", MU_WAV},
|
||||
{"MU_MOD", MU_MOD},
|
||||
{"MU_MID", MU_MID},
|
||||
{"MU_OGG", MU_OGG},
|
||||
{"MU_MP3", MU_MP3},
|
||||
{"MU_FLAC", MU_FLAC},
|
||||
{"MU_GME", MU_GME},
|
||||
{"MU_MOD_EX", MU_MOD_EX},
|
||||
{"MU_MID_EX", MU_MID_EX},
|
||||
|
||||
// gamestates
|
||||
{"GS_NULL",GS_NULL},
|
||||
{"GS_LEVEL",GS_LEVEL},
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ typedef enum
|
|||
DBG_DETAILED = 0x00000002,
|
||||
DBG_PLAYER = 0x00000004,
|
||||
DBG_RENDER = 0x00000008,
|
||||
//DBG_NIGHTSBASIC = 0x00000010, // free
|
||||
DBG_MUSIC = 0x00000010,
|
||||
//DBG_NIGHTS = 0x00000020, // free
|
||||
DBG_POLYOBJ = 0x00000040,
|
||||
DBG_GAMELOGIC = 0x00000080,
|
||||
|
|
|
|||
|
|
@ -22,20 +22,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// copied from SDL mixer, plus GME
|
||||
typedef enum {
|
||||
MU_NONE,
|
||||
MU_WAV,
|
||||
MU_MOD,
|
||||
MU_MID,
|
||||
MU_OGG,
|
||||
MU_MP3,
|
||||
MU_FLAC,
|
||||
MU_GME,
|
||||
MU_MOD_EX, // libopenmpt
|
||||
MU_MID_EX // Non-native MIDI
|
||||
} musictype_t;
|
||||
|
||||
/** \brief Sound subsystem runing and waiting
|
||||
*/
|
||||
extern UINT8 sound_started;
|
||||
|
|
@ -139,7 +125,7 @@ void I_ShutdownMusic(void);
|
|||
// MUSIC PROPERTIES
|
||||
/// ------------------------
|
||||
|
||||
musictype_t I_SongType(void);
|
||||
const char *I_SongType(void);
|
||||
boolean I_SongPlaying(void);
|
||||
boolean I_SongPaused(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -2608,7 +2608,7 @@ static int lib_sMusicType(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushinteger(L, S_MusicType());
|
||||
lua_pushstring(L, S_MusicType());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -690,6 +690,7 @@ struct debugFlagNames_s const debug_flag_names[] =
|
|||
{"Lua", DBG_LUA},
|
||||
{"RNG", DBG_RNG},
|
||||
{"Randomizer", DBG_RNG}, // alt name
|
||||
{"Music", DBG_MUSIC},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "r_fps.h" // R_ResetViewInterpolation in level load
|
||||
|
||||
#include "s_sound.h"
|
||||
#include "i_sound.h" // I_FreeSfx
|
||||
#include "st_stuff.h"
|
||||
#include "w_wad.h"
|
||||
#include "z_zone.h"
|
||||
|
|
|
|||
|
|
@ -1365,7 +1365,7 @@ int musicdef_volume;
|
|||
//
|
||||
// Find music def by 6 char name
|
||||
//
|
||||
static musicdef_t *S_FindMusicDef(const char *name)
|
||||
musicdef_t *S_FindMusicDef(const char *name)
|
||||
{
|
||||
musicdef_t *def = musicdefstart;
|
||||
|
||||
|
|
@ -1702,7 +1702,7 @@ boolean S_MusicNotInFocus(void)
|
|||
);
|
||||
}
|
||||
|
||||
musictype_t S_MusicType(void)
|
||||
const char *S_MusicType(void)
|
||||
{
|
||||
return I_SongType();
|
||||
}
|
||||
|
|
@ -2444,8 +2444,6 @@ static inline void PrintMusicDefField(const char *label, const char *field)
|
|||
|
||||
static void PrintSongAuthors(const musicdef_t *def)
|
||||
{
|
||||
CONS_Printf("Volume: %d/100\n\n", def->volume);
|
||||
|
||||
PrintMusicDefField("Title: ", def->title);
|
||||
PrintMusicDefField("Author: ", def->author);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#ifndef __S_SOUND__
|
||||
#define __S_SOUND__
|
||||
|
||||
#include "i_sound.h" // musictype_t
|
||||
#include "sounds.h"
|
||||
#include "m_fixed.h"
|
||||
#include "command.h"
|
||||
|
|
@ -162,7 +161,7 @@ boolean S_MusicDisabled(void);
|
|||
boolean S_MusicPlaying(void);
|
||||
boolean S_MusicPaused(void);
|
||||
boolean S_MusicNotInFocus(void);
|
||||
musictype_t S_MusicType(void);
|
||||
const char *S_MusicType(void);
|
||||
const char *S_MusicName(void);
|
||||
|
||||
boolean S_MusicExists(const char *mname);
|
||||
|
|
@ -203,6 +202,7 @@ extern int musicdef_volume;
|
|||
|
||||
void S_LoadMusicDefs(UINT16 wadnum);
|
||||
void S_InitMusicDefs(void);
|
||||
musicdef_t *S_FindMusicDef(const char *name);
|
||||
void S_ShowMusicCredit(void);
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -375,10 +375,10 @@ void I_ShutdownMusic(void)
|
|||
// MUSIC PROPERTIES
|
||||
/// ------------------------
|
||||
|
||||
musictype_t I_SongType(void)
|
||||
const char* I_SongType(void)
|
||||
{
|
||||
if (!music_player)
|
||||
return MU_NONE;
|
||||
return nullptr;
|
||||
|
||||
SdlAudioLockHandle _;
|
||||
|
||||
|
|
@ -386,19 +386,19 @@ musictype_t I_SongType(void)
|
|||
|
||||
if (music_type == std::nullopt)
|
||||
{
|
||||
return MU_NONE;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (*music_type)
|
||||
{
|
||||
case audio::MusicType::kOgg:
|
||||
return MU_OGG;
|
||||
return "OGG";
|
||||
case audio::MusicType::kGme:
|
||||
return MU_GME;
|
||||
return "GME";
|
||||
case audio::MusicType::kMod:
|
||||
return MU_MOD;
|
||||
return "Mod";
|
||||
default:
|
||||
return MU_NONE;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -357,6 +357,60 @@ static INT32 SCR(INT32 r)
|
|||
// =========================================================================
|
||||
|
||||
// Devmode information
|
||||
|
||||
static void ST_pushDebugString(INT32 *height, const char *string)
|
||||
{
|
||||
V_DrawRightAlignedString(320, *height, V_MONOSPACE, string);
|
||||
*height -= 8;
|
||||
}
|
||||
|
||||
static void ST_pushDebugTimeMS(INT32 *height, const char *label, UINT32 ms)
|
||||
{
|
||||
ST_pushDebugString(height, va("%s%02d:%05.2f", label,
|
||||
ms / 60000, ms % 60000 / 1000.f));
|
||||
}
|
||||
|
||||
static void ST_drawMusicDebug(INT32 *height)
|
||||
{
|
||||
char mname[7];
|
||||
UINT16 mflags; // unused
|
||||
boolean looping;
|
||||
|
||||
const musicdef_t *def;
|
||||
const char *format;
|
||||
|
||||
if (!S_MusicInfo(mname, &mflags, &looping))
|
||||
{
|
||||
ST_pushDebugString(height, "Song: <NOTHING>");
|
||||
return;
|
||||
}
|
||||
|
||||
def = S_FindMusicDef(mname);
|
||||
format = S_MusicType();
|
||||
|
||||
ST_pushDebugTimeMS(height, " Elapsed: ", S_GetMusicPosition());
|
||||
ST_pushDebugTimeMS(height, looping
|
||||
? " Loop B: "
|
||||
: "Duration: ", S_GetMusicLength());
|
||||
|
||||
if (looping)
|
||||
{
|
||||
ST_pushDebugTimeMS(height, " Loop A: ", S_GetMusicLoopPoint());
|
||||
}
|
||||
|
||||
if (def)
|
||||
{
|
||||
ST_pushDebugString(height, va(" Volume: %4d/100", def->volume));
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
ST_pushDebugString(height, va(" Format: %8s", S_MusicType()));
|
||||
}
|
||||
|
||||
ST_pushDebugString(height, va(" Song: %8s", mname));
|
||||
}
|
||||
|
||||
static void ST_drawDebugInfo(void)
|
||||
{
|
||||
INT32 height = 192;
|
||||
|
|
@ -419,6 +473,11 @@ static void ST_drawDebugInfo(void)
|
|||
height -= 32;
|
||||
}
|
||||
|
||||
if (cht_debug & DBG_MUSIC)
|
||||
{
|
||||
ST_drawMusicDebug(&height);
|
||||
}
|
||||
|
||||
if (cht_debug & DBG_MEMORY)
|
||||
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue