mirror of
https://github.com/XProger/OpenLara.git
synced 2025-02-24 15:32:30 +01:00
fix soundtracks remapping for web build, double precise for stb_vorbis LUTs initialization
This commit is contained in:
parent
3d560a10be
commit
50586ae604
@ -886,26 +886,28 @@ namespace TR {
|
||||
}
|
||||
|
||||
uint8 remapTrack(Version version, uint8 track) {
|
||||
static const uint8 TR2_TRACK_MAPPING[] = {
|
||||
2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 19, 20,
|
||||
21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61
|
||||
};
|
||||
|
||||
if (version & VER_TR2) {
|
||||
ASSERT(track < COUNT(TR2_TRACK_MAPPING));
|
||||
return TR2_TRACK_MAPPING[track];
|
||||
}
|
||||
static const uint8 TR1_TRACK_MAPPING[] = {
|
||||
2, 2, 2, 11, 12, 3, 13, 14, 15, 16, 17, 18, 19, 60, 20, 21, 22, 23, 24, 25, 26, 27,
|
||||
7, 8, 9, 10, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
||||
47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 28, 4, 5, 6
|
||||
};
|
||||
|
||||
static const uint8 TR2_TRACK_MAPPING[] = {
|
||||
2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 19, 20,
|
||||
21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61
|
||||
};
|
||||
|
||||
if (version & VER_TR1) {
|
||||
ASSERT(track < COUNT(TR1_TRACK_MAPPING));
|
||||
return TR1_TRACK_MAPPING[track];
|
||||
}
|
||||
|
||||
if (version & VER_TR2) {
|
||||
ASSERT(track < COUNT(TR2_TRACK_MAPPING));
|
||||
return TR2_TRACK_MAPPING[track];
|
||||
}
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
@ -972,10 +974,12 @@ namespace TR {
|
||||
case VER_TR1_PC :
|
||||
case VER_TR1_PSX :
|
||||
sprintf(title, "audio/1/track_%02d.ogg", track);
|
||||
#ifndef _OS_WEB
|
||||
if (Stream::existsContent(title))
|
||||
break;
|
||||
track = remapTrack(version, track);
|
||||
sprintf(title, "audio/1/%03d.ogg", track);
|
||||
#endif
|
||||
break;
|
||||
case VER_TR2_PC :
|
||||
case VER_TR2_PSX :
|
||||
|
@ -1219,16 +1219,22 @@ static int lookup1_values(int entries, int dim)
|
||||
|
||||
#define sinf(x) vfpu_sinf(x)
|
||||
#define cosf(x) vfpu_cosf(x)
|
||||
#define sincos(a, s, c) vfpu_sincos(a, s, c)
|
||||
|
||||
void sincosd(double x, double *s, double *c) {
|
||||
float fs, fc;
|
||||
vfpu_sincos((float)x, fs, fc);
|
||||
*s = (double)fs;
|
||||
*c = (double)fc;
|
||||
}
|
||||
#else
|
||||
static void sincos(float r, float *s, float *c) {
|
||||
*s = sinf(r);
|
||||
*c = cosf(r);
|
||||
void sincosd(double x, double *s, double *c) {
|
||||
*s = sin(x);
|
||||
*c = cos(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define rotate(x, y, s, c) {\
|
||||
float t = x*c - y*s;\
|
||||
double t = x*c - y*s;\
|
||||
y = x*s + y*c;\
|
||||
x = t;\
|
||||
}
|
||||
@ -1238,65 +1244,59 @@ static void compute_twiddle_factors(int n, float *A, float *B, float *C)
|
||||
{
|
||||
int n4 = n >> 2, n8 = n >> 3;
|
||||
int k, k2;
|
||||
#ifdef __MINGW64__
|
||||
|
||||
double sA, cA, sB, cB, sC, cC;
|
||||
double xA, yA, xB, yB, xC, yC;
|
||||
#else
|
||||
float sA, cA, sB, cB, sC, cC;
|
||||
float xA, yA, xB, yB, xC, yC;
|
||||
#endif
|
||||
|
||||
sincos(4*M_PI/n, &sA, &cA);
|
||||
sincos(M_PI/n/2, &sB, &cB);
|
||||
sincos(2*M_PI/n, &sC, &cC);
|
||||
sincosd(4*M_PI/n, &sA, &cA);
|
||||
sincosd(M_PI/n/2, &sB, &cB);
|
||||
sincosd(2*M_PI/n, &sC, &cC);
|
||||
|
||||
A[0] = xA = 1.0f;
|
||||
A[1] = yA = 0.0f;
|
||||
xA = 1.0;
|
||||
yA = 0.0;
|
||||
A[0] = 1.0f;
|
||||
A[1] = 0.0f;
|
||||
xB = cB;
|
||||
yB = sB;
|
||||
B[0] = xB * 0.5f;
|
||||
B[1] = yB * 0.5f;
|
||||
B[0] = (float)(xB * 0.5);
|
||||
B[1] = (float)(yB * 0.5);
|
||||
rotate(cB, sB, sB, cB);
|
||||
|
||||
for (k=1, k2=2; k < n4; ++k,k2+=2) {
|
||||
rotate(xA, yA, sA, cA);
|
||||
A[k2 ] = xA;
|
||||
A[k2+1] = -yA;
|
||||
A[k2 ] = (float) xA;
|
||||
A[k2+1] = (float)-yA;
|
||||
rotate(xB, yB, sB, cB);
|
||||
B[k2 ] = xB * 0.5f;
|
||||
B[k2+1] = yB * 0.5f;
|
||||
B[k2 ] = (float)(xB * 0.5);
|
||||
B[k2+1] = (float)(yB * 0.5);
|
||||
}
|
||||
|
||||
xC = cC;
|
||||
yC = sC;
|
||||
C[0] = xC;
|
||||
C[1] = -yC;
|
||||
C[0] = (float) xC;
|
||||
C[1] = (float)-yC;
|
||||
|
||||
rotate(cC, sC, sC, cC);
|
||||
|
||||
for (k=1, k2=2; k < n8; ++k,k2+=2) {
|
||||
rotate(xC, yC, sC, cC);
|
||||
C[k2 ] = xC;
|
||||
C[k2+1] = -yC;
|
||||
C[k2 ] = (float) xC;
|
||||
C[k2+1] = (float)-yC;
|
||||
}
|
||||
}
|
||||
|
||||
static void compute_window(int n, float *window)
|
||||
{
|
||||
int n2 = n >> 1, i;
|
||||
#ifdef __MINGW64__
|
||||
double s, c, x, y;
|
||||
#else
|
||||
float s, c, x, y;
|
||||
#endif
|
||||
|
||||
sincos(0.5f / n2 * 0.5f * M_PI, &s, &c);
|
||||
sincosd(0.5f / n2 * 0.5f * M_PI, &s, &c);
|
||||
x = c;
|
||||
y = s;
|
||||
rotate(c, s, s, c);
|
||||
|
||||
for (i=0; i < n2; ++i) {
|
||||
window[i] = sinf(0.5f * M_PI * (y * y));
|
||||
window[i] = (float)sin(0.5 * M_PI * (y * y));
|
||||
rotate(x, y, s, c);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user