mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 23:10:10 +01:00
Merge pull request #1317 from bnnm/wave-hx
- Add DS .wave [Adventure Time: HIKWYSOG (DS)] - Fix some .HXX [XIII Beta (Xbox)]
This commit is contained in:
commit
2b0da2af33
@ -28,7 +28,7 @@ def parse():
|
||||
)
|
||||
|
||||
parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser.add_argument("files", help="files to match")
|
||||
parser.add_argument("files", help="files to match", nargs="+")
|
||||
parser.add_argument("-n","--name", help="generated txtp name (auto from 'files' by default)\nMay use regex groups like '\\1.ogg' when used with filter-include")
|
||||
parser.add_argument("-fi","--filter-include", help="include files matched with regex and ignore rest")
|
||||
parser.add_argument("-fe","--filter-exclude", help="exclude files matched with regex and keep rest")
|
||||
@ -41,6 +41,7 @@ def parse():
|
||||
parser.add_argument("-cv","--command-volume", help="sets volume")
|
||||
parser.add_argument("-c","--command", help="sets any command (free text)")
|
||||
parser.add_argument("-ci","--command-inline", help="sets any inline command (free text)")
|
||||
parser.add_argument("-m","--multi", help="only write txtp that have multiple results", action='store_true')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@ -102,7 +103,10 @@ def main():
|
||||
args.p_exclude = re.compile(args.filter_exclude, re.IGNORECASE)
|
||||
|
||||
# get target files
|
||||
files = glob.glob(args.files)
|
||||
files = []
|
||||
for file in args.files:
|
||||
print(file)
|
||||
files += glob.glob(file)
|
||||
|
||||
# process matches and add to output list
|
||||
txtps = {}
|
||||
@ -123,6 +127,8 @@ def main():
|
||||
|
||||
# list info
|
||||
for name, segments in txtps.items():
|
||||
if args.multi and len(segments) <= 1:
|
||||
continue
|
||||
print("file: " + name)
|
||||
for segment in segments:
|
||||
print(" " + segment)
|
||||
@ -133,6 +139,8 @@ def main():
|
||||
# write resulting files
|
||||
for name, segments in txtps.items():
|
||||
len_segments = len(segments)
|
||||
if args.multi and len_segments <= 1:
|
||||
continue
|
||||
with open(name,"w+") as ftxtp:
|
||||
for i, segment in enumerate(segments):
|
||||
command_inline = ''
|
||||
|
@ -250,8 +250,8 @@ static int parse_header(ubi_hx_header* hx, STREAMFILE* sf, uint32_t offset, uint
|
||||
read_u32_t read_u32 = hx->big_endian ? read_u32be : read_u32le;
|
||||
read_s32_t read_s32 = hx->big_endian ? read_s32be : read_s32le;
|
||||
read_u16_t read_u16 = hx->big_endian ? read_u16be : read_u16le;
|
||||
off_t riff_offset, riff_size, chunk_offset, stream_adjust = 0, resource_size;
|
||||
size_t chunk_size;
|
||||
uint32_t riff_offset, riff_size, stream_adjust = 0, resource_size, chunk_size;
|
||||
off_t chunk_offset;
|
||||
int cue_flag = 0;
|
||||
|
||||
//todo cleanup/unify common readings
|
||||
@ -339,7 +339,7 @@ static int parse_header(ubi_hx_header* hx, STREAMFILE* sf, uint32_t offset, uint
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("ubi hx: unknown stream mode %x\n", hx->stream_mode);
|
||||
VGM_LOG("ubi hx: unknown wave mode %x\n", hx->stream_mode);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -473,6 +473,7 @@ static int parse_header(ubi_hx_header* hx, STREAMFILE* sf, uint32_t offset, uint
|
||||
|
||||
switch(hx->stream_mode) {
|
||||
case 0x00: /* static (smaller internal file) [XIII (Xbox)] */
|
||||
case 0x02: /* static (smaller internal file) [XIII-beta (Xbox)] */
|
||||
hx->stream_offset += offset;
|
||||
break;
|
||||
|
||||
|
@ -16,8 +16,9 @@ VGMSTREAM* init_vgmstream_wave(STREAMFILE* sf) {
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "VAW3") && /* Happy Feet Two (3DS) */
|
||||
read_u32le(0x00,sf) != 0xE5B7ECFE && /* common (LE) */
|
||||
read_u32be(0x00,sf) != 0xE5B7ECFE) /* used? */
|
||||
read_u32le(0x00,sf) != 0xE5B7ECFE && /* common LE (hashed something?) */
|
||||
read_u32be(0x00,sf) != 0xE5B7ECFE &&
|
||||
read_u32be(0x00,sf) != 0xC9FB0C03) /* NDS [Lalaloopsy, Adventure Time: HIKWYSOG (DS)] */
|
||||
goto fail;
|
||||
/* 0x04: version? common=0, VAW3=2 */
|
||||
|
||||
@ -51,15 +52,15 @@ VGMSTREAM* init_vgmstream_wave(STREAMFILE* sf) {
|
||||
|
||||
start_offset = read_u32(0x20, sf);
|
||||
interleave = read_u32(0x24, sf); /* typically half data_size */
|
||||
extradata_offset = read_u32(0x28, sf); /* OR: extradata size (always 0x2c) */
|
||||
extradata_offset = read_u32(0x28, sf); /* always 0x2c */
|
||||
|
||||
loop_flag = (loop_start > 0);
|
||||
/* some songs (ex. Adventure Time's m_candykingdom_overworld.wave) do full loops, but there is no way
|
||||
* to tell them apart from sfx/voices, so we try to detect if it's long enough. */
|
||||
if(!loop_flag
|
||||
&& loop_start == 0 && loop_end == num_samples /* full loop */
|
||||
&& channels > 1
|
||||
&& num_samples > 20*sample_rate) { /* in seconds */
|
||||
&& (channels > 1 || (channels == 1 && start_offset <= 0x40))
|
||||
&& num_samples > 30*sample_rate) { /* in seconds */
|
||||
loop_flag = 1;
|
||||
}
|
||||
|
||||
@ -75,22 +76,37 @@ VGMSTREAM* init_vgmstream_wave(STREAMFILE* sf) {
|
||||
|
||||
vgmstream->meta_type = meta_WAVE;
|
||||
|
||||
/* not sure if there are other codecs but anyway */
|
||||
/* not sure if there are other codecs but anyway (based also see wave-segmented) */
|
||||
switch(codec) {
|
||||
case 0x02:
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
/* DS games use IMA, no apparent flag (could also test ID) */
|
||||
if (start_offset <= 0x40) {
|
||||
vgmstream->coding_type = coding_IMA_int;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
|
||||
/* ADPCM setup: 0x20 coefs + 0x06 initial ps/hist1/hist2 + 0x06 loop ps/hist1/hist2, per channel */
|
||||
dsp_read_coefs(vgmstream, sf, extradata_offset+0x00, 0x2c, big_endian);
|
||||
dsp_read_hist(vgmstream, sf, extradata_offset+0x22, 0x2c, big_endian);
|
||||
/* extradata:
|
||||
* 0x00: base hist? (only seen 0)
|
||||
* 0x02: base step? (only seen 0)
|
||||
* 0x04: loop hist?
|
||||
* 0x06: loop step?
|
||||
*/
|
||||
}
|
||||
else {
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
|
||||
/* ADPCM setup: 0x20 coefs + 0x06 initial ps/hist1/hist2 + 0x06 loop ps/hist1/hist2, per channel */
|
||||
dsp_read_coefs(vgmstream, sf, extradata_offset+0x00, 0x2c, big_endian);
|
||||
dsp_read_hist(vgmstream, sf, extradata_offset+0x22, 0x2c, big_endian);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user