Skip to content

Commit

Permalink
Merge pull request #278 from Jbleezy/main
Browse files Browse the repository at this point in the history
Improve sound bank dumping
  • Loading branch information
Laupetin authored Oct 8, 2024
2 parents 038ed9a + ac7b180 commit bf23d79
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 284 deletions.
27 changes: 27 additions & 0 deletions src/Common/Game/T6/CommonT6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "Utils/Pack.h"

#include <algorithm>
#include <cmath>

using namespace T6;

PackedTexCoords Common::Vec2PackTexCoords(const float (&in)[2])
Expand Down Expand Up @@ -33,3 +36,27 @@ void Common::Vec4UnpackGfxColor(const GfxColor& in, float (&out)[4])
{
pack32::Vec4UnpackGfxColor(in.packed, out);
}

float Common::LinearToDbspl(const float linear)
{
const auto db = 20.0f * std::log10(std::max(linear, 0.0000152879f));
if (db > -95.0f)
return db + 100.0f;

return 0;
}

float Common::DbsplToLinear(const float dbsplValue)
{
return std::pow(10.0f, (dbsplValue - 100.0f) / 20.0f);
}

float Common::HertzToCents(const float hertz)
{
return 1200.0f * std::log2(hertz);
}

float Common::CentsToHertz(const float cents)
{
return std::pow(2.0f, cents / 1200.0f);
}
4 changes: 4 additions & 0 deletions src/Common/Game/T6/CommonT6.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,9 @@ namespace T6
static void Vec2UnpackTexCoords(const PackedTexCoords& in, float (&out)[2]);
static void Vec3UnpackUnitVec(const PackedUnitVec& in, float (&out)[3]);
static void Vec4UnpackGfxColor(const GfxColor& in, float (&out)[4]);
static float LinearToDbspl(const float linear);
static float DbsplToLinear(const float dbsplValue);
static float HertzToCents(const float hertz);
static float CentsToHertz(const float cents);
};
} // namespace T6
2 changes: 1 addition & 1 deletion src/Common/Game/T6/T6_Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -6228,7 +6228,7 @@ namespace T6
unsigned int distanceLpf : 1; // 2
unsigned int doppler : 1; // 3
unsigned int isBig : 1; // 4
unsigned int pausable : 1; // 5
unsigned int pauseable : 1; // 5
unsigned int isMusic : 1; // 6
unsigned int stopOnEntDeath : 1; // 7
unsigned int timescale : 1; // 8
Expand Down
Loading

0 comments on commit bf23d79

Please sign in to comment.