mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-13 18:20:50 +01:00
Merge pull request #1221 from NicknineTheEagle/vab
VAB: Don't use note limits by default
This commit is contained in:
commit
0be524e84f
@ -22,7 +22,8 @@ VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
|
|||||||
version = read_u8(0x03, sf);
|
version = read_u8(0x03, sf);
|
||||||
pcm_size = read_u32le(0x04, sf);
|
pcm_size = read_u32le(0x04, sf);
|
||||||
|
|
||||||
if (version == 3) {
|
switch (version) {
|
||||||
|
case 3:
|
||||||
/* Disney's Hercules */
|
/* Disney's Hercules */
|
||||||
sample_rate = read_u32le(0x08, sf);
|
sample_rate = read_u32le(0x08, sf);
|
||||||
loop_flag = read_u8(0x0c, sf);
|
loop_flag = read_u8(0x0c, sf);
|
||||||
@ -31,7 +32,8 @@ VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
|
|||||||
//bps = bps_flag ? 8 : 16;
|
//bps = bps_flag ? 8 : 16;
|
||||||
bps = 16;
|
bps = 16;
|
||||||
start_offset = 0x10;
|
start_offset = 0x10;
|
||||||
} else if (version == 6) {
|
break;
|
||||||
|
case 6:
|
||||||
/* Mortal Kombat 4 */
|
/* Mortal Kombat 4 */
|
||||||
bps_flag = pcm_size & 0x20000000;
|
bps_flag = pcm_size & 0x20000000;
|
||||||
hq_flag = pcm_size & 0x40000000;
|
hq_flag = pcm_size & 0x40000000;
|
||||||
@ -41,7 +43,8 @@ VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
|
|||||||
bps = bps_flag ? 16 : 8;
|
bps = bps_flag ? 16 : 8;
|
||||||
sample_rate = hq_flag ? 22050 : 11025;
|
sample_rate = hq_flag ? 22050 : 11025;
|
||||||
start_offset = 0x08;
|
start_offset = 0x08;
|
||||||
} else if (version == 8) {
|
break;
|
||||||
|
case 8:
|
||||||
/* Disney's Tarzan, Hydro Thunder */
|
/* Disney's Tarzan, Hydro Thunder */
|
||||||
bps_flag = pcm_size & 0x10000000;
|
bps_flag = pcm_size & 0x10000000;
|
||||||
hq_flag = pcm_size & 0x20000000;
|
hq_flag = pcm_size & 0x20000000;
|
||||||
@ -52,7 +55,8 @@ VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
|
|||||||
bps = bps_flag ? 16 : 8;
|
bps = bps_flag ? 16 : 8;
|
||||||
sample_rate = hq_flag ? 22050 : 11025;
|
sample_rate = hq_flag ? 22050 : 11025;
|
||||||
start_offset = 0x08;
|
start_offset = 0x08;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,20 +68,26 @@ VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
|
|||||||
|
|
||||||
vgmstream->meta_type = meta_ESF;
|
vgmstream->meta_type = meta_ESF;
|
||||||
vgmstream->sample_rate = sample_rate;
|
vgmstream->sample_rate = sample_rate;
|
||||||
if (version == 3) {
|
vgmstream->num_samples = pcm_bytes_to_samples(pcm_size, channels, bps);
|
||||||
|
vgmstream->loop_start_sample = 0;
|
||||||
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
|
||||||
|
switch (version) {
|
||||||
|
case 3:
|
||||||
vgmstream->coding_type = coding_DVI_IMA;
|
vgmstream->coding_type = coding_DVI_IMA;
|
||||||
} else if (version == 6) {
|
break;
|
||||||
|
case 6:
|
||||||
vgmstream->coding_type = (bps == 8) ? coding_PCM8_U : coding_DVI_IMA;
|
vgmstream->coding_type = (bps == 8) ? coding_PCM8_U : coding_DVI_IMA;
|
||||||
} else if (version == 8) {
|
break;
|
||||||
|
case 8:
|
||||||
if (bps == 8) {
|
if (bps == 8) {
|
||||||
vgmstream->coding_type = coding_PCM8_U;
|
vgmstream->coding_type = coding_PCM8_U;
|
||||||
} else {
|
} else {
|
||||||
vgmstream->coding_type = codec_flag ? coding_DVI_IMA : coding_PCM16LE;
|
vgmstream->coding_type = codec_flag ? coding_DVI_IMA : coding_PCM16LE;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
vgmstream->num_samples = pcm_bytes_to_samples(pcm_size, channels, bps);
|
|
||||||
vgmstream->loop_start_sample = 0;
|
|
||||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
||||||
|
|
||||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -141,23 +141,23 @@ VGMSTREAM* init_vgmstream_vab(STREAMFILE* sf) {
|
|||||||
entry_off = tones_off + program_num * 16 * 0x20 + tone_num * 0x20;
|
entry_off = tones_off + program_num * 16 * 0x20 + tone_num * 0x20;
|
||||||
center = read_u8(entry_off + 0x04, sf);
|
center = read_u8(entry_off + 0x04, sf);
|
||||||
shift = read_u8(entry_off + 0x05, sf);
|
shift = read_u8(entry_off + 0x05, sf);
|
||||||
min_note = read_u8(entry_off + 0x06, sf);
|
min_note = read_u8(entry_off + 0x06, sf); /* these two may contain garbage */
|
||||||
max_note = read_u8(entry_off + 0x07, sf);
|
max_note = read_u8(entry_off + 0x07, sf);
|
||||||
wave_num = read_u16le(entry_off + 0x16, sf);
|
wave_num = read_u16le(entry_off + 0x16, sf);
|
||||||
|
|
||||||
if (read_vabcfg_file(sf, program_num, tone_num, ¬e, &fine, &uselimits)) {
|
if (read_vabcfg_file(sf, program_num, tone_num, ¬e, &fine, &uselimits)) {
|
||||||
if (note == -1)
|
if (note == -1)
|
||||||
note = center;
|
note = center;
|
||||||
if (shift == -1)
|
if (fine == -1)
|
||||||
fine = shift;
|
fine = shift;
|
||||||
if (uselimits)
|
if (uselimits)
|
||||||
note = VAB_CLAMP(note, min_note, max_note);
|
note = VAB_CLAMP(note, min_note, max_note);
|
||||||
} else {
|
} else {
|
||||||
note = VAB_CLAMP(60, min_note, max_note);
|
/* play default note */
|
||||||
|
note = 60;
|
||||||
fine = 0;
|
fine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* play default note */
|
|
||||||
pitch = SsPitchFromNote(note, fine, center, shift);
|
pitch = SsPitchFromNote(note, fine, center, shift);
|
||||||
|
|
||||||
data_offset = is_vh ? 0x00 : (waves_off + 256 * 0x02);
|
data_offset = is_vh ? 0x00 : (waves_off + 256 * 0x02);
|
||||||
|
@ -2,31 +2,31 @@
|
|||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* .WAV - from Half-Life 2 (Xbox) */
|
/* .WAV - from Half-Life 2 (Xbox) */
|
||||||
VGMSTREAM *init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_xbox_hlwav(STREAMFILE* sf) {
|
||||||
VGMSTREAM *vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
uint32_t header_size, data_size, start_offset, sample_rate;
|
uint32_t header_size, data_size, start_offset, sample_rate;
|
||||||
int32_t loop_start;
|
int32_t loop_start;
|
||||||
uint8_t format, freq_mode, channels;
|
uint8_t format, freq_mode, channels;
|
||||||
int loop_flag;
|
int loop_flag;
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (!check_extensions(streamFile, "wav,lwav"))
|
if (!check_extensions(sf, "wav,lwav"))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* check header and size */
|
/* check header and size */
|
||||||
header_size = read_u32le(0x00, streamFile);
|
header_size = read_u32le(0x00, sf);
|
||||||
if (header_size != 0x14)
|
if (header_size != 0x14)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
data_size = read_u32le(0x04, streamFile);
|
data_size = read_u32le(0x04, sf);
|
||||||
start_offset = read_u32le(0x08, streamFile);
|
start_offset = read_u32le(0x08, sf);
|
||||||
if (data_size != get_streamfile_size(streamFile) - start_offset)
|
if (data_size != get_streamfile_size(sf) - start_offset)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
loop_start = read_s32le(0x0c, streamFile);
|
loop_start = read_s32le(0x0c, sf);
|
||||||
format = read_u8(0x12, streamFile);
|
format = read_u8(0x12, sf);
|
||||||
freq_mode = read_u8(0x13, streamFile) & 0x0F;
|
freq_mode = read_u8(0x13, sf) & 0x0F;
|
||||||
channels = (read_u8(0x13, streamFile) >> 4) & 0x0F;
|
channels = (read_u8(0x13, sf) >> 4) & 0x0F;
|
||||||
|
|
||||||
switch (freq_mode) {
|
switch (freq_mode) {
|
||||||
case 0x00: sample_rate = 11025; break;
|
case 0x00: sample_rate = 11025; break;
|
||||||
@ -67,7 +67,7 @@ VGMSTREAM *init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||||
goto fail;
|
goto fail;
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ fail:
|
|||||||
|
|
||||||
/* .360.WAV, .PS3.WAV - from Valve games running on Source Engine, evolution of Xbox .WAV format seen above */
|
/* .360.WAV, .PS3.WAV - from Valve games running on Source Engine, evolution of Xbox .WAV format seen above */
|
||||||
/* [The Orange Box (X360), Portal 2 (PS3/X360), Counter-Strike: Global Offensive (PS3/X360)] */
|
/* [The Orange Box (X360), Portal 2 (PS3/X360), Counter-Strike: Global Offensive (PS3/X360)] */
|
||||||
VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_xmv_valve(STREAMFILE* sf) {
|
||||||
VGMSTREAM *vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
int32_t loop_start;
|
int32_t loop_start;
|
||||||
uint32_t start_offset, data_size, sample_rate, num_samples;
|
uint32_t start_offset, data_size, sample_rate, num_samples;
|
||||||
uint16_t /*loop_block, loop_start_skip,*/ loop_end_skip;
|
uint16_t /*loop_block, loop_start_skip,*/ loop_end_skip;
|
||||||
@ -87,30 +87,29 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
|
|||||||
int loop_flag;
|
int loop_flag;
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (!check_extensions(streamFile, "wav,lwav"))
|
if (!is_id32be(0x00, sf, "XMV "))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* check header magic */
|
if (!check_extensions(sf, "wav,lwav"))
|
||||||
if (read_u32be(0x00, streamFile) != 0x58575620) /* "XMV " */
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* only version 4 is known */
|
/* only version 4 is known */
|
||||||
if (read_u32be(0x04, streamFile) != 0x04)
|
if (read_u32be(0x04, sf) != 0x04)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
start_offset = read_u32be(0x10, streamFile);
|
start_offset = read_u32be(0x10, sf);
|
||||||
data_size = read_u32be(0x14, streamFile);
|
data_size = read_u32be(0x14, sf);
|
||||||
num_samples = read_u32be(0x18, streamFile);
|
num_samples = read_u32be(0x18, sf);
|
||||||
loop_start = read_s32be(0x1c, streamFile);
|
loop_start = read_s32be(0x1c, sf);
|
||||||
|
|
||||||
/* XMA only */
|
/* XMA only */
|
||||||
//loop_block = read_u16be(0x20, streamFile);
|
//loop_block = read_u16be(0x20, sf);
|
||||||
//loop_start_skip = read_u16be(0x22, streamFile);
|
//loop_start_skip = read_u16be(0x22, sf);
|
||||||
loop_end_skip = read_u16be(0x24, streamFile);
|
loop_end_skip = read_u16be(0x24, sf);
|
||||||
|
|
||||||
format = read_u8(0x28, streamFile);
|
format = read_u8(0x28, sf);
|
||||||
freq_mode = read_u8(0x2a, streamFile);
|
freq_mode = read_u8(0x2a, sf);
|
||||||
channels = read_u8(0x2b, streamFile);
|
channels = read_u8(0x2b, sf);
|
||||||
|
|
||||||
switch (freq_mode) {
|
switch (freq_mode) {
|
||||||
case 0x00: sample_rate = 11025; break;
|
case 0x00: sample_rate = 11025; break;
|
||||||
@ -151,13 +150,13 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
|
|||||||
|
|
||||||
bytes = ffmpeg_make_riff_xma2(buf, 0x100, num_samples, data_size, channels, sample_rate, block_count, block_size);
|
bytes = ffmpeg_make_riff_xma2(buf, 0x100, num_samples, data_size, channels, sample_rate, block_count, block_size);
|
||||||
|
|
||||||
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf, bytes, start_offset, data_size);
|
vgmstream->codec_data = init_ffmpeg_header_offset(sf, buf, bytes, start_offset, data_size);
|
||||||
if (!vgmstream->codec_data) goto fail;
|
if (!vgmstream->codec_data) goto fail;
|
||||||
vgmstream->coding_type = coding_FFmpeg;
|
vgmstream->coding_type = coding_FFmpeg;
|
||||||
vgmstream->layout_type = layout_none;
|
vgmstream->layout_type = layout_none;
|
||||||
vgmstream->loop_end_sample -= loop_end_skip;
|
vgmstream->loop_end_sample -= loop_end_skip;
|
||||||
|
|
||||||
xma_fix_raw_samples(vgmstream, streamFile, start_offset, data_size, 0, 1, 1);
|
xma_fix_raw_samples(vgmstream, sf, start_offset, data_size, 0, 1, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -168,7 +167,7 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
|
|||||||
if (loop_flag) /* should never happen, Source cannot loop MP3 */
|
if (loop_flag) /* should never happen, Source cannot loop MP3 */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
vgmstream->codec_data = init_mpeg(streamFile, start_offset, &mpeg_coding, channels);
|
vgmstream->codec_data = init_mpeg(sf, start_offset, &mpeg_coding, channels);
|
||||||
if (!vgmstream->codec_data) goto fail;
|
if (!vgmstream->codec_data) goto fail;
|
||||||
vgmstream->coding_type = mpeg_coding;
|
vgmstream->coding_type = mpeg_coding;
|
||||||
vgmstream->layout_type = layout_none;
|
vgmstream->layout_type = layout_none;
|
||||||
@ -183,7 +182,7 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||||
goto fail;
|
goto fail;
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user