Add support for loading sound assets from iw4 zones

This commit is contained in:
Jan
2020-09-08 12:11:16 +02:00
parent 79848b4631
commit d35560ccd7
8 changed files with 246 additions and 37 deletions

View File

@ -113,9 +113,9 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
m_material_vertex_decl = nullptr;
m_technique_set = nullptr;
m_image = nullptr;
// m_sound = nullptr;
// m_sound_curve = nullptr;
// m_loaded_sound = nullptr;
m_sound = nullptr;
m_sound_curve = nullptr;
m_loaded_sound = nullptr;
// m_clip_map = nullptr;
// m_com_world = nullptr;
// m_game_world_sp = nullptr;
@ -165,9 +165,9 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
@ -225,9 +225,9 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
@ -294,9 +294,9 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
// CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
// CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
// CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
// CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap);
// CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap);
// CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
@ -354,9 +354,9 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
// CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
// CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
// CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
// CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map);
// CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map);
// CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);

View File

@ -25,9 +25,9 @@ public:
std::unique_ptr<AssetPool<IW4::MaterialVertexDeclaration>> m_material_vertex_decl;
std::unique_ptr<AssetPool<IW4::MaterialTechniqueSet>> m_technique_set;
std::unique_ptr<AssetPool<IW4::GfxImage>> m_image;
// std::unique_ptr<AssetPool<IW4::snd_alias_list_t>> m_sound;
// std::unique_ptr<AssetPool<IW4::SndCurve>> m_sound_curve;
// std::unique_ptr<AssetPool<IW4::LoadedSound>> m_loaded_sound;
std::unique_ptr<AssetPool<IW4::snd_alias_list_t>> m_sound;
std::unique_ptr<AssetPool<IW4::SndCurve>> m_sound_curve;
std::unique_ptr<AssetPool<IW4::LoadedSound>> m_loaded_sound;
// std::unique_ptr<AssetPool<IW4::clipMap_t>> m_clip_map;
// std::unique_ptr<AssetPool<IW4::ComWorld>> m_com_world;
// std::unique_ptr<AssetPool<IW4::GameWorldSp>> m_game_world_sp;

View File

@ -84,9 +84,9 @@ namespace IW4
struct MaterialVertexDeclaration;
struct MaterialTechniqueSet;
struct GfxImage;
// struct snd_alias_list_t;
// struct SndCurve;
// struct LoadedSound;
struct snd_alias_list_t;
struct SndCurve;
struct LoadedSound;
// struct clipMap_t;
// struct ComWorld;
// struct GameWorldSp;
@ -105,7 +105,6 @@ namespace IW4
// struct FxImpactTable;
struct RawFile;
struct StringTable;
// struct LeaderboardDef;
// struct StructuredDataDefSet;
// struct TracerDef;
@ -125,9 +124,9 @@ namespace IW4
MaterialVertexDeclaration* vertexDecl;
MaterialTechniqueSet* techniqueSet;
GfxImage* image;
// snd_alias_list_t* sound;
// SndCurve* sndCurve;
// LoadedSound* loadSnd;
snd_alias_list_t* sound;
SndCurve* sndCurve;
LoadedSound* loadSnd;
// clipMap_t* clipMap;
// ComWorld* comWorld;
// GameWorldSp* gameWorldSp;
@ -852,6 +851,126 @@ namespace IW4
StringTableCell* values;
};
struct _AILSOUNDINFO
{
int format;
const void* data_ptr;
unsigned int data_len;
unsigned int rate;
int bits;
int channels;
unsigned int samples;
unsigned int block_size;
const void* initial_ptr;
};
struct MssSound
{
_AILSOUNDINFO info;
char* data;
};
struct LoadedSound
{
const char* name;
MssSound sound;
};
struct StreamedSound
{
const char* dir;
const char* name;
};
union SoundFileRef
{
LoadedSound* loadSnd;
StreamedSound streamSnd;
};
enum snd_alias_type_t : char
{
SAT_UNKNOWN = 0x0,
SAT_LOADED = 0x1,
SAT_STREAMED = 0x2,
SAT_VOICED = 0x3,
SAT_COUNT,
};
struct SoundFile
{
snd_alias_type_t type;
char exists;
SoundFileRef u;
};
struct MSSSpeakerLevels
{
int speaker;
int numLevels;
float levels[2];
};
struct MSSChannelMap
{
int speakerCount;
MSSSpeakerLevels speakers[6];
};
struct SpeakerMap
{
bool isDefault;
const char* name;
MSSChannelMap channelMaps[2][2];
};
struct snd_alias_t
{
const char* aliasName;
const char* subtitle;
const char* secondaryAliasName;
const char* chainAliasName;
const char* mixerGroup;
SoundFile* soundFile;
int sequence;
float volMin;
float volMax;
float pitchMin;
float pitchMax;
float distMin;
float distMax;
float velocityMin;
int flags;
union
{
float slavePercentage;
float masterPercentage;
};
float probability;
float lfePercentage;
float centerPercentage;
int startDelay;
SndCurve* volumeFalloffCurve;
float envelopMin;
float envelopMax;
float envelopPercentage;
SpeakerMap* speakerMap;
};
struct snd_alias_list_t
{
const char* aliasName;
snd_alias_t* head;
int count;
};
struct SndCurve
{
const char* filename;
unsigned __int16 knotCount;
float knots[16][2];
};
#ifndef __zonecodegenerator
}
#endif