mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
(This commit does not compile. Sound test and tunes command code needs to be ported after this.) This is a big one. Here's the rundown: The old music system was very direct, much of the time just a proxy to the real sound API in i_sound.h. You could change the music on command, but there wasn't a consistent way to prevent some music from playing over others. P_RestoreMusic is one example of needing to address this problem. The jingles system was intended as another solution. Furthermore, sound test (Stereo) has its own needs. I am removing all of that. Music handling in general is now a very deliberate system, kind of similar to jingles. In the new system, "tunes" are registered. The tune stores info such as whether it should loop or fade out. Most of the configuration is intended to be initialized only ONCE. Tunes can be mapped to an actual music lump. They can be remapped at any time too. Tunes are also configured with a priority number. This determines which tune is heard, if multiple are supposed to be playing at a time. You can even tell a tune how long it should play, so it's unnecessary to track this with bespoke timers.
38 lines
864 B
C++
38 lines
864 B
C++
// DR ROBOTNIK'S RING RACERS
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 2023 by Kart Krew.
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef MUSIC_DETAIL_HPP
|
|
#define MUSIC_DETAIL_HPP
|
|
|
|
#include "doomdef.h"
|
|
#include "doomstat.h"
|
|
#include "doomtype.h"
|
|
|
|
namespace srb2::music::detail
|
|
{
|
|
|
|
inline constexpr tic_t msec_to_tics(int msec)
|
|
{
|
|
return msec * (TICRATE / 1000.f);
|
|
}
|
|
|
|
inline constexpr int tics_to_msec(tic_t tics)
|
|
{
|
|
return tics * (1000.f / TICRATE);
|
|
}
|
|
|
|
inline tic_t tic_time()
|
|
{
|
|
// Use gametic so it is synced with game logic.
|
|
return gametic;
|
|
}
|
|
|
|
}; // namespace srb2::music::detail
|
|
|
|
#endif // MUSIC_DETAIL_HPP
|