mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
code review changes
This commit is contained in:
parent
42c4068d2a
commit
2478a1355f
@ -7,7 +7,7 @@ class AlgorithmMD5 : public IHashFunction
|
||||
AlgorithmMD5Impl* m_impl;
|
||||
|
||||
public:
|
||||
static const int HASH_SIZE = 20;
|
||||
static const int HASH_SIZE = 16;
|
||||
|
||||
AlgorithmMD5();
|
||||
~AlgorithmMD5() override;
|
||||
|
@ -1,19 +1,19 @@
|
||||
#include "Csv/ParsedCsv.h"
|
||||
|
||||
ParsedCsvRow::ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std::vector<std::string>& row)
|
||||
ParsedCsvRow::ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std::vector<std::string> row)
|
||||
: headers(headers),
|
||||
values(row)
|
||||
values(std::move(row))
|
||||
{
|
||||
}
|
||||
|
||||
const std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const
|
||||
std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const
|
||||
{
|
||||
if (this->headers.find(header) == this->headers.end())
|
||||
{
|
||||
if (required)
|
||||
std::cerr << "ERROR: Required column \"" << header << "\" was not found";
|
||||
std::cerr << "ERROR: Required column \"" << header << "\" was not found" << std::endl;
|
||||
else
|
||||
std::cerr << "WARNING: Expected column \"" << header << "\" was not found";
|
||||
std::cerr << "WARNING: Expected column \"" << header << "\" was not found" << std::endl;
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -21,14 +21,14 @@ const std::string ParsedCsvRow::GetValue(const std::string& header, bool require
|
||||
auto& value = this->values.at(this->headers[header]);
|
||||
if (required && value.empty())
|
||||
{
|
||||
std::cerr << "ERROR: Required column \"" << header << "\" does not have a value";
|
||||
std::cerr << "ERROR: Required column \"" << header << "\" does not have a value" << std::endl;
|
||||
return {};
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
const float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const
|
||||
float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const
|
||||
{
|
||||
const auto& value = this->GetValue(header, required);
|
||||
if (!value.empty())
|
||||
@ -65,7 +65,7 @@ ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders)
|
||||
for (auto i = hasHeaders ? 1u : 0u; i < csvLines.size(); i++)
|
||||
{
|
||||
auto& rowValues = csvLines[i];
|
||||
this->rows.push_back(ParsedCsvRow(this->headers, rowValues));
|
||||
this->rows.emplace_back(this->headers, std::move(rowValues));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <Csv/CsvStream.h>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
#include "Csv/CsvStream.h"
|
||||
|
||||
class ParsedCsvRow
|
||||
{
|
||||
@ -9,9 +9,9 @@ class ParsedCsvRow
|
||||
std::vector<std::string> values;
|
||||
|
||||
public:
|
||||
explicit ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std::vector<std::string>& row);
|
||||
const std::string GetValue(const std::string& header, bool required = false) const;
|
||||
const float GetValueFloat(const std::string& header, bool required = false) const;
|
||||
explicit ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std::vector<std::string> row);
|
||||
std::string GetValue(const std::string& header, bool required = false) const;
|
||||
float GetValueFloat(const std::string& header, bool required = false) const;
|
||||
|
||||
template<typename T> T GetValueInt(const std::string& header, bool required = false) const
|
||||
{
|
||||
|
@ -26,14 +26,5 @@ namespace T6
|
||||
static constexpr const char* GDF_FILENAME_WEAPON_ATTACHMENT = "attachment.gdf";
|
||||
static constexpr const char* GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE = "attachmentunique.gdf";
|
||||
static constexpr const char* GDF_FILENAME_ZBARRIER = "zbarrier.gdf";
|
||||
|
||||
static const std::array<std::string, 27> SOUND_GROUPS;
|
||||
static const std::array<std::string, 18> SOUND_CURVES;
|
||||
static const std::array<std::string, 32> SOUND_DUCK_GROUPS;
|
||||
static const std::array<std::string, 4> SOUND_LIMIT_TYPES;
|
||||
static const std::array<std::string, 8> SOUND_MOVE_TYPES;
|
||||
static const std::array<std::string, 4> SOUND_LOAD_TYPES;
|
||||
static const std::array<std::string, 11> SOUND_BUS_IDS;
|
||||
static const std::array<std::string, 4> SOUND_RANDOMIZE_TYPES;
|
||||
};
|
||||
} // namespace T6
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "ObjConstantsT6.h"
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
const std::array<std::string, 27> ObjConstants::SOUND_GROUPS{
|
||||
inline const std::string SOUND_GROUPS[]{
|
||||
"grp_reference",
|
||||
"grp_master",
|
||||
"grp_wpn_lfe",
|
||||
@ -32,7 +33,7 @@ namespace T6
|
||||
"",
|
||||
};
|
||||
|
||||
const std::array<std::string, 18> ObjConstants::SOUND_CURVES{
|
||||
inline const std::string SOUND_CURVES[]{
|
||||
"default",
|
||||
"defaultmin",
|
||||
"allon",
|
||||
@ -53,7 +54,7 @@ namespace T6
|
||||
"",
|
||||
};
|
||||
|
||||
const std::array<std::string, 32> ObjConstants::SOUND_DUCK_GROUPS{
|
||||
inline const std::string SOUND_DUCK_GROUPS[]{
|
||||
"snp_alerts_gameplay",
|
||||
"snp_ambience",
|
||||
"snp_claw",
|
||||
@ -88,14 +89,14 @@ namespace T6
|
||||
"snp_x3",
|
||||
};
|
||||
|
||||
const std::array<std::string, 4> ObjConstants::SOUND_LIMIT_TYPES{
|
||||
inline const std::string SOUND_LIMIT_TYPES[]{
|
||||
"none",
|
||||
"oldest",
|
||||
"reject",
|
||||
"priority",
|
||||
};
|
||||
|
||||
const std::array<std::string, 8> ObjConstants::SOUND_MOVE_TYPES{
|
||||
inline const std::string SOUND_MOVE_TYPES[]{
|
||||
"none",
|
||||
"left_player",
|
||||
"center_player",
|
||||
@ -106,14 +107,14 @@ namespace T6
|
||||
"right_shot",
|
||||
};
|
||||
|
||||
const std::array<std::string, 4> ObjConstants::SOUND_LOAD_TYPES{
|
||||
inline const std::string SOUND_LOAD_TYPES[]{
|
||||
"unknown",
|
||||
"loaded",
|
||||
"streamed",
|
||||
"primed",
|
||||
};
|
||||
|
||||
const std::array<std::string, 11> ObjConstants::SOUND_BUS_IDS{
|
||||
inline const std::string SOUND_BUS_IDS[]{
|
||||
"bus_reverb",
|
||||
"bus_fx",
|
||||
"bus_voice",
|
||||
@ -127,11 +128,10 @@ namespace T6
|
||||
"",
|
||||
};
|
||||
|
||||
const std::array<std::string, 4> ObjConstants::SOUND_RANDOMIZE_TYPES{
|
||||
inline const std::string SOUND_RANDOMIZE_TYPES[]{
|
||||
"volume",
|
||||
"pitch",
|
||||
"variant",
|
||||
"",
|
||||
};
|
||||
|
||||
} // namespace T6
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "Csv/ParsedCsv.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/SoundConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "ObjContainer/SoundBank/SoundBankWriter.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
@ -180,24 +180,18 @@ bool LoadSoundAlias(MemoryManager* memory, SndAlias* alias, const ParsedCsvRow&
|
||||
alias->flags.pauseable = row.GetValue("pause") == "yes";
|
||||
alias->flags.stopOnDeath = row.GetValue("stop_on_death") == "yes";
|
||||
|
||||
alias->duckGroup =
|
||||
static_cast<char>(GetValueIndex(row.GetValue("duck_group"), ObjConstants::SOUND_DUCK_GROUPS.data(), ObjConstants::SOUND_DUCK_GROUPS.size()));
|
||||
alias->flags.volumeGroup = GetValueIndex(row.GetValue("group"), ObjConstants::SOUND_GROUPS.data(), ObjConstants::SOUND_GROUPS.size());
|
||||
alias->flags.fluxType = GetValueIndex(row.GetValue("move_type"), ObjConstants::SOUND_MOVE_TYPES.data(), ObjConstants::SOUND_MOVE_TYPES.size());
|
||||
alias->flags.loadType = GetValueIndex(row.GetValue("type"), ObjConstants::SOUND_LOAD_TYPES.data(), ObjConstants::SOUND_LOAD_TYPES.size());
|
||||
alias->flags.busType = GetValueIndex(row.GetValue("bus"), ObjConstants::SOUND_BUS_IDS.data(), ObjConstants::SOUND_BUS_IDS.size());
|
||||
alias->flags.limitType = GetValueIndex(row.GetValue("limit_type"), ObjConstants::SOUND_LIMIT_TYPES.data(), ObjConstants::SOUND_LIMIT_TYPES.size());
|
||||
alias->flags.volumeFalloffCurve = GetValueIndex(row.GetValue("volume_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size());
|
||||
alias->flags.reverbFalloffCurve = GetValueIndex(row.GetValue("reverb_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size());
|
||||
|
||||
alias->flags.entityLimitType =
|
||||
GetValueIndex(row.GetValue("entity_limit_type"), ObjConstants::SOUND_LIMIT_TYPES.data(), ObjConstants::SOUND_LIMIT_TYPES.size());
|
||||
alias->flags.volumeMinFalloffCurve =
|
||||
GetValueIndex(row.GetValue("volume_min_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size());
|
||||
alias->flags.reverbMinFalloffCurve =
|
||||
GetValueIndex(row.GetValue("reverb_min_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size());
|
||||
alias->flags.randomizeType =
|
||||
GetValueIndex(row.GetValue("randomize_type"), ObjConstants::SOUND_RANDOMIZE_TYPES.data(), ObjConstants::SOUND_RANDOMIZE_TYPES.size());
|
||||
alias->duckGroup = static_cast<char>(GetValueIndex(row.GetValue("duck_group"), SOUND_DUCK_GROUPS, std::extent_v<decltype(SOUND_DUCK_GROUPS)>));
|
||||
alias->flags.volumeGroup = GetValueIndex(row.GetValue("group"), SOUND_GROUPS, std::extent_v<decltype(SOUND_GROUPS)>);
|
||||
alias->flags.fluxType = GetValueIndex(row.GetValue("move_type"), SOUND_MOVE_TYPES, std::extent_v<decltype(SOUND_MOVE_TYPES)>);
|
||||
alias->flags.loadType = GetValueIndex(row.GetValue("type"), SOUND_LOAD_TYPES, std::extent_v<decltype(SOUND_LOAD_TYPES)>);
|
||||
alias->flags.busType = GetValueIndex(row.GetValue("bus"), SOUND_BUS_IDS, std::extent_v<decltype(SOUND_BUS_IDS)>);
|
||||
alias->flags.limitType = GetValueIndex(row.GetValue("limit_type"), SOUND_LIMIT_TYPES, std::extent_v<decltype(SOUND_LIMIT_TYPES)>);
|
||||
alias->flags.volumeFalloffCurve = GetValueIndex(row.GetValue("volume_falloff_curve"), SOUND_CURVES, std::extent_v<decltype(SOUND_CURVES)>);
|
||||
alias->flags.reverbFalloffCurve = GetValueIndex(row.GetValue("reverb_falloff_curve"), SOUND_CURVES, std::extent_v<decltype(SOUND_CURVES)>);
|
||||
alias->flags.entityLimitType = GetValueIndex(row.GetValue("entity_limit_type"), SOUND_LIMIT_TYPES, std::extent_v<decltype(SOUND_LIMIT_TYPES)>);
|
||||
alias->flags.volumeMinFalloffCurve = GetValueIndex(row.GetValue("volume_min_falloff_curve"), SOUND_CURVES, std::extent_v<decltype(SOUND_CURVES)>);
|
||||
alias->flags.reverbMinFalloffCurve = GetValueIndex(row.GetValue("reverb_min_falloff_curve"), SOUND_CURVES, std::extent_v<decltype(SOUND_CURVES)>);
|
||||
alias->flags.randomizeType = GetValueIndex(row.GetValue("randomize_type"), SOUND_RANDOMIZE_TYPES, std::extent_v<decltype(SOUND_RANDOMIZE_TYPES)>);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -208,16 +202,15 @@ bool LoadSoundAliasIndexList(MemoryManager* memory, SndBank* sndBank)
|
||||
sndBank->aliasIndex = static_cast<SndIndexEntry*>(memory->Alloc(sizeof(SndIndexEntry) * sndBank->aliasCount));
|
||||
memset(sndBank->aliasIndex, 0xFF, sizeof(SndIndexEntry) * sndBank->aliasCount);
|
||||
|
||||
bool* setAliasIndexList = new bool[sndBank->aliasCount];
|
||||
memset(setAliasIndexList, false, sndBank->aliasCount);
|
||||
const auto setAliasIndexList = std::make_unique<bool[]>(sndBank->aliasCount);
|
||||
|
||||
for (auto i = 0u; i < sndBank->aliasCount; i++)
|
||||
{
|
||||
auto idx = sndBank->alias[i].id % sndBank->aliasCount;
|
||||
if (sndBank->aliasIndex[idx].value == USHRT_MAX)
|
||||
if (sndBank->aliasIndex[idx].value == std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
sndBank->aliasIndex[idx].value = i;
|
||||
sndBank->aliasIndex[idx].next = USHRT_MAX;
|
||||
sndBank->aliasIndex[idx].next = std::numeric_limits<unsigned short>::max();
|
||||
setAliasIndexList[i] = true;
|
||||
}
|
||||
}
|
||||
@ -228,44 +221,42 @@ bool LoadSoundAliasIndexList(MemoryManager* memory, SndBank* sndBank)
|
||||
continue;
|
||||
|
||||
auto idx = sndBank->alias[i].id % sndBank->aliasCount;
|
||||
while (sndBank->aliasIndex[idx].next != USHRT_MAX)
|
||||
while (sndBank->aliasIndex[idx].next != std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
idx = sndBank->aliasIndex[idx].next;
|
||||
}
|
||||
|
||||
auto offset = 1u;
|
||||
auto freeIdx = USHRT_MAX;
|
||||
auto freeIdx = std::numeric_limits<unsigned short>::max();
|
||||
while (true)
|
||||
{
|
||||
freeIdx = (idx + offset) % sndBank->aliasCount;
|
||||
if (sndBank->aliasIndex[freeIdx].value == USHRT_MAX)
|
||||
if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits<unsigned short>::max())
|
||||
break;
|
||||
|
||||
freeIdx = (idx + sndBank->aliasCount - offset) % sndBank->aliasCount;
|
||||
if (sndBank->aliasIndex[freeIdx].value == USHRT_MAX)
|
||||
if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits<unsigned short>::max())
|
||||
break;
|
||||
|
||||
offset++;
|
||||
freeIdx = USHRT_MAX;
|
||||
freeIdx = std::numeric_limits<unsigned short>::max();
|
||||
|
||||
if (offset >= sndBank->aliasCount)
|
||||
break;
|
||||
}
|
||||
|
||||
if (freeIdx == USHRT_MAX)
|
||||
if (freeIdx == std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
std::cerr << "Unable to allocate sound bank alias index list" << std::endl;
|
||||
delete[] setAliasIndexList;
|
||||
return false;
|
||||
}
|
||||
|
||||
sndBank->aliasIndex[idx].next = freeIdx;
|
||||
sndBank->aliasIndex[freeIdx].value = i;
|
||||
sndBank->aliasIndex[freeIdx].next = USHRT_MAX;
|
||||
sndBank->aliasIndex[freeIdx].next = std::numeric_limits<unsigned short>::max();
|
||||
setAliasIndexList[i] = true;
|
||||
}
|
||||
|
||||
delete[] setAliasIndexList;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -436,8 +427,7 @@ bool LoadSoundDuckList(ISearchPath* searchPath, MemoryManager* memory, SndBank*
|
||||
|
||||
for (auto& valueJson : duckJson["values"])
|
||||
{
|
||||
auto index =
|
||||
GetValueIndex(valueJson["duckGroup"].get<std::string>(), ObjConstants::SOUND_DUCK_GROUPS.data(), ObjConstants::SOUND_DUCK_GROUPS.size());
|
||||
auto index = GetValueIndex(valueJson["duckGroup"].get<std::string>(), SOUND_DUCK_GROUPS, std::extent_v<decltype(SOUND_DUCK_GROUPS)>);
|
||||
|
||||
duck->attenuation[index] = valueJson["attenuation"].get<float>();
|
||||
duck->filter[index] = valueJson["filter"].get<float>();
|
||||
@ -550,14 +540,15 @@ bool AssetLoaderSoundBank::LoadFromRaw(
|
||||
// write the output linked sound bank
|
||||
if (sablWriter)
|
||||
{
|
||||
auto size = static_cast<size_t>(sablWriter->Write());
|
||||
size_t dataSize = 0u;
|
||||
auto result = sablWriter->Write(dataSize);
|
||||
sablStream->close();
|
||||
|
||||
if (size != UINT32_MAX)
|
||||
if (result)
|
||||
{
|
||||
sndBank->loadedAssets.dataSize = size;
|
||||
sndBank->loadedAssets.data = static_cast<SndChar2048*>(memory->Alloc(size));
|
||||
memset(sndBank->loadedAssets.data, 0, size);
|
||||
sndBank->loadedAssets.dataSize = dataSize;
|
||||
sndBank->loadedAssets.data = static_cast<SndChar2048*>(memory->Alloc(dataSize));
|
||||
memset(sndBank->loadedAssets.data, 0, dataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -569,10 +560,11 @@ bool AssetLoaderSoundBank::LoadFromRaw(
|
||||
// write the output streamed sound bank
|
||||
if (sabsWriter)
|
||||
{
|
||||
auto size = static_cast<size_t>(sabsWriter->Write());
|
||||
size_t dataSize = 0u;
|
||||
auto result = sabsWriter->Write(dataSize);
|
||||
sabsStream->close();
|
||||
|
||||
if (size == UINT32_MAX)
|
||||
if (!result)
|
||||
{
|
||||
std::cerr << "Streamed Sound Bank for " << assetName << " failed to generate. Please check your build files." << std::endl;
|
||||
return false;
|
||||
|
@ -2,12 +2,11 @@
|
||||
|
||||
#include "Crypto.h"
|
||||
#include "ObjContainer/SoundBank/SoundBankTypes.h"
|
||||
#include "Sound/WavTypes.h"
|
||||
#include "Sound/FlacDecoder.h"
|
||||
#include "Sound/WavTypes.h"
|
||||
#include "Utils/Alignment.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
@ -78,8 +77,8 @@ public:
|
||||
|
||||
void AlignToChunk()
|
||||
{
|
||||
if ((m_current_offset & 0xF) != 0)
|
||||
Pad(0x10 - (m_current_offset & 0xF));
|
||||
if (m_current_offset % 16 != 0)
|
||||
Pad(16 - (m_current_offset % 16));
|
||||
}
|
||||
|
||||
void WriteHeader()
|
||||
@ -91,7 +90,8 @@ public:
|
||||
SoundAssetBankChecksum checksum{};
|
||||
memset(&checksum, 0xCC, sizeof(SoundAssetBankChecksum));
|
||||
|
||||
SoundAssetBankHeader header{MAGIC,
|
||||
SoundAssetBankHeader header{
|
||||
MAGIC,
|
||||
VERSION,
|
||||
sizeof(SoundAssetBankEntry),
|
||||
sizeof(SoundAssetBankChecksum),
|
||||
@ -102,7 +102,8 @@ public:
|
||||
m_total_size,
|
||||
m_entry_section_offset,
|
||||
m_checksum_section_offset,
|
||||
checksum};
|
||||
checksum,
|
||||
};
|
||||
|
||||
strncpy(header.dependencies, m_file_name.data(), header.dependencySize);
|
||||
|
||||
@ -169,7 +170,7 @@ public:
|
||||
static_cast<size_t>(m_current_offset),
|
||||
decoder->GetFrameCount(),
|
||||
frameRateIndex,
|
||||
decoder->GetNumChannels(),
|
||||
static_cast<unsigned char>(decoder->GetNumChannels()),
|
||||
sound.looping,
|
||||
8,
|
||||
};
|
||||
@ -192,7 +193,8 @@ public:
|
||||
auto lastEntry = m_entries.rbegin();
|
||||
if (!sound.streamed && lastEntry->frameRateIndex != 6)
|
||||
{
|
||||
std::cout << "WARNING: Loaded sound \"" << soundFilePath << "\" should have a framerate of 48000 but doesn't. This sound may not work on all games!" << std::endl;
|
||||
std::cout << "WARNING: Loaded sound \"" << soundFilePath
|
||||
<< "\" should have a framerate of 48000 but doesn't. This sound may not work on all games!" << std::endl;
|
||||
}
|
||||
|
||||
// calculate checksum
|
||||
@ -240,12 +242,12 @@ public:
|
||||
AlignToChunk();
|
||||
}
|
||||
|
||||
std::int64_t Write() override
|
||||
bool Write(size_t& dataSize) override
|
||||
{
|
||||
if (!WriteEntries())
|
||||
{
|
||||
std::cerr << "An error occurred writing the sound bank entires. Please check output." << std::endl;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
WriteEntryList();
|
||||
@ -259,11 +261,12 @@ public:
|
||||
if (m_current_offset > UINT32_MAX)
|
||||
{
|
||||
std::cerr << "Sound bank files must be under 4GB. Please reduce the number of sounds being written!" << std::endl;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// return the total size for the sound asset data
|
||||
return m_entry_section_offset - DATA_OFFSET;
|
||||
// output the total size for the sound asset data
|
||||
dataSize = static_cast<size_t>(m_entry_section_offset - DATA_OFFSET);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
SoundBankWriter& operator=(SoundBankWriter&& other) noexcept = default;
|
||||
|
||||
virtual void AddSound(const std::string& soundFilePath, unsigned int soundId, bool looping = false, bool streamed = false) = 0;
|
||||
virtual std::int64_t Write() = 0;
|
||||
virtual bool Write(size_t& dataSize) = 0;
|
||||
|
||||
static std::unique_ptr<SoundBankWriter> Create(const std::string& fileName, std::ostream& stream, ISearchPath* assetSearchPath);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/SoundConstantsT6.h"
|
||||
#include "ObjContainer/SoundBank/SoundBank.h"
|
||||
#include "Sound/WavWriter.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
@ -123,8 +123,8 @@ namespace
|
||||
std::unordered_map<unsigned int, std::string> CreateCurvesMap()
|
||||
{
|
||||
std::unordered_map<unsigned int, std::string> result;
|
||||
for (auto i = 0u; i < ObjConstants::SOUND_CURVES.size(); i++)
|
||||
result.emplace(T6::Common::SND_HashName(ObjConstants::SOUND_CURVES[i].data()), ObjConstants::SOUND_CURVES[i]);
|
||||
for (auto i = 0u; i < std::extent_v<decltype(SOUND_CURVES)>; i++)
|
||||
result.emplace(T6::Common::SND_HashName(SOUND_CURVES[i].data()), SOUND_CURVES[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn((alias->secondaryname && *alias->secondaryname) ? alias->secondaryname : "");
|
||||
|
||||
// group
|
||||
stream.WriteColumn(ObjConstants::SOUND_GROUPS[alias->flags.volumeGroup]);
|
||||
stream.WriteColumn(SOUND_GROUPS[alias->flags.volumeGroup]);
|
||||
|
||||
// vol_min
|
||||
stream.WriteColumn(std::to_string(alias->volMin));
|
||||
@ -247,28 +247,28 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn(std::to_string(alias->distReverbMax));
|
||||
|
||||
// volume_falloff_curve
|
||||
stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.volumeFalloffCurve]);
|
||||
stream.WriteColumn(SOUND_CURVES[alias->flags.volumeFalloffCurve]);
|
||||
|
||||
// reverb_falloff_curve
|
||||
stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.reverbFalloffCurve]);
|
||||
stream.WriteColumn(SOUND_CURVES[alias->flags.reverbFalloffCurve]);
|
||||
|
||||
// volume_min_falloff_curve
|
||||
stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.volumeMinFalloffCurve]);
|
||||
stream.WriteColumn(SOUND_CURVES[alias->flags.volumeMinFalloffCurve]);
|
||||
|
||||
// reverb_min_falloff_curve"
|
||||
stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.reverbMinFalloffCurve]);
|
||||
stream.WriteColumn(SOUND_CURVES[alias->flags.reverbMinFalloffCurve]);
|
||||
|
||||
// limit_count
|
||||
stream.WriteColumn(std::to_string(alias->limitCount));
|
||||
|
||||
// limit_type
|
||||
stream.WriteColumn(ObjConstants::SOUND_LIMIT_TYPES[alias->flags.limitType]);
|
||||
stream.WriteColumn(SOUND_LIMIT_TYPES[alias->flags.limitType]);
|
||||
|
||||
// entity_limit_count
|
||||
stream.WriteColumn(std::to_string(alias->entityLimitCount));
|
||||
|
||||
// entity_limit_type
|
||||
stream.WriteColumn(ObjConstants::SOUND_LIMIT_TYPES[alias->flags.entityLimitType]);
|
||||
stream.WriteColumn(SOUND_LIMIT_TYPES[alias->flags.entityLimitType]);
|
||||
|
||||
// pitch_min
|
||||
stream.WriteColumn(std::to_string(alias->pitchMin));
|
||||
@ -295,13 +295,13 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn("");
|
||||
|
||||
// type
|
||||
stream.WriteColumn(ObjConstants::SOUND_LOAD_TYPES[alias->flags.loadType]);
|
||||
stream.WriteColumn(SOUND_LOAD_TYPES[alias->flags.loadType]);
|
||||
|
||||
// loop
|
||||
stream.WriteColumn(alias->flags.looping == T6::SA_NON_LOOPING ? "nonlooping" : "looping");
|
||||
|
||||
// randomize_type
|
||||
stream.WriteColumn(ObjConstants::SOUND_RANDOMIZE_TYPES[std::min(alias->flags.randomizeType, 3u)]);
|
||||
stream.WriteColumn(SOUND_RANDOMIZE_TYPES[std::min(alias->flags.randomizeType, 3u)]);
|
||||
|
||||
// probability",
|
||||
stream.WriteColumn(std::to_string(alias->probability));
|
||||
@ -316,7 +316,7 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn(FindNameForDuck(alias->duck, bank));
|
||||
|
||||
// duck_group",
|
||||
stream.WriteColumn(ObjConstants::SOUND_DUCK_GROUPS[alias->duckGroup]);
|
||||
stream.WriteColumn(SOUND_DUCK_GROUPS[alias->duckGroup]);
|
||||
|
||||
// pan",
|
||||
stream.WriteColumn(alias->flags.panType == SA_PAN_2D ? "2d" : "3d");
|
||||
@ -346,7 +346,7 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn(alias->flags.distanceLpf ? "yes" : "no");
|
||||
|
||||
// move_type",
|
||||
stream.WriteColumn(ObjConstants::SOUND_MOVE_TYPES[alias->flags.fluxType]);
|
||||
stream.WriteColumn(SOUND_MOVE_TYPES[alias->flags.fluxType]);
|
||||
|
||||
// move_time",
|
||||
stream.WriteColumn(std::to_string(alias->fluxTime));
|
||||
@ -397,7 +397,7 @@ class AssetDumperSndBank::Internal
|
||||
stream.WriteColumn(alias->flags.stopOnDeath ? "yes" : "no");
|
||||
|
||||
// bus",
|
||||
stream.WriteColumn(ObjConstants::SOUND_BUS_IDS[alias->flags.busType]);
|
||||
stream.WriteColumn(SOUND_BUS_IDS[alias->flags.busType]);
|
||||
|
||||
// snapshot",
|
||||
stream.WriteColumn("");
|
||||
@ -630,7 +630,7 @@ class AssetDumperSndBank::Internal
|
||||
for (auto i = 0u; i < 32u; i++)
|
||||
{
|
||||
values.push_back({
|
||||
{"duckGroup", ObjConstants::SOUND_DUCK_GROUPS[i]},
|
||||
{"duckGroup", SOUND_DUCK_GROUPS[i]},
|
||||
{"attenuation", duck.attenuation[i] },
|
||||
{"filter", duck.filter[i] }
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <Sound/WavTypes.h>
|
||||
#include <ostream>
|
||||
#include "Sound/WavTypes.h"
|
||||
|
||||
class WavWriter
|
||||
{
|
||||
|
@ -104,13 +104,13 @@ namespace utils
|
||||
|
||||
std::vector<std::string> StringSplit(const std::string& str, const char delim)
|
||||
{
|
||||
std::vector<std::string> strings{};
|
||||
std::vector<std::string> strings;
|
||||
std::istringstream stream(str);
|
||||
|
||||
std::string s;
|
||||
while (std::getline(stream, s, delim))
|
||||
{
|
||||
strings.push_back(s);
|
||||
strings.emplace_back(std::move(s));
|
||||
}
|
||||
|
||||
return strings;
|
||||
|
Loading…
x
Reference in New Issue
Block a user