-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
98 lines (77 loc) · 3.38 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//--------------------------------------------------------------------------------------
// File: common.h
//--------------------------------------------------------------------------------------
#ifndef __COMMON__
#define __COMMON__
//--------------------------------------------------------------------------------------
// forward declarations hacks
//--------------------------------------------------------------------------------------
extern HRESULT InitXAudio2(void);
extern HRESULT PlayPCM( IXAudio2* pXaudio2, LPCWSTR szFilename );
extern HRESULT PlayChannels(void);
extern HRESULT StopChannels(void);
extern double ProcessAudioVMath(int audioFrames);
extern double ProcessAudioXNAMath(int audioFrames);
extern double ProcessAudioVClass(int audioFrames);
extern double ProcessAudioVClassTypedef(int audioFrames);
extern double ProcessAudioVClassSIMDType(int audioFrames);
//globals
extern IXAudio2* g_pXAudio2;
extern LARGE_INTEGER g_qwTimeBefore;
extern LARGE_INTEGER g_qwTimeAfter;
extern LARGE_INTEGER g_ticksPerSecond;
extern float g_floatValues[16];
extern int g_intValues[16];
extern void DBugVec(WCHAR *str, float* p);
//--------------------------------------------------------------------------------------
// inline time functions
//--------------------------------------------------------------------------------------
inline void PerformanceCounterStart(void)
{
QueryPerformanceFrequency(&g_ticksPerSecond);
QueryPerformanceCounter( &g_qwTimeBefore );
}
inline double PerformanceCounterEnd(void)
{
QueryPerformanceCounter( &g_qwTimeAfter );
double diff = (double)(g_qwTimeAfter.QuadPart - g_qwTimeBefore.QuadPart);
double time = diff/(double)g_ticksPerSecond.QuadPart;
return(time);
}
//--------------------------------------------------------------------------------------
// defines & consts
//--------------------------------------------------------------------------------------
#define MATHLIB_TYPE_VMATH (0)
#define MATHLIB_TYPE_XNAMATH (1)
#define MATHLIB_TYPE_VCLASS (2)
#define MATHLIB_TYPE_VCLASS_TYPEDEF (3)
#define MATHLIB_TYPE_VCLASS_SIMDTYPE (4)
#define MATHLIB_TYPE_MAX (MATHLIB_TYPE_VCLASS_SIMDTYPE)
#define MATHLIB_TYPE_MIN (MATHLIB_TYPE_VMATH)
#define DEMO_TYPE_AUDIO (0)
#define DEMO_TYPE_CLOTH (1)
//--------------------------------------------------------------------------------------
// more hacks
//--------------------------------------------------------------------------------------
// A structure for our custom vertex type
typedef struct CUSTOMVERTEX
{
FLOAT x, y, z; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
} CUSTOMVERTEX, *PCUSTOMVERTEX;
// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
//--------------------------------------------------------------------------------------
// Aux Structs
//--------------------------------------------------------------------------------------
typedef struct AudioSampleStruct
{
__m128* pSIMDWavDataSrc; //source copy for processing SIMD friendly
__m128* pSIMDWavDataDest; //audio data stored as:
//b0, g0, d0, t0, b1, g1, d1, t1, b2, g2, d2, t2, etc...
BYTE* pWavDataSrc[4]; //source copy for processing FPU
BYTE* pWavDataDest[4];
int wavSize[4];
IXAudio2SourceVoice* pSourceVoice[4];
} AudioChannelStruct;
#endif // #ifndef __COMMON__