mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Merge pull request #1 from KiritoDv/feature/audio
Implemented full audio extraction
This commit is contained in:
+80
-36
@@ -525,8 +525,6 @@
|
||||
"actors/yoshi_egg/yoshi_egg_5_unused.rgba16.png": [32,32,2048,{"jp":[1215456,32696],"us":[1222624,32696],"eu":[1094592,32696],"sh":[1071104,32696]}],
|
||||
"actors/yoshi_egg/yoshi_egg_6_unused.rgba16.png": [32,32,2048,{"jp":[1215456,34744],"us":[1222624,34744],"eu":[1094592,34744],"sh":[1071104,34744]}],
|
||||
"actors/yoshi_egg/yoshi_egg_7_unused.rgba16.png": [32,32,2048,{"jp":[1215456,36792],"us":[1222624,36792],"eu":[1094592,36792],"sh":[1071104,36792]}],
|
||||
"sound/sequences.aud": [114432, { "us": [8063072] }],
|
||||
"sound/bank_sets.aud": [159, { "us": [8177185] }],
|
||||
"assets/demos/bbh.bin": [988,{"jp":[5733368],"us":[5741664],"eu":[5620584],"sh":[5589632]}],
|
||||
"assets/demos/bitdw.bin": [1412,{"us":[5747100],"sh":[5595068]}],
|
||||
"assets/demos/ccm.bin": [1320,{"jp":[5734356],"us":[5742652],"eu":[5621572],"sh":[5590620]}],
|
||||
@@ -1088,40 +1086,86 @@
|
||||
"sound/sequences/sh/20_cutscene_ending.m64": [1887,{"sh":[7981824]}],
|
||||
"sound/sequences/sh/21_menu_file_select.m64": [786,{"sh":[7983712]}],
|
||||
"sound/sequences/sh/22_cutscene_lakitu.m64": [317,{"sh":[7984512]}],
|
||||
"sound/sequences/us/01_cutscene_collect_star.m64": [619,{"us":[8076816]}],
|
||||
"sound/sequences/us/02_menu_title_screen.m64": [8254,{"us":[8077440]}],
|
||||
"sound/sequences/us/03_level_grass.m64": [5122,{"us":[8085696]}],
|
||||
"sound/sequences/us/04_level_inside_castle.m64": [2494,{"us":[8090832]}],
|
||||
"sound/sequences/us/05_level_water.m64": [4780,{"us":[8093328]}],
|
||||
"sound/sequences/us/06_level_hot.m64": [2451,{"us":[8098112]}],
|
||||
"sound/sequences/us/07_level_boss_koopa.m64": [3418,{"us":[8100576]}],
|
||||
"sound/sequences/us/08_level_snow.m64": [8143,{"us":[8104000]}],
|
||||
"sound/sequences/us/09_level_slide.m64": [7432,{"us":[8112144]}],
|
||||
"sound/sequences/us/0A_level_spooky.m64": [5674,{"us":[8119584]}],
|
||||
"sound/sequences/us/0B_event_piranha_plant.m64": [1395,{"us":[8125264]}],
|
||||
"sound/sequences/us/0C_level_underground.m64": [4887,{"us":[8126672]}],
|
||||
"sound/sequences/us/0D_menu_star_select.m64": [134,{"us":[8131568]}],
|
||||
"sound/sequences/us/0E_event_powerup.m64": [3129,{"us":[8131712]}],
|
||||
"sound/sequences/us/0F_event_metal_cap.m64": [2770,{"us":[8134848]}],
|
||||
"sound/sequences/us/10_event_koopa_message.m64": [552,{"us":[8137632]}],
|
||||
"sound/sequences/us/11_level_koopa_road.m64": [4741,{"us":[8138192]}],
|
||||
"sound/sequences/us/12_event_high_score.m64": [271,{"us":[8142944]}],
|
||||
"sound/sequences/us/13_event_merry_go_round.m64": [1657,{"us":[8143216]}],
|
||||
"sound/sequences/us/14_event_race.m64": [197,{"us":[8144880]}],
|
||||
"sound/sequences/us/15_cutscene_star_spawn.m64": [644,{"us":[8145088]}],
|
||||
"sound/sequences/us/16_event_boss.m64": [3435,{"us":[8145744]}],
|
||||
"sound/sequences/us/17_cutscene_collect_key.m64": [671,{"us":[8149184]}],
|
||||
"sound/sequences/us/18_event_endless_stairs.m64": [1777,{"us":[8149856]}],
|
||||
"sound/sequences/us/19_level_boss_koopa_final.m64": [3515,{"us":[8151648]}],
|
||||
"sound/sequences/us/1A_cutscene_credits.m64": [14313,{"us":[8155168]}],
|
||||
"sound/sequences/us/1B_event_solve_puzzle.m64": [216,{"us":[8169488]}],
|
||||
"sound/sequences/us/1C_event_toad_message.m64": [208,{"us":[8169712]}],
|
||||
"sound/sequences/us/1D_event_peach_message.m64": [432,{"us":[8169920]}],
|
||||
"sound/sequences/us/1E_cutscene_intro.m64": [1764,{"us":[8170352]}],
|
||||
"sound/sequences/us/1F_cutscene_victory.m64": [2058,{"us":[8172128]}],
|
||||
"sound/sequences/us/20_cutscene_ending.m64": [1882,{"us":[8174192]}],
|
||||
"sound/sequences/us/21_menu_file_select.m64": [781,{"us":[8176080]}],
|
||||
"sound/sequences/us/22_cutscene_lakitu.m64": [313,{"us":[8176864]}],
|
||||
"sound/sequences/us/00_sound_player.m64": [13452,{"us":[8063360], "banks": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}],
|
||||
"sound/sequences/us/01_cutscene_collect_star.m64": [619,{"us":[8076816], "banks": [34]}],
|
||||
"sound/sequences/us/02_menu_title_screen.m64": [8254,{"us":[8077440], "banks": [17]}],
|
||||
"sound/sequences/us/03_level_grass.m64": [5122,{"us":[8085696], "banks": [34]}],
|
||||
"sound/sequences/us/04_level_inside_castle.m64": [2494,{"us":[8090832], "banks": [14]}],
|
||||
"sound/sequences/us/05_level_water.m64": [4780,{"us":[8093328], "banks": [19]}],
|
||||
"sound/sequences/us/06_level_hot.m64": [2451,{"us":[8098112], "banks": [15]}],
|
||||
"sound/sequences/us/07_level_boss_koopa.m64": [3418,{"us":[8100576], "banks": [18]}],
|
||||
"sound/sequences/us/08_level_snow.m64": [8143,{"us":[8104000], "banks": [11]}],
|
||||
"sound/sequences/us/09_level_slide.m64": [7432,{"us":[8112144], "banks": [13]}],
|
||||
"sound/sequences/us/0A_level_spooky.m64": [5674,{"us":[8119584], "banks": [33, 16]}],
|
||||
"sound/sequences/us/0B_event_piranha_plant.m64": [1395,{"us":[8125264], "banks": [20]}],
|
||||
"sound/sequences/us/0C_level_underground.m64": [4887,{"us":[8126672], "banks": [21]}],
|
||||
"sound/sequences/us/0D_menu_star_select.m64": [134,{"us":[8131568], "banks": [22]}],
|
||||
"sound/sequences/us/0E_event_powerup.m64": [3129,{"us":[8131712], "banks": [23]}],
|
||||
"sound/sequences/us/0F_event_metal_cap.m64": [2770,{"us":[8134848], "banks": [24]}],
|
||||
"sound/sequences/us/10_event_koopa_message.m64": [552,{"us":[8137632], "banks": [18]}],
|
||||
"sound/sequences/us/11_level_koopa_road.m64": [4741,{"us":[8138192], "banks": [25]}],
|
||||
"sound/sequences/us/12_event_high_score.m64": [271,{"us":[8142944], "banks": [31]}],
|
||||
"sound/sequences/us/13_event_merry_go_round.m64": [1657,{"us":[8143216], "banks": [33]}],
|
||||
"sound/sequences/us/14_event_race.m64": [197,{"us":[8144880], "banks": [26]}],
|
||||
"sound/sequences/us/15_cutscene_star_spawn.m64": [644,{"us":[8145088], "banks": [14]}],
|
||||
"sound/sequences/us/16_event_boss.m64": [3435,{"us":[8145744], "banks": [27]}],
|
||||
"sound/sequences/us/17_cutscene_collect_key.m64": [671,{"us":[8149184], "banks": [26]}],
|
||||
"sound/sequences/us/18_event_endless_stairs.m64": [1777,{"us":[8149856], "banks": [28]}],
|
||||
"sound/sequences/us/19_level_boss_koopa_final.m64": [3515,{"us":[8151648], "banks": [29]}],
|
||||
"sound/sequences/us/1A_cutscene_credits.m64": [14313,{"us":[8155168], "banks": [37]}],
|
||||
"sound/sequences/us/1B_event_solve_puzzle.m64": [216,{"us":[8169488], "banks": [20]}],
|
||||
"sound/sequences/us/1C_event_toad_message.m64": [208,{"us":[8169712], "banks": [32]}],
|
||||
"sound/sequences/us/1D_event_peach_message.m64": [432,{"us":[8169920], "banks": [30]}],
|
||||
"sound/sequences/us/1E_cutscene_intro.m64": [1764,{"us":[8170352], "banks": [27]}],
|
||||
"sound/sequences/us/1F_cutscene_victory.m64": [2058,{"us":[8172128], "banks": [26]}],
|
||||
"sound/sequences/us/20_cutscene_ending.m64": [1882,{"us":[8174192], "banks": [35]}],
|
||||
"sound/sequences/us/21_menu_file_select.m64": [781,{"us":[8176080], "banks": [36]}],
|
||||
"sound/sequences/us/22_cutscene_lakitu.m64": [313,{"us":[8176864], "banks": [27]}],
|
||||
"sound/bank_sets.bset": [159, { "us": [8177185] }],
|
||||
"@sound_data": {
|
||||
"us": {
|
||||
"sound_ctl": [5748512, 97856],
|
||||
"sound_tbl": [5846368, 2216704]
|
||||
}
|
||||
},
|
||||
"sound/banks/us/00_bank.bnk": {"us": [0]},
|
||||
"sound/banks/us/01_bank.bnk": {"us": [1]},
|
||||
"sound/banks/us/02_bank.bnk": {"us": [2]},
|
||||
"sound/banks/us/03_bank.bnk": {"us": [3]},
|
||||
"sound/banks/us/04_bank.bnk": {"us": [4]},
|
||||
"sound/banks/us/05_bank.bnk": {"us": [5]},
|
||||
"sound/banks/us/06_bank.bnk": {"us": [6]},
|
||||
"sound/banks/us/07_bank.bnk": {"us": [7]},
|
||||
"sound/banks/us/08_bank.bnk": {"us": [8]},
|
||||
"sound/banks/us/09_bank.bnk": {"us": [9]},
|
||||
"sound/banks/us/0A_bank.bnk": {"us": [10]},
|
||||
"sound/banks/us/0B_bank.bnk": {"us": [11]},
|
||||
"sound/banks/us/0C_bank.bnk": {"us": [12]},
|
||||
"sound/banks/us/0D_bank.bnk": {"us": [13]},
|
||||
"sound/banks/us/0E_bank.bnk": {"us": [14]},
|
||||
"sound/banks/us/0F_bank.bnk": {"us": [15]},
|
||||
"sound/banks/us/10_bank.bnk": {"us": [16]},
|
||||
"sound/banks/us/11_bank.bnk": {"us": [17]},
|
||||
"sound/banks/us/12_bank.bnk": {"us": [18]},
|
||||
"sound/banks/us/13_bank.bnk": {"us": [19]},
|
||||
"sound/banks/us/14_bank.bnk": {"us": [20]},
|
||||
"sound/banks/us/15_bank.bnk": {"us": [21]},
|
||||
"sound/banks/us/16_bank.bnk": {"us": [22]},
|
||||
"sound/banks/us/17_bank.bnk": {"us": [23]},
|
||||
"sound/banks/us/18_bank.bnk": {"us": [24]},
|
||||
"sound/banks/us/19_bank.bnk": {"us": [25]},
|
||||
"sound/banks/us/1A_bank.bnk": {"us": [26]},
|
||||
"sound/banks/us/1B_bank.bnk": {"us": [27]},
|
||||
"sound/banks/us/1C_bank.bnk": {"us": [28]},
|
||||
"sound/banks/us/1D_bank.bnk": {"us": [29]},
|
||||
"sound/banks/us/1E_bank.bnk": {"us": [30]},
|
||||
"sound/banks/us/1F_bank.bnk": {"us": [31]},
|
||||
"sound/banks/us/20_bank.bnk": {"us": [32]},
|
||||
"sound/banks/us/21_bank.bnk": {"us": [33]},
|
||||
"sound/banks/us/22_bank.bnk": {"us": [34]},
|
||||
"sound/banks/us/23_bank.bnk": {"us": [35]},
|
||||
"sound/banks/us/24_bank.bnk": {"us": [36]},
|
||||
"sound/banks/us/25_bank.bnk": {"us": [37]},
|
||||
"textures/cave/hmc_textures.00000.rgba16.png": [32,64,4096,{"jp":[3432432,0],"us":[3439184,0],"eu":[3312784,0],"sh":[3287152,0]}],
|
||||
"textures/cave/hmc_textures.01000.rgba16.png": [32,32,2048,{"jp":[3432432,4096],"us":[3439184,4096],"eu":[3312784,4096],"sh":[3287152,4096]}],
|
||||
"textures/cave/hmc_textures.01800.rgba16.png": [32,64,4096,{"jp":[3432432,6144],"us":[3439184,6144],"eu":[3312784,6144],"sh":[3287152,6144]}],
|
||||
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
#pragma once
|
||||
#include "align_asset_macro.h"
|
||||
|
||||
#define dgBank00 "__OTR__sound/banks/us/00_bank"
|
||||
static const ALIGN_ASSET(2) char gBank00[] = dgBank00;
|
||||
|
||||
#define dgBank01 "__OTR__sound/banks/us/01_bank"
|
||||
static const ALIGN_ASSET(2) char gBank01[] = dgBank01;
|
||||
|
||||
#define dgBank02 "__OTR__sound/banks/us/02_bank"
|
||||
static const ALIGN_ASSET(2) char gBank02[] = dgBank02;
|
||||
|
||||
#define dgBank03 "__OTR__sound/banks/us/03_bank"
|
||||
static const ALIGN_ASSET(2) char gBank03[] = dgBank03;
|
||||
|
||||
#define dgBank04 "__OTR__sound/banks/us/04_bank"
|
||||
static const ALIGN_ASSET(2) char gBank04[] = dgBank04;
|
||||
|
||||
#define dgBank05 "__OTR__sound/banks/us/05_bank"
|
||||
static const ALIGN_ASSET(2) char gBank05[] = dgBank05;
|
||||
|
||||
#define dgBank06 "__OTR__sound/banks/us/06_bank"
|
||||
static const ALIGN_ASSET(2) char gBank06[] = dgBank06;
|
||||
|
||||
#define dgBank07 "__OTR__sound/banks/us/07_bank"
|
||||
static const ALIGN_ASSET(2) char gBank07[] = dgBank07;
|
||||
|
||||
#define dgBank08 "__OTR__sound/banks/us/08_bank"
|
||||
static const ALIGN_ASSET(2) char gBank08[] = dgBank08;
|
||||
|
||||
#define dgBank09 "__OTR__sound/banks/us/09_bank"
|
||||
static const ALIGN_ASSET(2) char gBank09[] = dgBank09;
|
||||
|
||||
#define dgBank0A "__OTR__sound/banks/us/0A_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0A[] = dgBank0A;
|
||||
|
||||
#define dgBank0B "__OTR__sound/banks/us/0B_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0B[] = dgBank0B;
|
||||
|
||||
#define dgBank0C "__OTR__sound/banks/us/0C_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0C[] = dgBank0C;
|
||||
|
||||
#define dgBank0D "__OTR__sound/banks/us/0D_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0D[] = dgBank0D;
|
||||
|
||||
#define dgBank0E "__OTR__sound/banks/us/0E_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0E[] = dgBank0E;
|
||||
|
||||
#define dgBank0F "__OTR__sound/banks/us/0F_bank"
|
||||
static const ALIGN_ASSET(2) char gBank0F[] = dgBank0F;
|
||||
|
||||
#define dgBank10 "__OTR__sound/banks/us/10_bank"
|
||||
static const ALIGN_ASSET(2) char gBank10[] = dgBank10;
|
||||
|
||||
#define dgBank11 "__OTR__sound/banks/us/11_bank"
|
||||
static const ALIGN_ASSET(2) char gBank11[] = dgBank11;
|
||||
|
||||
#define dgBank12 "__OTR__sound/banks/us/12_bank"
|
||||
static const ALIGN_ASSET(2) char gBank12[] = dgBank12;
|
||||
|
||||
#define dgBank13 "__OTR__sound/banks/us/13_bank"
|
||||
static const ALIGN_ASSET(2) char gBank13[] = dgBank13;
|
||||
|
||||
#define dgBank14 "__OTR__sound/banks/us/14_bank"
|
||||
static const ALIGN_ASSET(2) char gBank14[] = dgBank14;
|
||||
|
||||
#define dgBank15 "__OTR__sound/banks/us/15_bank"
|
||||
static const ALIGN_ASSET(2) char gBank15[] = dgBank15;
|
||||
|
||||
#define dgBank16 "__OTR__sound/banks/us/16_bank"
|
||||
static const ALIGN_ASSET(2) char gBank16[] = dgBank16;
|
||||
|
||||
#define dgBank17 "__OTR__sound/banks/us/17_bank"
|
||||
static const ALIGN_ASSET(2) char gBank17[] = dgBank17;
|
||||
|
||||
#define dgBank18 "__OTR__sound/banks/us/18_bank"
|
||||
static const ALIGN_ASSET(2) char gBank18[] = dgBank18;
|
||||
|
||||
#define dgBank19 "__OTR__sound/banks/us/19_bank"
|
||||
static const ALIGN_ASSET(2) char gBank19[] = dgBank19;
|
||||
|
||||
#define dgBank1A "__OTR__sound/banks/us/1A_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1A[] = dgBank1A;
|
||||
|
||||
#define dgBank1B "__OTR__sound/banks/us/1B_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1B[] = dgBank1B;
|
||||
|
||||
#define dgBank1C "__OTR__sound/banks/us/1C_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1C[] = dgBank1C;
|
||||
|
||||
#define dgBank1D "__OTR__sound/banks/us/1D_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1D[] = dgBank1D;
|
||||
|
||||
#define dgBank1E "__OTR__sound/banks/us/1E_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1E[] = dgBank1E;
|
||||
|
||||
#define dgBank1F "__OTR__sound/banks/us/1F_bank"
|
||||
static const ALIGN_ASSET(2) char gBank1F[] = dgBank1F;
|
||||
|
||||
#define dgBank20 "__OTR__sound/banks/us/20_bank"
|
||||
static const ALIGN_ASSET(2) char gBank20[] = dgBank20;
|
||||
|
||||
#define dgBank21 "__OTR__sound/banks/us/21_bank"
|
||||
static const ALIGN_ASSET(2) char gBank21[] = dgBank21;
|
||||
|
||||
#define dgBank22 "__OTR__sound/banks/us/22_bank"
|
||||
static const ALIGN_ASSET(2) char gBank22[] = dgBank22;
|
||||
|
||||
#define dgBank23 "__OTR__sound/banks/us/23_bank"
|
||||
static const ALIGN_ASSET(2) char gBank23[] = dgBank23;
|
||||
|
||||
#define dgBank24 "__OTR__sound/banks/us/24_bank"
|
||||
static const ALIGN_ASSET(2) char gBank24[] = dgBank24;
|
||||
|
||||
#define dgBank25 "__OTR__sound/banks/us/25_bank"
|
||||
static const ALIGN_ASSET(2) char gBank25[] = dgBank25;
|
||||
|
||||
static const char* gBankTable[] = {
|
||||
gBank00, gBank01, gBank02, gBank03,
|
||||
gBank04, gBank05, gBank06, gBank07,
|
||||
gBank08, gBank09, gBank0A, gBank0B,
|
||||
gBank0C, gBank0D, gBank0E, gBank0F,
|
||||
gBank10, gBank11, gBank12, gBank13,
|
||||
gBank14, gBank15, gBank16, gBank17,
|
||||
gBank18, gBank19, gBank1A, gBank1B,
|
||||
gBank1C, gBank1D, gBank1E, gBank1F,
|
||||
gBank20, gBank21, gBank22, gBank23,
|
||||
gBank24, gBank25,
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "MemoryStream.h"
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <locale>
|
||||
|
||||
LUS::BinaryReader::BinaryReader(char* nBuffer, size_t nBufferSize) {
|
||||
mStream = std::make_shared<MemoryStream>(nBuffer, nBufferSize);
|
||||
@@ -57,7 +58,6 @@ int16_t LUS::BinaryReader::ReadInt16() {
|
||||
if (mEndianness != Endianness::Native) {
|
||||
result = BSWAP16(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,28 @@ uint64_t LUS::BinaryReader::ReadUInt64() {
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned short LUS::BinaryReader::ReadUShort() {
|
||||
unsigned short result = 0;
|
||||
mStream->Read((char*)&result, sizeof(unsigned short));
|
||||
|
||||
if (mEndianness != Endianness::Native) {
|
||||
result = BSWAP16(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
short LUS::BinaryReader::ReadShort() {
|
||||
short result = 0;
|
||||
mStream->Read((char*)&result, sizeof(short));
|
||||
|
||||
if (mEndianness != Endianness::Native) {
|
||||
result = BSWAP16(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float LUS::BinaryReader::ReadFloat() {
|
||||
float result = NAN;
|
||||
|
||||
@@ -169,6 +191,7 @@ std::string LUS::BinaryReader::ReadString() {
|
||||
for (int i = 0; i < numChars; i++) {
|
||||
res += ReadChar();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -188,6 +211,10 @@ std::string LUS::BinaryReader::ReadCString() {
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t LUS::BinaryReader::GetLength() {
|
||||
return mStream->GetLength();
|
||||
}
|
||||
|
||||
std::vector<char> LUS::BinaryReader::ToVector() {
|
||||
return mStream->ToVector();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class BinaryReader {
|
||||
|
||||
void Seek(int32_t offset, SeekOffsetType seekType);
|
||||
uint32_t GetBaseAddress();
|
||||
size_t GetLength();
|
||||
|
||||
void Read(int32_t length);
|
||||
void Read(char* buffer, int32_t length);
|
||||
@@ -34,6 +35,8 @@ class BinaryReader {
|
||||
uint16_t ReadUInt16();
|
||||
uint32_t ReadUInt32();
|
||||
uint64_t ReadUInt64();
|
||||
unsigned short ReadUShort();
|
||||
short ReadShort();
|
||||
float ReadFloat();
|
||||
double ReadDouble();
|
||||
std::string ReadString();
|
||||
|
||||
@@ -132,10 +132,11 @@ void LUS::BinaryWriter::Write(double value) {
|
||||
mStream->Write((char*)&value, sizeof(double));
|
||||
}
|
||||
|
||||
void LUS::BinaryWriter::Write(const std::string& str) {
|
||||
int strLen = str.size();
|
||||
Write(strLen);
|
||||
|
||||
void LUS::BinaryWriter::Write(const std::string& str, bool writeLength) {
|
||||
if(writeLength){
|
||||
int strLen = str.size();
|
||||
Write(strLen);
|
||||
}
|
||||
for (char c : str) {
|
||||
mStream->WriteByte(c);
|
||||
}
|
||||
@@ -145,6 +146,10 @@ void LUS::BinaryWriter::Write(char* srcBuffer, size_t length) {
|
||||
mStream->Write(srcBuffer, length);
|
||||
}
|
||||
|
||||
void LUS::BinaryWriter::WriteByte(char value) {
|
||||
mStream->WriteByte(value);
|
||||
}
|
||||
|
||||
std::vector<char> LUS::BinaryWriter::ToVector() {
|
||||
return mStream->ToVector();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ class BinaryWriter {
|
||||
void Write(uint64_t value);
|
||||
void Write(float value);
|
||||
void Write(double value);
|
||||
void Write(const std::string& str);
|
||||
void Write(const std::string& str, bool writeLength = true);
|
||||
void Write(char* srcBuffer, size_t length);
|
||||
void WriteByte(char value);
|
||||
|
||||
std::vector<char> ToVector();
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace PyUtils {
|
||||
template<typename T>
|
||||
std::vector<T> slice(std::vector<T> const &v, uint32_t m, uint32_t n = -1) {
|
||||
auto first = v.cbegin() + m;
|
||||
auto last = n == -1 ? v.cend() : v.cbegin() + n;
|
||||
|
||||
std::vector<T> vec(first, last);
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> range(uint32_t start, uint32_t end);
|
||||
|
||||
template<typename T>
|
||||
T max(std::vector<T> const &v) {
|
||||
T max = v[0];
|
||||
for (auto const &value: v) {
|
||||
if (value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
template<typename T>
|
||||
T min(std::vector<T> const &v) {
|
||||
T min = v[0];
|
||||
for (auto const &value: v) {
|
||||
if (value < min) {
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
template<typename T, typename X>
|
||||
std::vector<T> keys(std::unordered_map<T, X> const &map) {
|
||||
std::vector<T> result;
|
||||
for (auto const &pair: map) {
|
||||
result.push_back(pair.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
template<typename T, typename X>
|
||||
std::vector<T> keys(std::map<T, X> const &map) {
|
||||
std::vector<T> result;
|
||||
for (auto const &pair: map) {
|
||||
result.push_back(pair.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> operator+(std::vector<T> const &x, std::vector<T> const &y)
|
||||
{
|
||||
std::vector<T> vec;
|
||||
vec.reserve(x.size() + y.size());
|
||||
vec.insert(vec.end(), x.begin(), x.end());
|
||||
vec.insert(vec.end(), y.begin(), y.end());
|
||||
return vec;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <any>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
|
||||
template<class TupType, size_t... I>
|
||||
void print_tuple(const TupType& _tup, std::index_sequence<I...>)
|
||||
{
|
||||
std::cout << "(";
|
||||
(..., (std::cout << (I == 0? "" : ", ") << std::get<I>(_tup)));
|
||||
std::cout << ")\n";
|
||||
}
|
||||
|
||||
template<class... T>
|
||||
void print_tuple(const std::tuple<T...>& _tup)
|
||||
{
|
||||
print_tuple(_tup, std::make_index_sequence<sizeof...(T)>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void variatic_min(std::vector<T> v, int &m) {
|
||||
if (m > v.size()) m = v.size();
|
||||
}
|
||||
|
||||
template<int N, typename... Ts>
|
||||
using NthTypeOf = typename std::tuple_element<N, std::tuple<Ts...>>::type;
|
||||
|
||||
template <typename... Result, std::size_t... Indices>
|
||||
auto vec_to_tup_helper(const std::vector<std::any>& v, std::index_sequence<Indices...>) {
|
||||
return std::make_tuple(
|
||||
std::any_cast<NthTypeOf<Indices, Result...>>(v[Indices])...
|
||||
);
|
||||
}
|
||||
|
||||
template <typename ...Result>
|
||||
std::tuple<Result...> vec_to_tup(std::vector<std::any>& values) {
|
||||
return vec_to_tup_helper<Result...>(values, std::make_index_sequence<sizeof...(Result)>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void celem_at(std::vector<T> v, int i, std::vector<std::any> &r) {
|
||||
r.push_back(v[i]);
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
std::vector<std::tuple<Types...>> zip(std::vector<Types>... args) {
|
||||
int m = 0xFFFFFFFF;
|
||||
std::vector<std::tuple<Types...>> res;
|
||||
|
||||
(variatic_min(args, m), ...);
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
std::vector<std::any> vaux;
|
||||
(celem_at(args, i, vaux), ...);
|
||||
res.push_back(vec_to_tup<Types...>(vaux));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
+717
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"00_sound_player": ["00", "01_terrain", "02_water", "03", "04", "05", "06", "07", "08_mario", "09", "0A_mario_peach"],
|
||||
"01_cutscene_collect_star": ["22"],
|
||||
"02_menu_title_screen": ["11"],
|
||||
"03_level_grass": ["22"],
|
||||
"04_level_inside_castle": ["0E"],
|
||||
"05_level_water": ["13"],
|
||||
"06_level_hot": ["0F"],
|
||||
"07_level_boss_koopa": ["12"],
|
||||
"08_level_snow": ["0B"],
|
||||
"09_level_slide": ["0D"],
|
||||
"0A_level_spooky": ["10", "21"],
|
||||
"0B_event_piranha_plant": ["14_piranha_music_box"],
|
||||
"0C_level_underground": ["15"],
|
||||
"0D_menu_star_select": ["16_course_start"],
|
||||
"0E_event_powerup": ["17"],
|
||||
"0F_event_metal_cap": ["18"],
|
||||
"10_event_koopa_message": ["12"],
|
||||
"11_level_koopa_road": ["19"],
|
||||
"12_event_high_score": ["1F"],
|
||||
"13_event_merry_go_round": ["21"],
|
||||
"14_event_race": ["1A"],
|
||||
"15_cutscene_star_spawn": ["0E"],
|
||||
"16_event_boss": ["1B"],
|
||||
"17_cutscene_collect_key": ["1A"],
|
||||
"18_event_endless_stairs": ["1C_endless_stairs"],
|
||||
"19_level_boss_koopa_final": ["1D_bowser_organ"],
|
||||
"1A_cutscene_credits": ["25"],
|
||||
"1B_event_solve_puzzle": ["14_piranha_music_box"],
|
||||
"1C_event_toad_message": ["20"],
|
||||
"1D_event_peach_message": ["1E"],
|
||||
"1E_cutscene_intro": ["1B"],
|
||||
"1F_cutscene_victory": ["1A"],
|
||||
"20_cutscene_ending": ["23"],
|
||||
"21_menu_file_select": ["24"],
|
||||
"22_cutscene_lakitu": ["1B"]
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
#pragma once
|
||||
#include "align_asset_macro.h"
|
||||
|
||||
#define dgSequence01 "__OTR__sound/sequences/01_cutscene_collect_star.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence01[] = dgSequence01;
|
||||
|
||||
#define dgSequence02 "__OTR__sound/sequences/02_menu_title_screen.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence02[] = dgSequence02;
|
||||
|
||||
#define dgSequence03 "__OTR__sound/sequences/03_level_grass.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence03[] = dgSequence03;
|
||||
|
||||
#define dgSequence04 "__OTR__sound/sequences/04_level_inside_castle.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence04[] = dgSequence04;
|
||||
|
||||
#define dgSequence05 "__OTR__sound/sequences/05_level_water.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence05[] = dgSequence05;
|
||||
|
||||
#define dgSequence06 "__OTR__sound/sequences/06_level_hot.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence06[] = dgSequence06;
|
||||
|
||||
#define dgSequence07 "__OTR__sound/sequences/07_level_boss_koopa.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence07[] = dgSequence07;
|
||||
|
||||
#define dgSequence08 "__OTR__sound/sequences/08_level_snow.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence08[] = dgSequence08;
|
||||
|
||||
#define dgSequence09 "__OTR__sound/sequences/09_level_slide.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence09[] = dgSequence09;
|
||||
|
||||
#define dgSequence0A "__OTR__sound/sequences/0A_level_spooky.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0A[] = dgSequence0A;
|
||||
|
||||
#define dgSequence0B "__OTR__sound/sequences/0B_event_piranha_plant.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0B[] = dgSequence0B;
|
||||
|
||||
#define dgSequence0C "__OTR__sound/sequences/0C_level_underground.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0C[] = dgSequence0C;
|
||||
|
||||
#define dgSequence0D "__OTR__sound/sequences/0D_menu_star_select.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0D[] = dgSequence0D;
|
||||
|
||||
#define dgSequence0E "__OTR__sound/sequences/0E_event_powerup.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0E[] = dgSequence0E;
|
||||
|
||||
#define dgSequence0F "__OTR__sound/sequences/0F_event_metal_cap.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence0F[] = dgSequence0F;
|
||||
|
||||
#define dgSequence10 "__OTR__sound/sequences/10_event_koopa_message.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence10[] = dgSequence10;
|
||||
|
||||
#define dgSequence11 "__OTR__sound/sequences/11_level_koopa_road.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence11[] = dgSequence11;
|
||||
|
||||
#define dgSequence12 "__OTR__sound/sequences/12_event_high_score.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence12[] = dgSequence12;
|
||||
|
||||
#define dgSequence13 "__OTR__sound/sequences/13_event_merry_go_round.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence13[] = dgSequence13;
|
||||
|
||||
#define dgSequence14 "__OTR__sound/sequences/14_event_race.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence14[] = dgSequence14;
|
||||
|
||||
#define dgSequence15 "__OTR__sound/sequences/15_cutscene_star_spawn.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence15[] = dgSequence15;
|
||||
|
||||
#define dgSequence16 "__OTR__sound/sequences/16_event_boss.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence16[] = dgSequence16;
|
||||
|
||||
#define dgSequence17 "__OTR__sound/sequences/17_cutscene_collect_key.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence17[] = dgSequence17;
|
||||
|
||||
#define dgSequence18 "__OTR__sound/sequences/18_event_endless_stairs.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence18[] = dgSequence18;
|
||||
|
||||
#define dgSequence19 "__OTR__sound/sequences/19_level_boss_koopa_final.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence19[] = dgSequence19;
|
||||
|
||||
#define dgSequence1A "__OTR__sound/sequences/1A_cutscene_credits.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1A[] = dgSequence1A;
|
||||
|
||||
#define dgSequence1B "__OTR__sound/sequences/1B_event_solve_puzzle.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1B[] = dgSequence1B;
|
||||
|
||||
#define dgSequence1C "__OTR__sound/sequences/1C_event_toad_message.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1C[] = dgSequence1C;
|
||||
|
||||
#define dgSequence1D "__OTR__sound/sequences/1D_event_peach_message.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1D[] = dgSequence1D;
|
||||
|
||||
#define dgSequence1E "__OTR__sound/sequences/1E_cutscene_intro.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1E[] = dgSequence1E;
|
||||
|
||||
#define dgSequence1F "__OTR__sound/sequences/1F_cutscene_victory.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence1F[] = dgSequence1F;
|
||||
|
||||
#define dgSequence20 "__OTR__sound/sequences/20_cutscene_ending.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence20[] = dgSequence20;
|
||||
|
||||
#define dgSequence21 "__OTR__sound/sequences/21_menu_file_select.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence21[] = dgSequence21;
|
||||
|
||||
#define dgSequence22 "__OTR__sound/sequences/22_cutscene_lakitu.m64"
|
||||
static const ALIGN_ASSET(2) char gSequence22[] = dgSequence22;
|
||||
|
||||
static const char* gSequenceTable[] = {
|
||||
gSequence01,
|
||||
gSequence02,
|
||||
gSequence03,
|
||||
gSequence04,
|
||||
gSequence05,
|
||||
gSequence06,
|
||||
gSequence07,
|
||||
gSequence08,
|
||||
gSequence09,
|
||||
gSequence0A,
|
||||
gSequence0B,
|
||||
gSequence0C,
|
||||
gSequence0D,
|
||||
gSequence0E,
|
||||
gSequence0F,
|
||||
gSequence10,
|
||||
gSequence11,
|
||||
gSequence12,
|
||||
gSequence13,
|
||||
gSequence14,
|
||||
gSequence15,
|
||||
gSequence16,
|
||||
gSequence17,
|
||||
gSequence18,
|
||||
gSequence19,
|
||||
gSequence1A,
|
||||
gSequence1B,
|
||||
gSequence1C,
|
||||
gSequence1D,
|
||||
gSequence1E,
|
||||
gSequence1F,
|
||||
gSequence20,
|
||||
gSequence21,
|
||||
gSequence22,
|
||||
};
|
||||
+15
-5
@@ -2,8 +2,10 @@
|
||||
|
||||
#include "storm/SWrapper.h"
|
||||
#include "utils/MIODecoder.h"
|
||||
#include "audio/AudioManager.h"
|
||||
#include "factories/RawFactory.h"
|
||||
#include "factories/BlobFactory.h"
|
||||
#include "factories/AudioFactory.h"
|
||||
#include "factories/TextureFactory.h"
|
||||
#include "factories/AnimFactory.h"
|
||||
|
||||
@@ -18,9 +20,12 @@ namespace fs = std::filesystem;
|
||||
static const std::unordered_map<std::string, RawFactory*> gFactories = {
|
||||
{ ".png", new TextureFactory() },
|
||||
{ ".anim", new AnimFactory() },
|
||||
{ ".aiff", new AudioFactory() },
|
||||
{ ".bnk", new AudioFactory() },
|
||||
{ ".bset", new AudioFactory() },
|
||||
{ ".m64", new AudioFactory() },
|
||||
{ ".bin", new BlobFactory(LUS::ResourceType::Blob) },
|
||||
{ ".sbox", new BlobFactory(LUS::ResourceType::Blob, true) },
|
||||
{ ".aud", new BlobFactory(LUS::ResourceType::Blob, false) },
|
||||
};
|
||||
|
||||
void Companion::Start() {
|
||||
@@ -34,6 +39,9 @@ void Companion::Start() {
|
||||
|
||||
std::cout << "Detected Rom Size: " << this->gRomData.size() << '\n';
|
||||
|
||||
AudioManager::Instance = new AudioManager();
|
||||
AudioManager::Instance->initialize(this->gRomData);
|
||||
|
||||
this->ProcessAssets();
|
||||
}
|
||||
|
||||
@@ -45,7 +53,7 @@ void Companion::ProcessAssets() {
|
||||
for( auto& [asset, data] : assets.items() ) {
|
||||
std::string extension = fs::path(asset).extension().string();
|
||||
if( gFactories.find(extension) == gFactories.end() ) {
|
||||
std::cout << "No factory found for " << asset << '\n';
|
||||
std::cout << "No factory found for " << asset << '\n';
|
||||
continue;
|
||||
}
|
||||
LUS::BinaryWriter write = LUS::BinaryWriter();
|
||||
@@ -57,7 +65,7 @@ void Companion::ProcessAssets() {
|
||||
RawFactory* factory = gFactories.at(extension);
|
||||
|
||||
if(!factory->process(&write, entry, this->gRomData)){
|
||||
std::cout << "Failed to process " << asset << '\n';
|
||||
std::cout << "Failed to process " << asset << '\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -70,13 +78,15 @@ void Companion::ProcessAssets() {
|
||||
if(!isTexture) {
|
||||
// Write to file too
|
||||
std::string dpath = "debug/" + path;
|
||||
fs::create_directories(fs::path(dpath).parent_path());
|
||||
if(!fs::exists(fs::path(dpath).parent_path())){
|
||||
fs::create_directories(fs::path(dpath).parent_path());
|
||||
}
|
||||
std::ofstream output(dpath, std::ios::binary);
|
||||
output.write((char*)buffer.data(), buffer.size());
|
||||
output.close();
|
||||
}
|
||||
|
||||
std::cout << "Processed " << path << std::endl;
|
||||
std::cout << "Processed " << path << std::endl;
|
||||
|
||||
write.Close();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "BinaryWriter.h"
|
||||
|
||||
void write_aiff(std::vector<char> data, LUS::BinaryWriter& writer);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,161 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "binarytools/BinaryWriter.h"
|
||||
|
||||
#define NONE 0xFFFF
|
||||
#define ALIGN(val, al) (size_t) ((val + (al - 1)) & -al)
|
||||
|
||||
namespace AIFC {
|
||||
enum MagicValues {
|
||||
FORM = 0x464f524d,
|
||||
AIFC = 0x41494643,
|
||||
COMM = 0x434f4d4d,
|
||||
INST = 0x494e5354,
|
||||
VAPC = 0x56415043,
|
||||
SSND = 0x53534e44,
|
||||
AAPL = 0x4150504c,
|
||||
stoc = 0x73746f63,
|
||||
};
|
||||
}
|
||||
|
||||
struct Entry {
|
||||
uint32_t offset;
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
struct AudioBankSound {
|
||||
uint32_t offset;
|
||||
float tuning;
|
||||
bool operator==(const AudioBankSound& other) const {
|
||||
return offset == other.offset && tuning == other.tuning;
|
||||
}
|
||||
};
|
||||
|
||||
struct Instrument {
|
||||
bool valid;
|
||||
std::string name;
|
||||
uint32_t offset;
|
||||
uint8_t releaseRate;
|
||||
uint8_t normalRangeLo;
|
||||
uint8_t normalRangeHi;
|
||||
uint32_t envelope;
|
||||
std::optional<AudioBankSound> soundLo;
|
||||
std::optional<AudioBankSound> soundMed;
|
||||
std::optional<AudioBankSound> soundHi;
|
||||
};
|
||||
|
||||
struct AdpcmBook {
|
||||
int32_t order{};
|
||||
int32_t npredictors{};
|
||||
std::vector<int16_t> table;
|
||||
bool operator==(const AdpcmBook& other) const {
|
||||
return order == other.order && npredictors == other.npredictors && table == other.table;
|
||||
}
|
||||
};
|
||||
|
||||
struct Drum {
|
||||
std::string name;
|
||||
uint32_t offset;
|
||||
uint8_t releaseRate;
|
||||
uint8_t pan;
|
||||
uint32_t envelope;
|
||||
AudioBankSound sound;
|
||||
bool operator==(const Drum& other) const {
|
||||
return name == other.name && offset == other.offset && releaseRate == other.releaseRate && pan == other.pan && envelope == other.envelope && sound == other.sound;
|
||||
}
|
||||
};
|
||||
|
||||
struct AdpcmLoop {
|
||||
uint32_t start{};
|
||||
uint32_t end{};
|
||||
int32_t count{};
|
||||
uint32_t pad{};
|
||||
std::optional<std::vector<int16_t>> state;
|
||||
bool operator==(const AdpcmLoop& other) const {
|
||||
return start == other.start && end == other.end && count == other.count && pad == other.pad && state == other.state;
|
||||
}
|
||||
};
|
||||
|
||||
struct AudioBankSample {
|
||||
std::string name;
|
||||
std::vector<uint8_t> data;
|
||||
AdpcmBook book;
|
||||
AdpcmLoop loop;
|
||||
std::vector<float> tunings;
|
||||
};
|
||||
|
||||
struct SampleBank {
|
||||
std::string name;
|
||||
uint32_t offset;
|
||||
std::vector<uint8_t> data;
|
||||
std::map<uint32_t, AudioBankSample*> entries;
|
||||
|
||||
AudioBankSample* AddSample(uint32_t addr, size_t sampleSize, const AdpcmBook& book, const AdpcmLoop& loop);
|
||||
};
|
||||
|
||||
struct TBLFile {
|
||||
std::vector<SampleBank*> banks;
|
||||
std::vector<std::string> tbls;
|
||||
std::map<std::string, SampleBank*> map;
|
||||
};
|
||||
|
||||
struct CTLHeader {
|
||||
uint32_t instruments;
|
||||
uint32_t numDrums;
|
||||
uint32_t shared;
|
||||
};
|
||||
|
||||
struct AdsrEnvelope {
|
||||
int16_t delay;
|
||||
int16_t arg;
|
||||
};
|
||||
|
||||
struct Envelope {
|
||||
std::string name;
|
||||
std::vector<AdsrEnvelope> entries;
|
||||
};
|
||||
|
||||
struct Bank {
|
||||
std::string name;
|
||||
SampleBank* sampleBank;
|
||||
std::vector<Instrument> insts;
|
||||
std::vector<Drum> drums;
|
||||
std::vector<std::variant<Instrument, std::vector<Drum>>> allInsts;
|
||||
std::vector<uint32_t> instOffsets;
|
||||
std::map<uint32_t, Envelope> envelopes;
|
||||
std::map<uint32_t, AudioBankSample*> samples;
|
||||
void print() const;
|
||||
};
|
||||
|
||||
class AudioManager {
|
||||
public:
|
||||
static AudioManager* Instance;
|
||||
void initialize(std::vector<uint8_t>& buffer);
|
||||
void create_aifc(int32_t index, LUS::BinaryWriter& writer);
|
||||
AudioBankSample get_aifc(int32_t index);
|
||||
std::map<uint32_t, Bank> get_banks();
|
||||
uint32_t get_index(AudioBankSample* bank);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, Bank> banks;
|
||||
std::map<AudioBankSample*, uint32_t> sampleMap;
|
||||
TBLFile loaded_tbl;
|
||||
|
||||
static std::vector<Entry> parse_seq_file(std::vector<uint8_t>& buffer, uint32_t offset, bool isCTL);
|
||||
static CTLHeader parse_ctl_header(std::vector<uint8_t>& data);
|
||||
static std::optional<AudioBankSound> parse_sound(std::vector<uint8_t> data);
|
||||
static Drum parse_drum(std::vector<uint8_t>& data, uint32_t addr);
|
||||
static Instrument parse_inst(std::vector<uint8_t>& data, uint32_t addr);
|
||||
static AdpcmLoop parse_loop(uint32_t addr, std::vector<uint8_t>& bankData);
|
||||
static AdpcmBook parse_book(uint32_t addr, std::vector<uint8_t>& bankData);
|
||||
static AudioBankSample* parse_sample(std::vector<uint8_t>& data, std::vector<uint8_t>& bankData, SampleBank* sampleBank);
|
||||
static std::vector<AdsrEnvelope> parse_envelope(uint32_t addr, std::vector<uint8_t>& dataBank);
|
||||
static Bank parse_ctl(CTLHeader header, std::vector<uint8_t> data, SampleBank* bank, uint32_t index);
|
||||
static TBLFile parse_tbl(std::vector<uint8_t>& data, std::vector<Entry>& entries);
|
||||
|
||||
static void write_aifc(AudioBankSample* entry, LUS::BinaryWriter& writer);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,191 @@
|
||||
#include "AudioFactory.h"
|
||||
|
||||
#include <vector>
|
||||
#include "audio/AudioManager.h"
|
||||
#include "audio/samples_table.h"
|
||||
#include "binarytools/BinaryReader.h"
|
||||
|
||||
bool AudioFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::vector<uint8_t>& buffer) {
|
||||
auto metadata = data["offsets"];
|
||||
std::string path = data["path"];
|
||||
|
||||
if(path.find("bank_sets") != std::string::npos){
|
||||
WRITE_HEADER(LUS::ResourceType::Blob, 0);
|
||||
char* raw = (char*) (buffer.data() + metadata[1]["us"][0]);
|
||||
WRITE_U32(metadata[0]);
|
||||
for(int i = 0; i < 0x23; i++){
|
||||
int16_t value;
|
||||
memcpy(&value, raw + (i * 2), 2);
|
||||
WRITE_I16(BSWAP16(value));
|
||||
}
|
||||
writer->Write(raw + 0x46, 0x5A);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(path.find("sound/banks") != std::string::npos){
|
||||
auto banks = AudioManager::Instance->get_banks();
|
||||
auto bankId = metadata["us"][0];
|
||||
auto bank = banks[bankId];
|
||||
|
||||
if(bankId == 10){
|
||||
int bp = 1;
|
||||
}
|
||||
|
||||
WRITE_HEADER(LUS::ResourceType::Bank, 0);
|
||||
|
||||
WRITE_U32(bank.insts.size());
|
||||
for(auto &instrument : bank.insts){
|
||||
WRITE_U8(instrument.valid);
|
||||
if(!instrument.valid){
|
||||
continue;
|
||||
}
|
||||
WRITE_U8(instrument.releaseRate);
|
||||
WRITE_U8(instrument.normalRangeLo);
|
||||
WRITE_U8(instrument.normalRangeHi);
|
||||
|
||||
auto envelope = bank.envelopes[instrument.envelope];
|
||||
if(!envelope.entries.empty()){
|
||||
WRITE_U32(envelope.entries.size());
|
||||
for(auto &entry : envelope.entries){
|
||||
writer->Write(entry.delay);
|
||||
writer->Write(entry.arg);
|
||||
}
|
||||
} else {
|
||||
WRITE_U32(0);
|
||||
}
|
||||
|
||||
uint32_t soundFlags = 0;
|
||||
bool hasLo = instrument.soundLo.has_value();
|
||||
bool hasMed = instrument.soundMed.has_value();
|
||||
bool hasHi = instrument.soundHi.has_value();
|
||||
if(hasLo){
|
||||
soundFlags |= (1 << 0);
|
||||
}
|
||||
if(hasMed){
|
||||
soundFlags |= (1 << 1);
|
||||
}
|
||||
if(hasHi){
|
||||
soundFlags |= (1 << 2);
|
||||
}
|
||||
|
||||
WRITE_U32(soundFlags);
|
||||
if(hasLo){
|
||||
auto value = instrument.soundLo.value();
|
||||
uint32_t idx = AudioManager::Instance->get_index(bank.samples[value.offset]);
|
||||
writer->Write(std::string(gSampleTable[idx]));
|
||||
writer->Write(value.tuning);
|
||||
}
|
||||
if(hasMed){
|
||||
auto value = instrument.soundMed.value();
|
||||
uint32_t idx = AudioManager::Instance->get_index(bank.samples[value.offset]);
|
||||
writer->Write(std::string(gSampleTable[idx]));
|
||||
writer->Write(value.tuning);
|
||||
}
|
||||
if(hasHi){
|
||||
auto value = instrument.soundHi.value();
|
||||
uint32_t idx = AudioManager::Instance->get_index(bank.samples[value.offset]);
|
||||
writer->Write(std::string(gSampleTable[idx]));
|
||||
writer->Write(value.tuning);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WRITE_U32(bank.drums.size());
|
||||
for(auto &drum : bank.drums){
|
||||
WRITE_U8(drum.releaseRate);
|
||||
WRITE_U8(drum.pan);
|
||||
auto envelope = bank.envelopes[drum.envelope];
|
||||
if(!envelope.entries.empty()){
|
||||
std::cout << "Envelope entries: " << envelope.entries.size() << std::endl;
|
||||
WRITE_U32(envelope.entries.size());
|
||||
for(auto &entry : envelope.entries){
|
||||
writer->Write(entry.delay);
|
||||
writer->Write(entry.arg);
|
||||
}
|
||||
} else {
|
||||
WRITE_U32(0);
|
||||
}
|
||||
|
||||
uint32_t idx = AudioManager::Instance->get_index(bank.samples[drum.sound.offset]);
|
||||
std::string out = std::string(gSampleTable[idx]);
|
||||
writer->Write(out);
|
||||
writer->Write(drum.sound.tuning);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(path.find("sound/sequences") != std::string::npos){
|
||||
|
||||
if(!metadata[1].contains("us")){
|
||||
return false;
|
||||
}
|
||||
|
||||
WRITE_HEADER(LUS::ResourceType::Sequence, 0);
|
||||
|
||||
size_t size = metadata[0];
|
||||
auto offsets = metadata[1]["us"];
|
||||
|
||||
std::vector<uint8_t> bank = metadata[1]["banks"];
|
||||
|
||||
WRITE_U32(bank.size());
|
||||
WRITE_ARRAY(bank.data(), bank.size());
|
||||
|
||||
WRITE_U32(size);
|
||||
WRITE_ARRAY(buffer.data() + (size_t)offsets[0], size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(path.find("sound/samples") == std::string::npos || metadata.size() < 2 || !metadata[1].contains("us")){
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* HINT: Uncomment this to write the aiff to a file
|
||||
LUS::BinaryWriter aifcWriter;
|
||||
AudioManager::Instance->create_aifc(metadata[1]["us"][1], aifcWriter);
|
||||
std::vector<char> aifcData = aifcWriter.ToVector();
|
||||
aifcWriter.Close();
|
||||
write_aiff(aifcData, *writer);
|
||||
*/
|
||||
|
||||
WRITE_HEADER(LUS::ResourceType::Sample, 0);
|
||||
|
||||
AudioBankSample entry = AudioManager::Instance->get_aifc(metadata[1]["us"][1]);
|
||||
|
||||
// Write AdpcmLoop
|
||||
WRITE_U32(entry.loop.start);
|
||||
WRITE_U32(entry.loop.end);
|
||||
WRITE_I32(entry.loop.count);
|
||||
WRITE_U32(entry.loop.pad);
|
||||
|
||||
if(entry.loop.state.has_value()){
|
||||
std::vector<int16_t> state = entry.loop.state.value();
|
||||
WRITE_U32(state.size());
|
||||
for(auto &value : state){
|
||||
writer->Write(value);
|
||||
}
|
||||
} else {
|
||||
WRITE_U32(0);
|
||||
}
|
||||
|
||||
// Write AdpcmBook
|
||||
WRITE_I32(entry.book.order);
|
||||
WRITE_I32(entry.book.npredictors);
|
||||
|
||||
WRITE_U32(entry.book.table.size());
|
||||
for(auto &value : entry.book.table){
|
||||
writer->Write(value);
|
||||
}
|
||||
|
||||
// Write sample
|
||||
WRITE_I32(entry.data.size());
|
||||
for(auto &value : entry.data){
|
||||
WRITE_U8(value);
|
||||
}
|
||||
|
||||
writer->Write(entry.name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "RawFactory.h"
|
||||
|
||||
class AudioFactory : public RawFactory {
|
||||
public:
|
||||
AudioFactory() = default;
|
||||
bool process(LUS::BinaryWriter* write, nlohmann::json& data, std::vector<uint8_t>& buffer) override;
|
||||
};
|
||||
@@ -13,11 +13,7 @@ bool BlobFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this->bigEndian){
|
||||
WRITE_BHEADER(this->type, 0);
|
||||
} else {
|
||||
WRITE_HEADER(this->type, 0);
|
||||
}
|
||||
WRITE_HEADER(this->type, 0);
|
||||
|
||||
size_t size = metadata[0];
|
||||
auto offsets = metadata[1]["us"];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user