mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-14 18:47:39 +01:00
Add .TUN ACM [Descent to Undermountain (PC)]
This commit is contained in:
parent
48c67ecfd8
commit
e283384dcd
@ -3,51 +3,53 @@
|
||||
#include "../coding/acm_decoder_libacm.h"
|
||||
|
||||
/* ACM - InterPlay infinity engine games [Planescape: Torment (PC), Baldur's Gate (PC)] */
|
||||
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
||||
VGMSTREAM* init_vgmstream_acm(STREAMFILE* sf) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
||||
int loop_flag = 0, channels, sample_rate, num_samples;
|
||||
int force_channel_number = 0;
|
||||
acm_codec_data *data = NULL;
|
||||
|
||||
|
||||
/* checks */
|
||||
/* .acm: plain ACM extension (often but not always paired with .mus, parsed elsewhere)
|
||||
* .tun: Descent to Undermountain (PC)
|
||||
* .wavc: header id for WAVC sfx (from bigfiles, extensionless) */
|
||||
if (!check_extensions(streamFile, "acm,wavc"))
|
||||
if (!check_extensions(sf, "acm,tun,wavc"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x97280301 && /* header id (music) */
|
||||
read_32bitBE(0x00,streamFile) != 0x57415643) /* "WAVC" (sfx) */
|
||||
if (read_u32be(0x00,sf) != 0x97280301 && /* header id (music) */
|
||||
!is_id32be(0x00,sf, "WAVC")) /* sfx */
|
||||
goto fail;
|
||||
|
||||
|
||||
/* Plain ACM "channels" in the header may be set to 2 for mono voices or 1 for music,
|
||||
/* Plain ACM "channels" in the header (at 0x08) may be set to 2 for mono voices [FO1] or 1 for music [P:T],
|
||||
* but actually seem related to ACM rows/cols and have nothing to do with channels.
|
||||
*
|
||||
* libacm will set plain ACM (not WAVC) to 2ch unless changes unless changed, but
|
||||
* only Fallout (PC) seems to use plain ACM for sfx, others are WAVC (which do have channels).
|
||||
* libacm will set plain ACM (not WAVC) to 2ch unless changed, but only Fallout (PC)
|
||||
* and Descent to Undermountain (PC) seems to use plain ACM for sfx/voices,
|
||||
* others are WAVC (which do have channels).
|
||||
* DtU seems to use the field
|
||||
*
|
||||
* Doesn't look like there is any way to detect mono/stereo, so as a quick hack if
|
||||
* we have a plain ACM (not WAVC) named .wavc we will force 1ch. */
|
||||
if (check_extensions(streamFile, "wavc")
|
||||
&& read_32bitBE(0x00,streamFile) == 0x97280301) {
|
||||
if (check_extensions(sf, "wavc") && read_u32be(0x00,sf) == 0x97280301) {
|
||||
force_channel_number = 1;
|
||||
}
|
||||
|
||||
/* init decoder */
|
||||
{
|
||||
ACMStream *handle;
|
||||
data = init_acm(streamFile, force_channel_number);
|
||||
data = init_acm(sf, force_channel_number);
|
||||
if (!data) goto fail;
|
||||
|
||||
handle = data->handle;
|
||||
channel_count = handle->info.channels;
|
||||
channels = handle->info.channels;
|
||||
sample_rate = handle->info.rate;
|
||||
num_samples = handle->total_values / handle->info.channels;
|
||||
}
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
|
Loading…
Reference in New Issue
Block a user