From 177400159883b19fc5d6b07647af30fcd5d51fc7 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 12:13:22 -0700 Subject: [PATCH 01/17] Use int16_t max for pitch dumping and loading --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 2 +- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 76ddc2ce..5834efc6 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -142,7 +142,7 @@ namespace return false; } - value = static_cast(CentToHertz(centValue) * static_cast(std::numeric_limits::max())); + value = static_cast(CentToHertz(centValue) * static_cast(std::numeric_limits::max())); return true; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index b7cea999..ec79fe34 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -404,7 +404,7 @@ namespace void WriteColumnPitchHertz(CsvOutputStream& stream, const uint16_t value) { - const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); + const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); const auto cents = std::clamp(HertzToCents(hertz), -2400.0f, 1200.0f); stream.WriteColumn(std::format("{:.4g}", cents)); } From ff02491e085fdac27ff923e5e9894ba8efa046a5 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 12:31:45 -0700 Subject: [PATCH 02/17] Fix space being prepended to randomize type --- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index ec79fe34..a47eae78 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -372,7 +372,7 @@ namespace { assert(enumValueCount <= 32u); std::ostringstream ss; - auto first = false; + auto first = true; for (auto i = 0u; i < enumValueCount; i++) { const auto flagValue = 1u << i; From 2aac08a62d903906059a6a8e9654a94f213a19c3 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 14:59:56 -0700 Subject: [PATCH 03/17] Reorganize sound alias columns --- .../T6/AssetLoaders/AssetLoaderSoundBank.cpp | 226 +++++++------- .../T6/AssetDumpers/AssetDumperSndBank.cpp | 292 +++++++++--------- 2 files changed, 259 insertions(+), 259 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 5834efc6..6f65f6b3 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -383,126 +383,126 @@ namespace return headerRow.RequireIndexForHeader("Name", m_name) && headerRow.RequireIndexForHeader("FileSource", m_file_source) && headerRow.RequireIndexForHeader("Secondary", m_secondary) - && headerRow.RequireIndexForHeader("Subtitle", m_subtitle) + && headerRow.RequireIndexForHeader("Storage", m_storage) + && headerRow.RequireIndexForHeader("Bus", m_bus) + && headerRow.RequireIndexForHeader("VolumeGroup", m_volume_group) + && headerRow.RequireIndexForHeader("DuckGroup", m_duck_group) + && headerRow.RequireIndexForHeader("Duck", m_duck) + && headerRow.RequireIndexForHeader("ReverbSend", m_reverb_send) + && headerRow.RequireIndexForHeader("CenterSend", m_center_send) && headerRow.RequireIndexForHeader("VolMin", m_vol_min) && headerRow.RequireIndexForHeader("VolMax", m_vol_max) - && headerRow.RequireIndexForHeader("PitchMin", m_pitch_min) - && headerRow.RequireIndexForHeader("PitchMax", m_pitch_max) && headerRow.RequireIndexForHeader("DistMin", m_dist_min) && headerRow.RequireIndexForHeader("DistMaxDry", m_dist_max_dry) && headerRow.RequireIndexForHeader("DistMaxWet", m_dist_max_wet) - && headerRow.RequireIndexForHeader("Probability", m_probability) - && headerRow.RequireIndexForHeader("EnvelopMin", m_envelop_min) - && headerRow.RequireIndexForHeader("EnvelopMax", m_envelop_max) - && headerRow.RequireIndexForHeader("EnvelopPercentage", m_envelop_percentage) - && headerRow.RequireIndexForHeader("CenterSend", m_center_send) - && headerRow.RequireIndexForHeader("ReverbSend", m_reverb_send) - && headerRow.RequireIndexForHeader("StartDelay", m_start_delay) - && headerRow.RequireIndexForHeader("PriorityThresholdMin", m_priority_threshold_min) - && headerRow.RequireIndexForHeader("PriorityThresholdMax", m_priority_threshold_max) - && headerRow.RequireIndexForHeader("OcclusionLevel", m_occlusion_level) - && headerRow.RequireIndexForHeader("FluxTime", m_flux_time) - && headerRow.RequireIndexForHeader("Duck", m_duck) - && headerRow.RequireIndexForHeader("PriorityMin", m_priority_min) - && headerRow.RequireIndexForHeader("PriorityMax", m_priority_max) - && headerRow.RequireIndexForHeader("LimitCount", m_limit_count) - && headerRow.RequireIndexForHeader("EntityLimitCount", m_entity_limit_count) && headerRow.RequireIndexForHeader("DryMinCurve", m_dry_min_curve) && headerRow.RequireIndexForHeader("DryMaxCurve", m_dry_max_curve) && headerRow.RequireIndexForHeader("WetMinCurve", m_wet_min_curve) && headerRow.RequireIndexForHeader("WetMaxCurve", m_wet_max_curve) + && headerRow.RequireIndexForHeader("LimitCount", m_limit_count) + && headerRow.RequireIndexForHeader("EntityLimitCount", m_entity_limit_count) + && headerRow.RequireIndexForHeader("LimitType", m_limit_type) + && headerRow.RequireIndexForHeader("EntityLimitType", m_entity_limit_type) + && headerRow.RequireIndexForHeader("PitchMin", m_pitch_min) + && headerRow.RequireIndexForHeader("PitchMax", m_pitch_max) + && headerRow.RequireIndexForHeader("PriorityMin", m_priority_min) + && headerRow.RequireIndexForHeader("PriorityMax", m_priority_max) + && headerRow.RequireIndexForHeader("PriorityThresholdMin", m_priority_threshold_min) + && headerRow.RequireIndexForHeader("PriorityThresholdMax", m_priority_threshold_max) + && headerRow.RequireIndexForHeader("PanType", m_pan_type) && headerRow.RequireIndexForHeader("Pan", m_pan) - && headerRow.RequireIndexForHeader("DuckGroup", m_duck_group) + && headerRow.RequireIndexForHeader("Looping", m_looping) + && headerRow.RequireIndexForHeader("RandomizeType", m_randomize_type) + && headerRow.RequireIndexForHeader("Probability", m_probability) + && headerRow.RequireIndexForHeader("StartDelay", m_start_delay) + && headerRow.RequireIndexForHeader("EnvelopMin", m_envelop_min) + && headerRow.RequireIndexForHeader("EnvelopMax", m_envelop_max) + && headerRow.RequireIndexForHeader("EnvelopPercentage", m_envelop_percentage) + && headerRow.RequireIndexForHeader("OcclusionLevel", m_occlusion_level) + && headerRow.RequireIndexForHeader("IsBig", m_is_big) + && headerRow.RequireIndexForHeader("DistanceLpf", m_distance_lpf) + && headerRow.RequireIndexForHeader("FluxType", m_flux_type) + && headerRow.RequireIndexForHeader("FluxTime", m_flux_time) + && headerRow.RequireIndexForHeader("Subtitle", m_subtitle) + && headerRow.RequireIndexForHeader("Doppler", m_doppler) && headerRow.RequireIndexForHeader("ContextType", m_context_type) && headerRow.RequireIndexForHeader("ContextValue", m_context_value) + && headerRow.RequireIndexForHeader("Timescale", m_timescale) + && headerRow.RequireIndexForHeader("IsMusic", m_is_music) + && headerRow.RequireIndexForHeader("IsCinematic", m_is_cinematic) && headerRow.RequireIndexForHeader("FadeIn", m_fade_in) && headerRow.RequireIndexForHeader("FadeOut", m_fade_out) + && headerRow.RequireIndexForHeader("Pauseable", m_pauseable) + && headerRow.RequireIndexForHeader("StopOnEntDeath", m_stop_on_ent_death) && headerRow.RequireIndexForHeader("StopOnPlay", m_stop_on_play) && headerRow.RequireIndexForHeader("DopplerScale", m_doppler_scale) && headerRow.RequireIndexForHeader("FutzPatch", m_futz_patch) - && headerRow.RequireIndexForHeader("LimitType", m_limit_type) - && headerRow.RequireIndexForHeader("EntityLimitType", m_entity_limit_type) - && headerRow.RequireIndexForHeader("RandomizeType", m_randomize_type) - && headerRow.RequireIndexForHeader("FluxType", m_flux_type) - && headerRow.RequireIndexForHeader("Storage", m_storage) - && headerRow.RequireIndexForHeader("VolumeGroup", m_volume_group) - && headerRow.RequireIndexForHeader("DistanceLpf", m_distance_lpf) - && headerRow.RequireIndexForHeader("Doppler", m_doppler) - && headerRow.RequireIndexForHeader("IsBig", m_is_big) - && headerRow.RequireIndexForHeader("Looping", m_looping) - && headerRow.RequireIndexForHeader("PanType", m_pan_type) - && headerRow.RequireIndexForHeader("IsMusic", m_is_music) - && headerRow.RequireIndexForHeader("Timescale", m_timescale) - && headerRow.RequireIndexForHeader("Pauseable", m_pauseable) - && headerRow.RequireIndexForHeader("StopOnEntDeath", m_stop_on_ent_death) - && headerRow.RequireIndexForHeader("Bus", m_bus) && headerRow.RequireIndexForHeader("VoiceLimit", m_voice_limit) && headerRow.RequireIndexForHeader("IgnoreMaxDist", m_ignore_max_dist) - && headerRow.RequireIndexForHeader("NeverPlayTwice", m_never_play_twice) - && headerRow.RequireIndexForHeader("IsCinematic", m_is_cinematic); + && headerRow.RequireIndexForHeader("NeverPlayTwice", m_never_play_twice); // clang-format on } unsigned m_name; unsigned m_file_source; unsigned m_secondary; - unsigned m_subtitle; + unsigned m_storage; + unsigned m_bus; + unsigned m_volume_group; + unsigned m_duck_group; + unsigned m_duck; + unsigned m_reverb_send; + unsigned m_center_send; unsigned m_vol_min; unsigned m_vol_max; - unsigned m_pitch_min; - unsigned m_pitch_max; unsigned m_dist_min; unsigned m_dist_max_dry; unsigned m_dist_max_wet; - unsigned m_probability; - unsigned m_envelop_min; - unsigned m_envelop_max; - unsigned m_envelop_percentage; - unsigned m_center_send; - unsigned m_reverb_send; - unsigned m_start_delay; - unsigned m_priority_threshold_min; - unsigned m_priority_threshold_max; - unsigned m_occlusion_level; - unsigned m_flux_time; - unsigned m_duck; - unsigned m_priority_min; - unsigned m_priority_max; - unsigned m_limit_count; - unsigned m_entity_limit_count; unsigned m_dry_min_curve; unsigned m_dry_max_curve; unsigned m_wet_min_curve; unsigned m_wet_max_curve; + unsigned m_limit_count; + unsigned m_entity_limit_count; + unsigned m_limit_type; + unsigned m_entity_limit_type; + unsigned m_pitch_min; + unsigned m_pitch_max; + unsigned m_priority_min; + unsigned m_priority_max; + unsigned m_priority_threshold_min; + unsigned m_priority_threshold_max; + unsigned m_pan_type; unsigned m_pan; - unsigned m_duck_group; + unsigned m_looping; + unsigned m_randomize_type; + unsigned m_probability; + unsigned m_start_delay; + unsigned m_envelop_min; + unsigned m_envelop_max; + unsigned m_envelop_percentage; + unsigned m_occlusion_level; + unsigned m_is_big; + unsigned m_distance_lpf; + unsigned m_flux_type; + unsigned m_flux_time; + unsigned m_subtitle; + unsigned m_doppler; unsigned m_context_type; unsigned m_context_value; + unsigned m_timescale; + unsigned m_is_music; + unsigned m_is_cinematic; unsigned m_fade_in; unsigned m_fade_out; + unsigned m_pauseable; + unsigned m_stop_on_ent_death; unsigned m_stop_on_play; unsigned m_doppler_scale; unsigned m_futz_patch; - unsigned m_limit_type; - unsigned m_entity_limit_type; - unsigned m_randomize_type; - unsigned m_flux_type; - unsigned m_storage; - unsigned m_volume_group; - unsigned m_distance_lpf; - unsigned m_doppler; - unsigned m_is_big; - unsigned m_looping; - unsigned m_pan_type; - unsigned m_is_music; - unsigned m_timescale; - unsigned m_pauseable; - unsigned m_stop_on_ent_death; - unsigned m_bus; unsigned m_voice_limit; unsigned m_ignore_max_dist; unsigned m_never_play_twice; - unsigned m_is_cinematic; }; bool LoadSoundAlias(SndAlias& alias, @@ -537,63 +537,63 @@ namespace // clang-format off const auto couldReadSoundAlias = ReadColumnString(row, headers.m_secondary, alias.secondaryName, memory) - && ReadColumnString(row, headers.m_subtitle, alias.subtitle, memory) + && ReadColumnEnum(headerRow, row, headers.m_storage, rowIndex, storage, SOUND_LOAD_TYPES) + && ReadColumnEnum(headerRow, row, headers.m_bus, rowIndex, busType, SOUND_BUS_IDS) + && ReadColumnEnum(headerRow, row, headers.m_volume_group, rowIndex, volumeGroup, SOUND_GROUPS) + && ReadColumnEnum(headerRow, row, headers.m_duck_group, rowIndex, alias.duckGroup, SOUND_DUCK_GROUPS) + && ReadColumnHash(row, headers.m_duck, alias.duck) + && ReadColumnVolumeDbspl(headerRow, row, headers.m_reverb_send, rowIndex, alias.reverbSend) + && ReadColumnVolumeDbspl(headerRow, row, headers.m_center_send, rowIndex, alias.centerSend) && ReadColumnVolumeDbspl(headerRow, row, headers.m_vol_min, rowIndex, alias.volMin) && ReadColumnVolumeDbspl(headerRow, row, headers.m_vol_max, rowIndex, alias.volMax) - && ReadColumnPitchCents(headerRow, row, headers.m_pitch_min, rowIndex, alias.pitchMin) - && ReadColumnPitchCents(headerRow, row, headers.m_pitch_max, rowIndex, alias.pitchMax) && ReadColumnUInt16(headerRow, row, headers.m_dist_min, rowIndex, alias.distMin) && ReadColumnUInt16(headerRow, row, headers.m_dist_max_dry, rowIndex, alias.distMax) && ReadColumnUInt16(headerRow, row, headers.m_dist_max_wet, rowIndex, alias.distReverbMax) - && ReadColumnNormByte(headerRow, row, headers.m_probability, rowIndex, alias.probability) - && ReadColumnUInt16(headerRow, row, headers.m_envelop_min, rowIndex, alias.envelopMin) - && ReadColumnUInt16(headerRow, row, headers.m_envelop_max, rowIndex, alias.envelopMax) - && ReadColumnVolumeDbspl(headerRow, row, headers.m_envelop_percentage, rowIndex, alias.envelopPercentage) - && ReadColumnVolumeDbspl(headerRow, row, headers.m_center_send, rowIndex, alias.centerSend) - && ReadColumnVolumeDbspl(headerRow, row, headers.m_reverb_send, rowIndex, alias.reverbSend) - && ReadColumnUInt16(headerRow, row, headers.m_start_delay, rowIndex, alias.startDelay) - && ReadColumnNormByte(headerRow, row, headers.m_priority_threshold_min, rowIndex, alias.minPriorityThreshold) - && ReadColumnNormByte(headerRow, row, headers.m_priority_threshold_max, rowIndex, alias.maxPriorityThreshold) - && ReadColumnNormByte(headerRow, row, headers.m_occlusion_level, rowIndex, alias.occlusionLevel) - && ReadColumnUInt16(headerRow, row, headers.m_flux_time, rowIndex, alias.fluxTime) - && ReadColumnHash(row, headers.m_duck, alias.duck) - && ReadColumnUInt8(headerRow, row, headers.m_priority_min, rowIndex, alias.minPriority, 0u, 128u) - && ReadColumnUInt8(headerRow, row, headers.m_priority_max, rowIndex, alias.maxPriority, 0u, 128u) - && ReadColumnUInt8(headerRow, row, headers.m_limit_count, rowIndex, alias.limitCount, 0u, 128u) - && ReadColumnUInt8(headerRow, row, headers.m_entity_limit_count, rowIndex, alias.entityLimitCount, 0u, 128u) && ReadColumnEnum(headerRow, row, headers.m_dry_min_curve, rowIndex, dryMinCurve, SOUND_CURVES) && ReadColumnEnum(headerRow, row, headers.m_dry_max_curve, rowIndex, dryMaxCurve, SOUND_CURVES) && ReadColumnEnum(headerRow, row, headers.m_wet_min_curve, rowIndex, wetMinCurve, SOUND_CURVES) && ReadColumnEnum(headerRow, row, headers.m_wet_max_curve, rowIndex, wetMaxCurve, SOUND_CURVES) + && ReadColumnUInt8(headerRow, row, headers.m_limit_count, rowIndex, alias.limitCount, 0u, 128u) + && ReadColumnUInt8(headerRow, row, headers.m_entity_limit_count, rowIndex, alias.entityLimitCount, 0u, 128u) + && ReadColumnEnum(headerRow, row, headers.m_limit_type, rowIndex, limitType, SOUND_LIMIT_TYPES) + && ReadColumnEnum(headerRow, row, headers.m_entity_limit_type, rowIndex, entityLimitType, SOUND_LIMIT_TYPES) + && ReadColumnPitchCents(headerRow, row, headers.m_pitch_min, rowIndex, alias.pitchMin) + && ReadColumnPitchCents(headerRow, row, headers.m_pitch_max, rowIndex, alias.pitchMax) + && ReadColumnUInt8(headerRow, row, headers.m_priority_min, rowIndex, alias.minPriority, 0u, 128u) + && ReadColumnUInt8(headerRow, row, headers.m_priority_max, rowIndex, alias.maxPriority, 0u, 128u) + && ReadColumnNormByte(headerRow, row, headers.m_priority_threshold_min, rowIndex, alias.minPriorityThreshold) + && ReadColumnNormByte(headerRow, row, headers.m_priority_threshold_max, rowIndex, alias.maxPriorityThreshold) + && ReadColumnEnum(headerRow, row, headers.m_pan_type, rowIndex, panType, SOUND_PAN_TYPES) && ReadColumnEnum(headerRow, row, headers.m_pan, rowIndex, alias.pan, SOUND_PANS) - && ReadColumnEnum(headerRow, row, headers.m_duck_group, rowIndex, alias.duckGroup, SOUND_DUCK_GROUPS) + && ReadColumnEnum(headerRow, row, headers.m_looping, rowIndex, looping, SOUND_LOOP_TYPES) + && ReadColumnEnumFlags(headerRow, row, headers.m_randomize_type, rowIndex, randomizeType, SOUND_RANDOMIZE_TYPES) + && ReadColumnNormByte(headerRow, row, headers.m_probability, rowIndex, alias.probability) + && ReadColumnUInt16(headerRow, row, headers.m_start_delay, rowIndex, alias.startDelay) + && ReadColumnUInt16(headerRow, row, headers.m_envelop_min, rowIndex, alias.envelopMin) + && ReadColumnUInt16(headerRow, row, headers.m_envelop_max, rowIndex, alias.envelopMax) + && ReadColumnVolumeDbspl(headerRow, row, headers.m_envelop_percentage, rowIndex, alias.envelopPercentage) + && ReadColumnNormByte(headerRow, row, headers.m_occlusion_level, rowIndex, alias.occlusionLevel) + && ReadColumnEnum(headerRow, row, headers.m_is_big, rowIndex, isBig, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_distance_lpf, rowIndex, distanceLpf, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_flux_type, rowIndex, fluxType, SOUND_MOVE_TYPES) + && ReadColumnUInt16(headerRow, row, headers.m_flux_time, rowIndex, alias.fluxTime) + && ReadColumnString(row, headers.m_subtitle, alias.subtitle, memory) + && ReadColumnEnum(headerRow, row, headers.m_doppler, rowIndex, doppler, SOUND_NO_YES) && ReadColumnHash(row, headers.m_context_type, alias.contextType) && ReadColumnHash(row, headers.m_context_value, alias.contextValue) + && ReadColumnEnum(headerRow, row, headers.m_timescale, rowIndex, timescale, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_is_music, rowIndex, isMusic, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_is_cinematic, rowIndex, isCinematic, SOUND_NO_YES) && ReadColumnInt16(headerRow, row, headers.m_fade_in, rowIndex, alias.fadeIn, 0) && ReadColumnInt16(headerRow, row, headers.m_fade_out, rowIndex, alias.fadeOut, 0) + && ReadColumnEnum(headerRow, row, headers.m_pauseable, rowIndex, pausable, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_stop_on_ent_death, rowIndex, stopOnEntDeath, SOUND_NO_YES) && ReadColumnHash(row, headers.m_stop_on_play, alias.stopOnPlay) && ReadColumnInt16(headerRow, row, headers.m_doppler_scale, rowIndex, alias.dopplerScale, -100, 100) && ReadColumnHash(row, headers.m_futz_patch, alias.futzPatch) - && ReadColumnEnum(headerRow, row, headers.m_limit_type, rowIndex, limitType, SOUND_LIMIT_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_entity_limit_type, rowIndex, entityLimitType, SOUND_LIMIT_TYPES) - && ReadColumnEnumFlags(headerRow, row, headers.m_randomize_type, rowIndex, randomizeType, SOUND_RANDOMIZE_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_flux_type, rowIndex, fluxType, SOUND_MOVE_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_storage, rowIndex, storage, SOUND_LOAD_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_volume_group, rowIndex, volumeGroup, SOUND_GROUPS) - && ReadColumnEnum(headerRow, row, headers.m_distance_lpf, rowIndex, distanceLpf, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_doppler, rowIndex, doppler, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_is_big, rowIndex, isBig, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_looping, rowIndex, looping, SOUND_LOOP_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_pan_type, rowIndex, panType, SOUND_PAN_TYPES) - && ReadColumnEnum(headerRow, row, headers.m_is_music, rowIndex, isMusic, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_timescale, rowIndex, timescale, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_pauseable, rowIndex, pausable, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_stop_on_ent_death, rowIndex, stopOnEntDeath, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_bus, rowIndex, busType, SOUND_BUS_IDS) && ReadColumnEnum(headerRow, row, headers.m_voice_limit, rowIndex, voiceLimit, SOUND_NO_YES) && ReadColumnEnum(headerRow, row, headers.m_ignore_max_dist, rowIndex, ignoreMaxDist, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_never_play_twice, rowIndex, neverPlayTwice, SOUND_NO_YES) - && ReadColumnEnum(headerRow, row, headers.m_is_cinematic, rowIndex, isCinematic, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_never_play_twice, rowIndex, neverPlayTwice, SOUND_NO_YES) ; // clang-format on diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index a47eae78..88e29e1d 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -26,63 +26,63 @@ namespace "Name", "FileSource", "Secondary", - "Subtitle", + "Storage", + "Bus", + "VolumeGroup", + "DuckGroup", + "Duck", + "ReverbSend", + "CenterSend", "VolMin", "VolMax", - "PitchMin", - "PitchMax", "DistMin", "DistMaxDry", "DistMaxWet", - "Probability", - "EnvelopMin", - "EnvelopMax", - "EnvelopPercentage", - "CenterSend", - "ReverbSend", - "StartDelay", - "PriorityThresholdMin", - "PriorityThresholdMax", - "OcclusionLevel", - "FluxTime", - "Duck", - "PriorityMin", - "PriorityMax", - "LimitCount", - "EntityLimitCount", "DryMinCurve", "DryMaxCurve", "WetMinCurve", "WetMaxCurve", + "LimitCount", + "EntityLimitCount", + "LimitType", + "EntityLimitType", + "PitchMin", + "PitchMax", + "PriorityMin", + "PriorityMax", + "PriorityThresholdMin", + "PriorityThresholdMax", + "PanType", "Pan", - "DuckGroup", + "Looping", + "RandomizeType", + "Probability", + "StartDelay", + "EnvelopMin", + "EnvelopMax", + "EnvelopPercentage", + "OcclusionLevel", + "IsBig", + "DistanceLpf", + "FluxType", + "FluxTime", + "Subtitle", + "Doppler", "ContextType", "ContextValue", + "Timescale", + "IsMusic", + "IsCinematic", "FadeIn", "FadeOut", + "Pauseable", + "StopOnEntDeath", "StopOnPlay", "DopplerScale", "FutzPatch", - "LimitType", - "EntityLimitType", - "RandomizeType", - "FluxType", - "Storage", - "VolumeGroup", - "DistanceLpf", - "Doppler", - "IsBig", - "Looping", - "PanType", - "IsMusic", - "Timescale", - "Pauseable", - "StopOnEntDeath", - "Bus", "VoiceLimit", "IgnoreMaxDist", "NeverPlayTwice", - "IsCinematic", }; const std::string REVERB_HEADERS[]{ @@ -455,8 +455,26 @@ namespace // Secondary WriteColumnString(stream, alias.secondaryName); - // Subtitle - WriteColumnString(stream, alias.subtitle); + // Storage + WriteColumnEnum(stream, alias.flags.loadType, SOUND_LOAD_TYPES); + + // Bus + WriteColumnEnum(stream, alias.flags.busType, SOUND_BUS_IDS); + + // VolumeGroup + WriteColumnEnum(stream, alias.flags.volumeGroup, SOUND_GROUPS); + + // DuckGroup + WriteColumnEnum(stream, alias.duckGroup, SOUND_DUCK_GROUPS); + + // Duck + WriteColumnWithDuckHash(stream, hashes, alias.duck); + + // ReverbSend + WriteColumnVolumeLinear(stream, alias.reverbSend); + + // CenterSend + WriteColumnVolumeLinear(stream, alias.centerSend); // VolMin WriteColumnVolumeLinear(stream, alias.volMin); @@ -464,12 +482,6 @@ namespace // VolMax WriteColumnVolumeLinear(stream, alias.volMax); - // PitchMin - WriteColumnPitchHertz(stream, alias.pitchMin); - - // PitchMax - WriteColumnPitchHertz(stream, alias.pitchMax); - // DistMin WriteColumnIntegral(stream, alias.distMin); @@ -479,54 +491,6 @@ namespace // DistMaxWet WriteColumnIntegral(stream, alias.distReverbMax); - // Probability - WriteColumnNormByte(stream, alias.probability); - - // EnvelopMin - WriteColumnIntegral(stream, alias.envelopMin); - - // EnvelopMax - WriteColumnIntegral(stream, alias.envelopMax); - - // EnvelopPercentage - WriteColumnVolumeLinear(stream, alias.envelopPercentage); - - // CenterSend - WriteColumnVolumeLinear(stream, alias.centerSend); - - // ReverbSend - WriteColumnVolumeLinear(stream, alias.reverbSend); - - // StartDelay - WriteColumnIntegral(stream, alias.startDelay); - - // PriorityThresholdMin - WriteColumnNormByte(stream, alias.minPriorityThreshold); - - // PriorityThresholdMax - WriteColumnNormByte(stream, alias.maxPriorityThreshold); - - // OcclusionLevel - WriteColumnNormByte(stream, alias.occlusionLevel); - - // FluxTime - WriteColumnIntegral(stream, alias.fluxTime); - - // Duck - WriteColumnWithDuckHash(stream, hashes, alias.duck); - - // PriorityMin - WriteColumnIntegral(stream, alias.minPriority); - - // PriorityMax - WriteColumnIntegral(stream, alias.maxPriority); - - // LimitCount - WriteColumnIntegral(stream, alias.limitCount); - - // EntityLimitCount - WriteColumnIntegral(stream, alias.entityLimitCount); - // DryMinCurve WriteColumnEnum(stream, alias.flags.volumeMinFalloffCurve, SOUND_CURVES); @@ -539,11 +503,83 @@ namespace // WetMaxCurve WriteColumnEnum(stream, alias.flags.reverbFalloffCurve, SOUND_CURVES); + // LimitCount + WriteColumnIntegral(stream, alias.limitCount); + + // EntityLimitCount + WriteColumnIntegral(stream, alias.entityLimitCount); + + // LimitType + WriteColumnEnum(stream, alias.flags.limitType, SOUND_LIMIT_TYPES); + + // EntityLimitType + WriteColumnEnum(stream, alias.flags.entityLimitType, SOUND_LIMIT_TYPES); + + // PitchMin + WriteColumnPitchHertz(stream, alias.pitchMin); + + // PitchMax + WriteColumnPitchHertz(stream, alias.pitchMax); + + // PriorityMin + WriteColumnIntegral(stream, alias.minPriority); + + // PriorityMax + WriteColumnIntegral(stream, alias.maxPriority); + + // PriorityThresholdMin + WriteColumnNormByte(stream, alias.minPriorityThreshold); + + // PriorityThresholdMax + WriteColumnNormByte(stream, alias.maxPriorityThreshold); + + // PanType + WriteColumnEnum(stream, alias.flags.panType, SOUND_PAN_TYPES); + // Pan WriteColumnEnum(stream, alias.pan, SOUND_PANS); - // DuckGroup - WriteColumnEnum(stream, alias.duckGroup, SOUND_DUCK_GROUPS); + // Looping + WriteColumnEnum(stream, alias.flags.looping, SOUND_LOOP_TYPES); + + // RandomizeType + WriteColumnEnumFlags(stream, alias.flags.randomizeType, SOUND_RANDOMIZE_TYPES); + + // Probability + WriteColumnNormByte(stream, alias.probability); + + // StartDelay + WriteColumnIntegral(stream, alias.startDelay); + + // EnvelopMin + WriteColumnIntegral(stream, alias.envelopMin); + + // EnvelopMax + WriteColumnIntegral(stream, alias.envelopMax); + + // EnvelopPercentage + WriteColumnVolumeLinear(stream, alias.envelopPercentage); + + // OcclusionLevel + WriteColumnNormByte(stream, alias.occlusionLevel); + + // IsBig + WriteColumnEnum(stream, alias.flags.isBig, SOUND_NO_YES); + + // DistanceLpf + WriteColumnEnum(stream, alias.flags.distanceLpf, SOUND_NO_YES); + + // FluxType + WriteColumnEnum(stream, alias.flags.fluxType, SOUND_MOVE_TYPES); + + // FluxTime + WriteColumnIntegral(stream, alias.fluxTime); + + // Subtitle + WriteColumnString(stream, alias.subtitle); + + // Doppler + WriteColumnEnum(stream, alias.flags.doppler, SOUND_NO_YES); // ContextType WriteColumnWithKnownHashes(stream, CONTEXT_TYPES_MAP, alias.contextType); @@ -551,12 +587,27 @@ namespace // ContextValue WriteColumnWithKnownHashes(stream, CONTEXT_VALUES_MAP, alias.contextValue); + // Timescale + WriteColumnEnum(stream, alias.flags.timescale, SOUND_NO_YES); + + // IsMusic + WriteColumnEnum(stream, alias.flags.isMusic, SOUND_NO_YES); + + // IsCinematic + WriteColumnEnum(stream, alias.flags.isCinematic, SOUND_NO_YES); + // FadeIn WriteColumnIntegral(stream, alias.fadeIn); // FadeOut WriteColumnIntegral(stream, alias.fadeOut); + // Pausable + WriteColumnEnum(stream, alias.flags.pausable, SOUND_NO_YES); + + // StopOnEntDeath + WriteColumnEnum(stream, alias.flags.stopOnEntDeath, SOUND_NO_YES); + // StopOnPlay WriteColumnWithAliasHash(stream, hashes, alias.stopOnPlay); @@ -566,54 +617,6 @@ namespace // FutzPatch WriteColumnWithKnownHashes(stream, FUTZ_IDS_MAP, alias.futzPatch); - // LimitType - WriteColumnEnum(stream, alias.flags.limitType, SOUND_LIMIT_TYPES); - - // EntityLimitType - WriteColumnEnum(stream, alias.flags.entityLimitType, SOUND_LIMIT_TYPES); - - // RandomizeType - WriteColumnEnumFlags(stream, alias.flags.randomizeType, SOUND_RANDOMIZE_TYPES); - - // FluxType - WriteColumnEnum(stream, alias.flags.fluxType, SOUND_MOVE_TYPES); - - // Storage - WriteColumnEnum(stream, alias.flags.loadType, SOUND_LOAD_TYPES); - - // VolumeGroup - WriteColumnEnum(stream, alias.flags.volumeGroup, SOUND_GROUPS); - - // DistanceLpf - WriteColumnEnum(stream, alias.flags.distanceLpf, SOUND_NO_YES); - - // Doppler - WriteColumnEnum(stream, alias.flags.doppler, SOUND_NO_YES); - - // IsBig - WriteColumnEnum(stream, alias.flags.isBig, SOUND_NO_YES); - - // Looping - WriteColumnEnum(stream, alias.flags.looping, SOUND_LOOP_TYPES); - - // PanType - WriteColumnEnum(stream, alias.flags.panType, SOUND_PAN_TYPES); - - // IsMusic - WriteColumnEnum(stream, alias.flags.isMusic, SOUND_NO_YES); - - // Timescale - WriteColumnEnum(stream, alias.flags.timescale, SOUND_NO_YES); - - // Pausable - WriteColumnEnum(stream, alias.flags.pausable, SOUND_NO_YES); - - // StopOnEntDeath - WriteColumnEnum(stream, alias.flags.stopOnEntDeath, SOUND_NO_YES); - - // Bus - WriteColumnEnum(stream, alias.flags.busType, SOUND_BUS_IDS); - // VoiceLimit WriteColumnEnum(stream, alias.flags.voiceLimit, SOUND_NO_YES); @@ -622,9 +625,6 @@ namespace // NeverPlayTwice WriteColumnEnum(stream, alias.flags.neverPlayTwice, SOUND_NO_YES); - - // IsCinematic - WriteColumnEnum(stream, alias.flags.isCinematic, SOUND_NO_YES); } SoundBankEntryInputStream FindSoundDataInSoundBanks(const unsigned assetId) From 494ea8f89cf013d2c996bc724f138412c31296ae Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 15:01:51 -0700 Subject: [PATCH 04/17] Rename FileSource to File --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 2 +- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 6f65f6b3..811533b9 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -381,7 +381,7 @@ namespace { // clang-format off return headerRow.RequireIndexForHeader("Name", m_name) - && headerRow.RequireIndexForHeader("FileSource", m_file_source) + && headerRow.RequireIndexForHeader("File", m_file_source) && headerRow.RequireIndexForHeader("Secondary", m_secondary) && headerRow.RequireIndexForHeader("Storage", m_storage) && headerRow.RequireIndexForHeader("Bus", m_bus) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 88e29e1d..f8a4939e 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -24,7 +24,7 @@ namespace { const std::string ALIAS_HEADERS[]{ "Name", - "FileSource", + "File", "Secondary", "Storage", "Bus", @@ -448,7 +448,7 @@ namespace // Name WriteColumnString(stream, alias.name); - // FileSource + // File const auto* extension = maybeFormat ? ExtensionForSndFormat(*maybeFormat) : ""; WriteColumnString(stream, alias.assetFileName ? std::format("{}{}", alias.assetFileName, extension) : ""); From a926b752cf150d1b60a3ce9d2c6aa30455ef762b Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 15:04:47 -0700 Subject: [PATCH 05/17] Rename EnvelopPercentage to EnvelopPercent --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 2 +- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 811533b9..3a5d6854 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -417,7 +417,7 @@ namespace && headerRow.RequireIndexForHeader("StartDelay", m_start_delay) && headerRow.RequireIndexForHeader("EnvelopMin", m_envelop_min) && headerRow.RequireIndexForHeader("EnvelopMax", m_envelop_max) - && headerRow.RequireIndexForHeader("EnvelopPercentage", m_envelop_percentage) + && headerRow.RequireIndexForHeader("EnvelopPercent", m_envelop_percentage) && headerRow.RequireIndexForHeader("OcclusionLevel", m_occlusion_level) && headerRow.RequireIndexForHeader("IsBig", m_is_big) && headerRow.RequireIndexForHeader("DistanceLpf", m_distance_lpf) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index f8a4939e..e225d699 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -60,7 +60,7 @@ namespace "StartDelay", "EnvelopMin", "EnvelopMax", - "EnvelopPercentage", + "EnvelopPercent", "OcclusionLevel", "IsBig", "DistanceLpf", @@ -557,7 +557,7 @@ namespace // EnvelopMax WriteColumnIntegral(stream, alias.envelopMax); - // EnvelopPercentage + // EnvelopPercent WriteColumnVolumeLinear(stream, alias.envelopPercentage); // OcclusionLevel From 4529ff2c5ee7e1ac5dd64722cfb0e8442817e9d4 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 15:16:14 -0700 Subject: [PATCH 06/17] Rename all instances of Pausable to Pauseable --- src/Common/Game/T6/T6_Assets.h | 2 +- .../Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 6 +++--- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Common/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h index fca7250e..89394044 100644 --- a/src/Common/Game/T6/T6_Assets.h +++ b/src/Common/Game/T6/T6_Assets.h @@ -6228,7 +6228,7 @@ namespace T6 unsigned int distanceLpf : 1; // 2 unsigned int doppler : 1; // 3 unsigned int isBig : 1; // 4 - unsigned int pausable : 1; // 5 + unsigned int pauseable : 1; // 5 unsigned int isMusic : 1; // 6 unsigned int stopOnEntDeath : 1; // 7 unsigned int timescale : 1; // 8 diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 3a5d6854..bdece92b 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -533,7 +533,7 @@ namespace uint8_t dryMinCurve = 0u, dryMaxCurve = 0u, wetMinCurve = 0u, wetMaxCurve = 0u, limitType = 0u, entityLimitType = 0u, randomizeType = 0u, fluxType = 0u, storage = 0u, volumeGroup = 0u, distanceLpf = 0u, doppler = 0u, isBig = 0u, looping = 0u, panType = 0u, isMusic = 0u, timescale = 0u, - pausable = 0u, stopOnEntDeath = 0u, busType = 0u, voiceLimit = 0u, ignoreMaxDist = 0u, neverPlayTwice = 0u, isCinematic = 0u; + pauseable = 0u, stopOnEntDeath = 0u, busType = 0u, voiceLimit = 0u, ignoreMaxDist = 0u, neverPlayTwice = 0u, isCinematic = 0u; // clang-format off const auto couldReadSoundAlias = ReadColumnString(row, headers.m_secondary, alias.secondaryName, memory) @@ -586,7 +586,7 @@ namespace && ReadColumnEnum(headerRow, row, headers.m_is_cinematic, rowIndex, isCinematic, SOUND_NO_YES) && ReadColumnInt16(headerRow, row, headers.m_fade_in, rowIndex, alias.fadeIn, 0) && ReadColumnInt16(headerRow, row, headers.m_fade_out, rowIndex, alias.fadeOut, 0) - && ReadColumnEnum(headerRow, row, headers.m_pauseable, rowIndex, pausable, SOUND_NO_YES) + && ReadColumnEnum(headerRow, row, headers.m_pauseable, rowIndex, pauseable, SOUND_NO_YES) && ReadColumnEnum(headerRow, row, headers.m_stop_on_ent_death, rowIndex, stopOnEntDeath, SOUND_NO_YES) && ReadColumnHash(row, headers.m_stop_on_play, alias.stopOnPlay) && ReadColumnInt16(headerRow, row, headers.m_doppler_scale, rowIndex, alias.dopplerScale, -100, 100) @@ -617,7 +617,7 @@ namespace alias.flags.panType = panType; alias.flags.isMusic = isMusic; alias.flags.timescale = timescale; - alias.flags.pausable = pausable; + alias.flags.pauseable = pauseable; alias.flags.stopOnEntDeath = stopOnEntDeath; alias.flags.busType = busType; alias.flags.voiceLimit = voiceLimit; diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index e225d699..67a041f4 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -602,8 +602,8 @@ namespace // FadeOut WriteColumnIntegral(stream, alias.fadeOut); - // Pausable - WriteColumnEnum(stream, alias.flags.pausable, SOUND_NO_YES); + // Pauseable + WriteColumnEnum(stream, alias.flags.pauseable, SOUND_NO_YES); // StopOnEntDeath WriteColumnEnum(stream, alias.flags.stopOnEntDeath, SOUND_NO_YES); From 5f8eb30ce00ced83e78af7c2b62829cc5baa204c Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 6 Oct 2024 17:45:50 -0700 Subject: [PATCH 07/17] Format dumped sound alias float values --- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 67a041f4..bf3d6f13 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -399,20 +399,20 @@ namespace { const auto linear = static_cast(value) / static_cast(std::numeric_limits::max()); const auto dbSpl = std::clamp(LinearToDbspl(linear), 0.0f, 100.0f); - stream.WriteColumn(std::format("{:.3g}", dbSpl)); + stream.WriteColumn(std::format("{}", std::stof(std::format("{:.0f}", dbSpl)))); } void WriteColumnPitchHertz(CsvOutputStream& stream, const uint16_t value) { const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); const auto cents = std::clamp(HertzToCents(hertz), -2400.0f, 1200.0f); - stream.WriteColumn(std::format("{:.4g}", cents)); + stream.WriteColumn(std::format("{}", std::stof(std::format("{:.0f}", cents)))); } void WriteColumnNormByte(CsvOutputStream& stream, const uint8_t value) { const auto normValue = static_cast(value) / static_cast(std::numeric_limits::max()); - stream.WriteColumn(std::format("{:.3g}", normValue)); + stream.WriteColumn(std::format("{}", std::stof(std::format("{:.2f}", normValue)))); } void WriteColumnWithKnownHashes(CsvOutputStream& stream, const std::unordered_map& knownValues, const unsigned value) From 93a35f5dcf6b53f829e76cee31b3c9208f243abe Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 7 Oct 2024 01:15:48 -0700 Subject: [PATCH 08/17] Rename CentToHertz to CentsToHertz --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index bdece92b..ff16a1cf 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -81,7 +81,7 @@ namespace return std::pow(10.0f, (dbsplValue - 100.0f) / 20.0f); } - float CentToHertz(const float cents) + float CentsToHertz(const float cents) { return std::pow(2.0f, cents / 1200.0f); } @@ -142,7 +142,7 @@ namespace return false; } - value = static_cast(CentToHertz(centValue) * static_cast(std::numeric_limits::max())); + value = static_cast(CentsToHertz(centValue) * static_cast(std::numeric_limits::max())); return true; } From ed06700f99b63c55190958963698beaef1a2fe79 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 7 Oct 2024 06:41:59 -0700 Subject: [PATCH 09/17] Increase rounded sound alias float value precision until it is equal to initial value --- src/Common/Game/T6/CommonT6.cpp | 26 +++++++ src/Common/Game/T6/CommonT6.h | 4 ++ .../T6/AssetLoaders/AssetLoaderSoundBank.cpp | 14 +--- .../T6/AssetDumpers/AssetDumperSndBank.cpp | 67 +++++++++++++------ 4 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/Common/Game/T6/CommonT6.cpp b/src/Common/Game/T6/CommonT6.cpp index 5a54bc8d..34121e0b 100644 --- a/src/Common/Game/T6/CommonT6.cpp +++ b/src/Common/Game/T6/CommonT6.cpp @@ -2,6 +2,8 @@ #include "Utils/Pack.h" +#include + using namespace T6; PackedTexCoords Common::Vec2PackTexCoords(const float (&in)[2]) @@ -33,3 +35,27 @@ void Common::Vec4UnpackGfxColor(const GfxColor& in, float (&out)[4]) { pack32::Vec4UnpackGfxColor(in.packed, out); } + +float Common::LinearToDbspl(const float linear) +{ + const auto db = 20.0f * std::log10(std::max(linear, 0.0000152879f)); + if (db > -95.0f) + return db + 100.0f; + + return 0; +} + +float Common::DbsplToLinear(const float dbsplValue) +{ + return std::pow(10.0f, (dbsplValue - 100.0f) / 20.0f); +} + +float Common::HertzToCents(const float hertz) +{ + return 1200.0f * std::log2(hertz); +} + +float Common::CentsToHertz(const float cents) +{ + return std::pow(2.0f, cents / 1200.0f); +} diff --git a/src/Common/Game/T6/CommonT6.h b/src/Common/Game/T6/CommonT6.h index f32c9d97..212a09d9 100644 --- a/src/Common/Game/T6/CommonT6.h +++ b/src/Common/Game/T6/CommonT6.h @@ -102,5 +102,9 @@ namespace T6 static void Vec2UnpackTexCoords(const PackedTexCoords& in, float (&out)[2]); static void Vec3UnpackUnitVec(const PackedUnitVec& in, float (&out)[3]); static void Vec4UnpackGfxColor(const GfxColor& in, float (&out)[4]); + static float LinearToDbspl(const float linear); + static float DbsplToLinear(const float dbsplValue); + static float HertzToCents(const float hertz); + static float CentsToHertz(const float cents); }; } // namespace T6 diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index ff16a1cf..1454fc2a 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -76,16 +76,6 @@ namespace return 0; } - float DbsplToLinear(const float dbsplValue) - { - return std::pow(10.0f, (dbsplValue - 100.0f) / 20.0f); - } - - float CentsToHertz(const float cents) - { - return std::pow(2.0f, cents / 1200.0f); - } - bool ReadColumnString(const std::vector& row, const unsigned columnIndex, const char*& value, MemoryManager& memory) { const auto& cell = row[columnIndex]; @@ -117,7 +107,7 @@ namespace return false; } - value = static_cast(DbsplToLinear(dbsplValue) * static_cast(std::numeric_limits::max())); + value = static_cast(T6::Common::DbsplToLinear(dbsplValue) * static_cast(std::numeric_limits::max())); return true; } @@ -142,7 +132,7 @@ namespace return false; } - value = static_cast(CentsToHertz(centValue) * static_cast(std::numeric_limits::max())); + value = static_cast(T6::Common::CentsToHertz(centValue) * static_cast(std::numeric_limits::max())); return true; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index bf3d6f13..a691ee01 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -326,22 +326,6 @@ namespace } } - float LinearToDbspl(float linear) - { - linear = std::max(linear, 0.0000152879f); - - const auto db = 20.0f * std::log10(linear); - if (db > -95.0f) - return db + 100.0f; - - return 0; - } - - float HertzToCents(const float hertz) - { - return 1200.0f * std::log2(hertz); - } - void WriteColumnString(CsvOutputStream& stream, const std::string& stringValue) { stream.WriteColumn(stringValue); @@ -398,21 +382,62 @@ namespace void WriteColumnVolumeLinear(CsvOutputStream& stream, const uint16_t value) { const auto linear = static_cast(value) / static_cast(std::numeric_limits::max()); - const auto dbSpl = std::clamp(LinearToDbspl(linear), 0.0f, 100.0f); - stream.WriteColumn(std::format("{}", std::stof(std::format("{:.0f}", dbSpl)))); + const auto dbSpl = std::clamp(T6::Common::LinearToDbspl(linear), 0.0f, 100.0f); + + float dbSplRound; + for (auto i = 0; i <= 4; i++) + { + dbSplRound = std::stof(std::format("{:.{}f}", dbSpl, i)); + const auto dbSplRoundToValue = + static_cast(T6::Common::DbsplToLinear(dbSplRound) * static_cast(std::numeric_limits::max())); + + if (dbSplRoundToValue == value) + { + break; + } + } + + stream.WriteColumn(std::format("{}", dbSplRound)); } void WriteColumnPitchHertz(CsvOutputStream& stream, const uint16_t value) { const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); - const auto cents = std::clamp(HertzToCents(hertz), -2400.0f, 1200.0f); - stream.WriteColumn(std::format("{}", std::stof(std::format("{:.0f}", cents)))); + const auto cents = std::clamp(T6::Common::HertzToCents(hertz), -2400.0f, 1200.0f); + + float centsRound; + for (auto i = 0; i <= 4; i++) + { + centsRound = std::stof(std::format("{:.{}f}", cents, i)); + const auto centsRoundToValue = + static_cast(T6::Common::CentsToHertz(centsRound) * static_cast(std::numeric_limits::max())); + + if (centsRoundToValue == value) + { + break; + } + } + + stream.WriteColumn(std::format("{}", centsRound)); } void WriteColumnNormByte(CsvOutputStream& stream, const uint8_t value) { const auto normValue = static_cast(value) / static_cast(std::numeric_limits::max()); - stream.WriteColumn(std::format("{}", std::stof(std::format("{:.2f}", normValue)))); + + float normValueRound; + for (auto i = 0; i <= 4; i++) + { + normValueRound = std::stof(std::format("{:.{}f}", normValue, i)); + const auto normValueRoundToValue = static_cast(normValueRound * static_cast(std::numeric_limits::max())); + + if (normValueRoundToValue == value) + { + break; + } + } + + stream.WriteColumn(std::format("{}", normValueRound)); } void WriteColumnWithKnownHashes(CsvOutputStream& stream, const std::unordered_map& knownValues, const unsigned value) From 321c5067ed793d8e3fef5aa561b99ea8c6df5a1e Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 7 Oct 2024 06:45:22 -0700 Subject: [PATCH 10/17] Rename centValue to centsValue --- .../Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 1454fc2a..0135b2af 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -117,22 +117,22 @@ namespace { const auto& cell = row[columnIndex]; - float centValue; - if (!cell.AsFloat(centValue)) + float centsValue; + if (!cell.AsFloat(centsValue)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); std::cerr << std::format("Invalid value for row {} col '{}' - Must be a float\n", rowIndex + 1, colName); return false; } - if (centValue < -2400.0f || centValue > 1200.0f) + if (centsValue < -2400.0f || centsValue > 1200.0f) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [-2400.0, 1200.0]\n", rowIndex + 1, colName, centValue); + std::cerr << std::format("Invalid value for row {} col '{}' - {} [-2400.0, 1200.0]\n", rowIndex + 1, colName, centsValue); return false; } - value = static_cast(T6::Common::CentsToHertz(centValue) * static_cast(std::numeric_limits::max())); + value = static_cast(T6::Common::CentsToHertz(centsValue) * static_cast(std::numeric_limits::max())); return true; } From bd57f84ecd1d2ee431327f0624e3f56f5b800bbb Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 7 Oct 2024 12:10:32 -0700 Subject: [PATCH 11/17] Fix windows build --- src/Common/Game/T6/CommonT6.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Common/Game/T6/CommonT6.cpp b/src/Common/Game/T6/CommonT6.cpp index 34121e0b..0af59ee6 100644 --- a/src/Common/Game/T6/CommonT6.cpp +++ b/src/Common/Game/T6/CommonT6.cpp @@ -2,6 +2,7 @@ #include "Utils/Pack.h" +#include #include using namespace T6; From 351a4441c2dc5bc92e79de836fbc96963d17133f Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Mon, 7 Oct 2024 12:33:01 -0700 Subject: [PATCH 12/17] Revert FileSource rename --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 2 +- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 0135b2af..4b866564 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -371,7 +371,7 @@ namespace { // clang-format off return headerRow.RequireIndexForHeader("Name", m_name) - && headerRow.RequireIndexForHeader("File", m_file_source) + && headerRow.RequireIndexForHeader("FileSource", m_file_source) && headerRow.RequireIndexForHeader("Secondary", m_secondary) && headerRow.RequireIndexForHeader("Storage", m_storage) && headerRow.RequireIndexForHeader("Bus", m_bus) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index a691ee01..663e18d0 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -24,7 +24,7 @@ namespace { const std::string ALIAS_HEADERS[]{ "Name", - "File", + "FileSource", "Secondary", "Storage", "Bus", @@ -473,7 +473,7 @@ namespace // Name WriteColumnString(stream, alias.name); - // File + // FileSource const auto* extension = maybeFormat ? ExtensionForSndFormat(*maybeFormat) : ""; WriteColumnString(stream, alias.assetFileName ? std::format("{}{}", alias.assetFileName, extension) : ""); From e9720a2b1a043fb4d11fd85f0e5c76a2344b0999 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 11:36:23 -0700 Subject: [PATCH 13/17] Remove namespace on function calls --- .../Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 663e18d0..d3a4e431 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -382,14 +382,13 @@ namespace void WriteColumnVolumeLinear(CsvOutputStream& stream, const uint16_t value) { const auto linear = static_cast(value) / static_cast(std::numeric_limits::max()); - const auto dbSpl = std::clamp(T6::Common::LinearToDbspl(linear), 0.0f, 100.0f); + const auto dbSpl = std::clamp(Common::LinearToDbspl(linear), 0.0f, 100.0f); float dbSplRound; for (auto i = 0; i <= 4; i++) { dbSplRound = std::stof(std::format("{:.{}f}", dbSpl, i)); - const auto dbSplRoundToValue = - static_cast(T6::Common::DbsplToLinear(dbSplRound) * static_cast(std::numeric_limits::max())); + const auto dbSplRoundToValue = static_cast(Common::DbsplToLinear(dbSplRound) * static_cast(std::numeric_limits::max())); if (dbSplRoundToValue == value) { @@ -403,14 +402,13 @@ namespace void WriteColumnPitchHertz(CsvOutputStream& stream, const uint16_t value) { const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); - const auto cents = std::clamp(T6::Common::HertzToCents(hertz), -2400.0f, 1200.0f); + const auto cents = std::clamp(Common::HertzToCents(hertz), -2400.0f, 1200.0f); float centsRound; for (auto i = 0; i <= 4; i++) { centsRound = std::stof(std::format("{:.{}f}", cents, i)); - const auto centsRoundToValue = - static_cast(T6::Common::CentsToHertz(centsRound) * static_cast(std::numeric_limits::max())); + const auto centsRoundToValue = static_cast(Common::CentsToHertz(centsRound) * static_cast(std::numeric_limits::max())); if (centsRoundToValue == value) { From 6beff28518a95398d1558fc22ee78442156f565d Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 11:38:24 -0700 Subject: [PATCH 14/17] Remove more namespace on function calls --- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 4b866564..43a83b46 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -107,7 +107,7 @@ namespace return false; } - value = static_cast(T6::Common::DbsplToLinear(dbsplValue) * static_cast(std::numeric_limits::max())); + value = static_cast(Common::DbsplToLinear(dbsplValue) * static_cast(std::numeric_limits::max())); return true; } @@ -132,7 +132,7 @@ namespace return false; } - value = static_cast(T6::Common::CentsToHertz(centsValue) * static_cast(std::numeric_limits::max())); + value = static_cast(Common::CentsToHertz(centsValue) * static_cast(std::numeric_limits::max())); return true; } From e98fad73b945931ae81cb4729a71eafbbe0d6dd3 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 11:40:30 -0700 Subject: [PATCH 15/17] Remove curly braces on single line statements --- src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index d3a4e431..e3b213ee 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -391,9 +391,7 @@ namespace const auto dbSplRoundToValue = static_cast(Common::DbsplToLinear(dbSplRound) * static_cast(std::numeric_limits::max())); if (dbSplRoundToValue == value) - { break; - } } stream.WriteColumn(std::format("{}", dbSplRound)); @@ -411,9 +409,7 @@ namespace const auto centsRoundToValue = static_cast(Common::CentsToHertz(centsRound) * static_cast(std::numeric_limits::max())); if (centsRoundToValue == value) - { break; - } } stream.WriteColumn(std::format("{}", centsRound)); @@ -430,9 +426,7 @@ namespace const auto normValueRoundToValue = static_cast(normValueRound * static_cast(std::numeric_limits::max())); if (normValueRoundToValue == value) - { break; - } } stream.WriteColumn(std::format("{}", normValueRound)); From cfb7c7ca78bce595a985e797d19f8b0234f156a8 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 11:56:52 -0700 Subject: [PATCH 16/17] Save format string instead of float --- .../T6/AssetDumpers/AssetDumperSndBank.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index e3b213ee..39ee1e4b 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -384,17 +384,18 @@ namespace const auto linear = static_cast(value) / static_cast(std::numeric_limits::max()); const auto dbSpl = std::clamp(Common::LinearToDbspl(linear), 0.0f, 100.0f); - float dbSplRound; + std::string dbSplFormat; for (auto i = 0; i <= 4; i++) { - dbSplRound = std::stof(std::format("{:.{}f}", dbSpl, i)); + dbSplFormat = std::format("{:.{}f}", dbSpl, i); + const auto dbSplRound = std::stof(dbSplFormat); const auto dbSplRoundToValue = static_cast(Common::DbsplToLinear(dbSplRound) * static_cast(std::numeric_limits::max())); if (dbSplRoundToValue == value) break; } - stream.WriteColumn(std::format("{}", dbSplRound)); + stream.WriteColumn(dbSplFormat); } void WriteColumnPitchHertz(CsvOutputStream& stream, const uint16_t value) @@ -402,34 +403,36 @@ namespace const auto hertz = static_cast(value) / static_cast(std::numeric_limits::max()); const auto cents = std::clamp(Common::HertzToCents(hertz), -2400.0f, 1200.0f); - float centsRound; + std::string centsFormat; for (auto i = 0; i <= 4; i++) { - centsRound = std::stof(std::format("{:.{}f}", cents, i)); + centsFormat = std::format("{:.{}f}", cents, i); + const auto centsRound = std::stof(centsFormat); const auto centsRoundToValue = static_cast(Common::CentsToHertz(centsRound) * static_cast(std::numeric_limits::max())); if (centsRoundToValue == value) break; } - stream.WriteColumn(std::format("{}", centsRound)); + stream.WriteColumn(centsFormat); } void WriteColumnNormByte(CsvOutputStream& stream, const uint8_t value) { const auto normValue = static_cast(value) / static_cast(std::numeric_limits::max()); - float normValueRound; + std::string normValueFormat; for (auto i = 0; i <= 4; i++) { - normValueRound = std::stof(std::format("{:.{}f}", normValue, i)); + normValueFormat = std::format("{:.{}f}", normValue, i); + const auto normValueRound = std::stof(normValueFormat); const auto normValueRoundToValue = static_cast(normValueRound * static_cast(std::numeric_limits::max())); if (normValueRoundToValue == value) break; } - stream.WriteColumn(std::format("{}", normValueRound)); + stream.WriteColumn(normValueFormat); } void WriteColumnWithKnownHashes(CsvOutputStream& stream, const std::unordered_map& knownValues, const unsigned value) From ac7b1800f058197ea5f0b3b920b721d7a3a1ce7f Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 12:03:33 -0700 Subject: [PATCH 17/17] Add FORMATTING_RETRIES constexpr --- .../Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 39ee1e4b..10805b9c 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -194,6 +194,8 @@ namespace const auto CONTEXT_VALUES_MAP = CreateSoundHashMap(KNOWN_CONTEXT_VALUES, std::extent_v); const auto FUTZ_IDS_MAP = CreateSoundHashMap(KNOWN_FUTZ_IDS, std::extent_v); + constexpr auto FORMATTING_RETRIES = 5; + class LoadedSoundBankHashes { public: @@ -385,7 +387,7 @@ namespace const auto dbSpl = std::clamp(Common::LinearToDbspl(linear), 0.0f, 100.0f); std::string dbSplFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { dbSplFormat = std::format("{:.{}f}", dbSpl, i); const auto dbSplRound = std::stof(dbSplFormat); @@ -404,7 +406,7 @@ namespace const auto cents = std::clamp(Common::HertzToCents(hertz), -2400.0f, 1200.0f); std::string centsFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { centsFormat = std::format("{:.{}f}", cents, i); const auto centsRound = std::stof(centsFormat); @@ -422,7 +424,7 @@ namespace const auto normValue = static_cast(value) / static_cast(std::numeric_limits::max()); std::string normValueFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { normValueFormat = std::format("{:.{}f}", normValue, i); const auto normValueRound = std::stof(normValueFormat);