Added recognition for audio bank files

Added wrapper class to hold path for fmod system
This commit is contained in:
Xiao Qi 2023-01-31 18:27:39 +08:00
parent 8c9673cafd
commit 883c3c8fc1
10 changed files with 74 additions and 5 deletions

View File

@ -0,0 +1,3 @@
Name: Master
ID: 187131295
Type: 11

View File

@ -0,0 +1,3 @@
Name: Master.strings
ID: 184993030
Type: 11

View File

@ -0,0 +1,3 @@
Name: Music
ID: 187337426
Type: 11

View File

@ -0,0 +1,3 @@
Name: SFX
ID: 200039123
Type: 11

View File

@ -0,0 +1,3 @@
Name: UI
ID: 185075145
Type: 11

View File

@ -76,7 +76,7 @@ DockId=0x0000000B,0
[Window][ Viewport] [Window][ Viewport]
Pos=302,48 Pos=302,48
Size=1300,836 Size=1300,266
Collapsed=0 Collapsed=0
DockId=0x0000000B,0 DockId=0x0000000B,0
@ -93,8 +93,8 @@ Collapsed=0
DockId=0x0000000A,0 DockId=0x0000000A,0
[Window][ Asset Browser] [Window][ Asset Browser]
Pos=302,886 Pos=302,316
Size=1300,103 Size=1300,673
Collapsed=0 Collapsed=0
DockId=0x0000000C,0 DockId=0x0000000C,0
@ -157,8 +157,8 @@ DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1300,1036 Split=Y Selected=0xB41284E7 DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1300,1036 Split=Y Selected=0xB41284E7
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7 DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7 DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,836 CentralNode=1 Selected=0xB41284E7 DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,266 CentralNode=1 Selected=0xB41284E7
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,103 Selected=0xB128252A DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,673 Selected=0xB128252A
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6 DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532 DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=316,1036 Selected=0xE7039252 DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=316,1036 Selected=0xE7039252

View File

@ -0,0 +1,23 @@
/******************************************************************************
* \file SHAudioBankAsset.h
* \author Loh Xiao Qi
* \date 31 January 2023
* \brief
*
* \copyright Copyright (c) 2023 Digipen Institute of Technology. Reproduction
* or disclosure of this file or its contents without the prior
* written consent of Digipen Institute of Technology is prohibited.
******************************************************************************/
#pragma once
#include "SHAssetData.h"
#include <string>
namespace SHADE
{
struct SHAudioBankAsset : SHAssetData
{
std::string name;
std::string path;
};
}

View File

@ -14,6 +14,7 @@
#include "Assets/Asset Types/SHSceneAsset.h" #include "Assets/Asset Types/SHSceneAsset.h"
#include "Assets/Asset Types/SHPrefabAsset.h" #include "Assets/Asset Types/SHPrefabAsset.h"
#include "Assets/Asset Types/SHMaterialAsset.h" #include "Assets/Asset Types/SHMaterialAsset.h"
#include "Assets/Asset Types/SHAudioBankAsset.h"
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
@ -22,6 +23,14 @@ namespace SHADE
{ {
SHAssetData* SHTextBasedLoader::Load(AssetPath path) SHAssetData* SHTextBasedLoader::Load(AssetPath path)
{ {
if (path.extension().string() == AUDIO_BANK_EXTENSION)
{
auto data = new SHAudioBankAsset();
data->name = path.stem().string();
data->path = path.string();
return data;
}
std::ifstream file{ path, std::ios::in }; std::ifstream file{ path, std::ios::in };
if (!file.is_open()) if (!file.is_open())

View File

@ -56,6 +56,7 @@ enum class AssetType : AssetTypeMeta
MESH, MESH,
SCRIPT, SCRIPT,
FONT, FONT,
AUDIO_BANK,
MAX_COUNT MAX_COUNT
}; };
constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) }; constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) };
@ -83,6 +84,7 @@ constexpr std::string_view MATERIAL_FOLDER{ "/Materials/" };
constexpr std::string_view META_EXTENSION {".shmeta"}; constexpr std::string_view META_EXTENSION {".shmeta"};
constexpr std::string_view AUDIO_EXTENSION {".ogg"}; constexpr std::string_view AUDIO_EXTENSION {".ogg"};
constexpr std::string_view AUDIO_WAV_EXTENSION {".wav"}; constexpr std::string_view AUDIO_WAV_EXTENSION {".wav"};
constexpr std::string_view AUDIO_BANK_EXTENSION {".bank"};
constexpr std::string_view SHADER_EXTENSION{ ".shshader" }; constexpr std::string_view SHADER_EXTENSION{ ".shshader" };
constexpr std::string_view SHADER_BUILT_IN_EXTENSION{ ".shshaderb" }; constexpr std::string_view SHADER_BUILT_IN_EXTENSION{ ".shshaderb" };
constexpr std::string_view FONT_EXTENSION{ ".shfont" }; constexpr std::string_view FONT_EXTENSION{ ".shfont" };
@ -106,6 +108,7 @@ constexpr std::string_view EXTENSIONS[] = {
SCRIPT_EXTENSION, SCRIPT_EXTENSION,
FONT_EXTENSION, FONT_EXTENSION,
AUDIO_WAV_EXTENSION, AUDIO_WAV_EXTENSION,
AUDIO_BANK_EXTENSION
}; };
constexpr size_t EXTENSIONS_COUNT{ 11 }; constexpr size_t EXTENSIONS_COUNT{ 11 };

View File

@ -431,6 +431,10 @@ namespace SHADE
fontPath += FONT_EXTENSION; fontPath += FONT_EXTENSION;
newPath = fontPath; newPath = fontPath;
} }
else if (ext == AUDIO_BANK_EXTENSION.data())
{
newPath = path.string();
}
else else
{ {
SHLOG_WARNING("[Asset Manager] File Type compilation not yet Implemented: {}", path.string()); SHLOG_WARNING("[Asset Manager] File Type compilation not yet Implemented: {}", path.string());
@ -485,6 +489,7 @@ namespace SHADE
loaders[static_cast<size_t>(AssetType::MESH)] = nullptr; loaders[static_cast<size_t>(AssetType::MESH)] = nullptr;
loaders[static_cast<size_t>(AssetType::SCRIPT)] = nullptr; loaders[static_cast<size_t>(AssetType::SCRIPT)] = nullptr;
loaders[static_cast<size_t>(AssetType::FONT)] = dynamic_cast<SHAssetLoader*>(new SHFontLoader()); loaders[static_cast<size_t>(AssetType::FONT)] = dynamic_cast<SHAssetLoader*>(new SHFontLoader());
loaders[static_cast<size_t>(AssetType::AUDIO_BANK)] = loaders[static_cast<size_t>(AssetType::SCENE)];
} }
/**************************************************************************** /****************************************************************************
@ -653,6 +658,20 @@ namespace SHADE
return newAsset.id; return newAsset.id;
} }
else if (ext == AUDIO_BANK_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::AUDIO_BANK),
AssetType::AUDIO_BANK,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
else if(ext == MATERIAL_EXTENSION) else if(ext == MATERIAL_EXTENSION)
{ {
SHAsset newAsset{ SHAsset newAsset{