mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Added full bank extraction
This commit is contained in:
+39
@@ -1121,6 +1121,7 @@
|
||||
"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/bank_sets.bset": [159, { "us": [8177185] }],
|
||||
"@sound_data": {
|
||||
"us": {
|
||||
"bank_sets": [8177184, 160],
|
||||
@@ -1128,6 +1129,44 @@
|
||||
"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,
|
||||
};
|
||||
@@ -44,6 +44,14 @@ std::vector<T> keys(std::unordered_map<T, X> const &map) {
|
||||
}
|
||||
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>
|
||||
|
||||
+717
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,8 @@ static const std::unordered_map<std::string, RawFactory*> gFactories = {
|
||||
{ ".png", new TextureFactory() },
|
||||
{ ".anim", new AnimFactory() },
|
||||
{ ".aiff", new AudioFactory() },
|
||||
{ ".bnk", new AudioFactory() },
|
||||
{ ".bset", new AudioFactory() },
|
||||
{ ".bin", new BlobFactory(LUS::ResourceType::Blob) },
|
||||
{ ".m64", new BlobFactory(LUS::ResourceType::Blob) },
|
||||
{ ".sbox", new BlobFactory(LUS::ResourceType::Blob, true) },
|
||||
|
||||
+220
-167
File diff suppressed because it is too large
Load Diff
+44
-36
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include "binarytools/BinaryWriter.h"
|
||||
|
||||
#define NONE 0xFFFF
|
||||
@@ -27,31 +27,32 @@ struct Entry {
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
struct Sound {
|
||||
struct AudioBankSound {
|
||||
uint32_t offset;
|
||||
float tuning;
|
||||
bool operator==(const Sound& other) const {
|
||||
bool operator==(const AudioBankSound& other) const {
|
||||
return offset == other.offset && tuning == other.tuning;
|
||||
}
|
||||
};
|
||||
|
||||
struct Inst {
|
||||
struct Instrument {
|
||||
bool valid;
|
||||
std::string name;
|
||||
uint32_t offset;
|
||||
uint8_t releaseRate;
|
||||
uint8_t normalRangeLo;
|
||||
uint8_t normalRangeHi;
|
||||
uint32_t envelope;
|
||||
std::optional<Sound> soundLo;
|
||||
std::optional<Sound> soundMed;
|
||||
std::optional<Sound> soundHi;
|
||||
std::optional<AudioBankSound> soundLo;
|
||||
std::optional<AudioBankSound> soundMed;
|
||||
std::optional<AudioBankSound> soundHi;
|
||||
};
|
||||
|
||||
struct Book {
|
||||
uint32_t order{};
|
||||
uint32_t npredictors{};
|
||||
std::vector<short> table;
|
||||
bool operator==(const Book& other) const {
|
||||
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;
|
||||
}
|
||||
};
|
||||
@@ -62,28 +63,28 @@ struct Drum {
|
||||
uint8_t releaseRate;
|
||||
uint8_t pan;
|
||||
uint32_t envelope;
|
||||
Sound sound;
|
||||
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 Loop {
|
||||
struct AdpcmLoop {
|
||||
uint32_t start{};
|
||||
uint32_t end{};
|
||||
int32_t count{};
|
||||
uint32_t pad{};
|
||||
std::optional<std::vector<short>> state;
|
||||
bool operator==(const Loop& other) const {
|
||||
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 AifcEntry {
|
||||
struct AudioBankSample {
|
||||
std::string name;
|
||||
std::vector<uint8_t> data;
|
||||
Book book;
|
||||
Loop loop;
|
||||
AdpcmBook book;
|
||||
AdpcmLoop loop;
|
||||
std::vector<float> tunings;
|
||||
};
|
||||
|
||||
@@ -91,15 +92,15 @@ struct SampleBank {
|
||||
std::string name;
|
||||
uint32_t offset;
|
||||
std::vector<uint8_t> data;
|
||||
std::unordered_map<uint32_t, AifcEntry*> entries;
|
||||
std::map<uint32_t, AudioBankSample*> entries;
|
||||
|
||||
AifcEntry* AddSample(uint32_t addr, size_t sampleSize, const Book& book, const Loop& loop);
|
||||
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::unordered_map<std::string, SampleBank*> map;
|
||||
std::map<std::string, SampleBank*> map;
|
||||
};
|
||||
|
||||
struct CTLHeader {
|
||||
@@ -108,22 +109,25 @@ struct CTLHeader {
|
||||
uint32_t shared;
|
||||
};
|
||||
|
||||
typedef std::pair<unsigned short, unsigned short> EnvelopeData;
|
||||
struct AdsrEnvelope {
|
||||
int16_t delay;
|
||||
int16_t arg;
|
||||
};
|
||||
|
||||
struct Envelope {
|
||||
std::string name;
|
||||
std::vector<EnvelopeData> entries;
|
||||
std::vector<AdsrEnvelope> entries;
|
||||
};
|
||||
|
||||
struct Bank {
|
||||
std::string name;
|
||||
SampleBank* sampleBank;
|
||||
std::vector<Inst> insts;
|
||||
std::vector<Instrument> insts;
|
||||
std::vector<Drum> drums;
|
||||
std::vector<std::variant<Inst, std::vector<Drum>>> allInsts;
|
||||
std::vector<std::variant<Instrument, std::vector<Drum>>> allInsts;
|
||||
std::vector<uint32_t> instOffsets;
|
||||
std::unordered_map<uint32_t, Envelope> envelopes;
|
||||
std::unordered_map<uint32_t, AifcEntry*> samples;
|
||||
std::map<uint32_t, Envelope> envelopes;
|
||||
std::map<uint32_t, AudioBankSample*> samples;
|
||||
void print() const;
|
||||
};
|
||||
|
||||
@@ -132,22 +136,26 @@ 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::vector<Bank> banks;
|
||||
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<Sound> parse_sound(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 Inst parse_inst(std::vector<uint8_t>& data, uint32_t addr);
|
||||
static Loop parse_loop(uint32_t addr, std::vector<uint8_t>& bankData);
|
||||
static Book parse_book(uint32_t addr, std::vector<uint8_t>& bankData);
|
||||
static AifcEntry* parse_sample(std::vector<uint8_t>& data, std::vector<uint8_t>& bankData, SampleBank* sampleBank);
|
||||
static std::vector<EnvelopeData> parse_envelope(uint32_t addr, std::vector<uint8_t>& dataBank);
|
||||
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(AifcEntry* entry, LUS::BinaryWriter& writer);
|
||||
static void write_aifc(AudioBankSample* entry, LUS::BinaryWriter& writer);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include "audio/AudioManager.h"
|
||||
#include "audio/AIFCDecode.h"
|
||||
#include "audio/samples_table.h"
|
||||
#include "binarytools/BinaryReader.h"
|
||||
|
||||
bool AudioFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::vector<uint8_t>& buffer) {
|
||||
@@ -22,16 +22,156 @@ bool AudioFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std:
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!metadata[1].contains("us")){
|
||||
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);
|
||||
|
||||
if(path.find("sound/banks/us/20_bank") != std::string::npos){
|
||||
int bp = 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(metadata.size() < 2 || !metadata[1].contains("us")){
|
||||
return false;
|
||||
}
|
||||
|
||||
LUS::BinaryWriter aifcWriter;
|
||||
AudioManager::Instance->create_aifc(metadata[1]["us"][1], aifcWriter);
|
||||
std::vector<char> aifcData = aifcWriter.ToVector();
|
||||
aifcWriter.Close();
|
||||
/*
|
||||
* 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_aiff(aifcData, *writer);
|
||||
WRITE_HEADER(LUS::ResourceType::Audio, 0);
|
||||
|
||||
AudioBankSample entry = AudioManager::Instance->get_aifc(metadata[1]["us"][1]);
|
||||
|
||||
if(path.find("00_mario_waaaooow") != std::string::npos){
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,13 @@
|
||||
|
||||
#define WRITE_HEADER(type, version) this->WriteHeader(writer, type, version)
|
||||
#define WRITE_BHEADER(type, version) this->WriteHeader(writer, type, version, true)
|
||||
#define WRITE_U8(value) writer->Write((uint8_t) value)
|
||||
#define WRITE_U16(value) writer->Write((uint16_t) value)
|
||||
#define WRITE_U32(value) writer->Write((uint32_t) value)
|
||||
#define WRITE_U64(value) writer->Write((uint64_t) value)
|
||||
#define WRITE_I8(value) writer->Write((int8_t) value)
|
||||
#define WRITE_I16(value) writer->Write((int16_t) value)
|
||||
#define WRITE_I32(value) writer->Write((int32_t) value)
|
||||
#define WRITE_DATA(vec) writer->Write((char*) vec.data(), data.size())
|
||||
#define WRITE_ARRAY(data, size) writer->Write((char*) data, size)
|
||||
|
||||
|
||||
@@ -19,5 +19,7 @@ enum class ResourceType {
|
||||
Demo = 0x44454D4F, // DEMO
|
||||
Skybox = 0x534B5942, // SKYB
|
||||
Anim = 0x414E494D, // ANIM
|
||||
Bank = 0x42414E4B, // BANK
|
||||
Audio = 0x41554643, // AIFC
|
||||
};
|
||||
} // namespace LUS
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
const fs = require('fs');
|
||||
const data = require('../assets.json');
|
||||
|
||||
const header = [
|
||||
'#pragma once',
|
||||
'#include "align_asset_macro.h"',
|
||||
'',
|
||||
]
|
||||
const banks = []
|
||||
|
||||
async function main(){
|
||||
const files = Object.keys(data).filter(f => f.endsWith(".bnk") && data[f]['us'] != undefined).map(m => {
|
||||
return {
|
||||
file: m,
|
||||
offset: data[m]['us'][0]
|
||||
}
|
||||
})
|
||||
|
||||
files.sort((a, b) => a.offset - b.offset);
|
||||
|
||||
for(const entry of files){
|
||||
const sampleId = entry.offset.toString(16).padStart(2, '0').toUpperCase();
|
||||
banks.push(`gBank${sampleId}`);
|
||||
header.push(`#define dgBank${sampleId} "__OTR__${entry.file.replace('.bnk', '')}"`);
|
||||
header.push(`static const ALIGN_ASSET(2) char gBank${sampleId}[] = dgBank${sampleId};\n`);
|
||||
}
|
||||
|
||||
header.push('static const char* gBankTable[] = {');
|
||||
for (const bank of banks) {
|
||||
header.push(` ${bank},`);
|
||||
}
|
||||
header.push('};\n');
|
||||
|
||||
fs.writeFileSync('./banks_table.h', header.join('\n'));
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,37 @@
|
||||
const fs = require('fs');
|
||||
const data = require('../assets.json');
|
||||
|
||||
const header = [
|
||||
'#pragma once',
|
||||
'#include "align_asset_macro.h"',
|
||||
'',
|
||||
]
|
||||
const samples = []
|
||||
|
||||
async function main(){
|
||||
const files = Object.keys(data).filter(f => f.endsWith(".aiff") && data[f][1]['us'] != undefined).map(m => {
|
||||
return {
|
||||
file: m,
|
||||
offset: data[m][1]['us'][1]
|
||||
}
|
||||
})
|
||||
|
||||
files.sort((a, b) => a.offset - b.offset);
|
||||
|
||||
for(const entry of files){
|
||||
const sampleId = entry.offset.toString(16).padStart(2, '0').toUpperCase();
|
||||
samples.push(`gSample${sampleId}`);
|
||||
header.push(`#define dgSample${sampleId} "__OTR__${entry.file.replace('.aiff', '')}"`);
|
||||
header.push(`static const ALIGN_ASSET(2) char gSample${sampleId}[] = dgSample${sampleId};\n`);
|
||||
}
|
||||
|
||||
header.push('static const char* gSampleTable[] = {');
|
||||
for (const sample of samples) {
|
||||
header.push(` ${sample},`);
|
||||
}
|
||||
header.push('};\n');
|
||||
|
||||
fs.writeFileSync('./samples_table.h', header.join('\n'));
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user