mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
.sli
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@358 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
764231fd8d
commit
a697663f08
@ -103,7 +103,7 @@ File types supported by this version of vgmstream:
|
||||
- .amts (GC DSP ADPCM)
|
||||
- .svs (PS2 ADPCM)
|
||||
- .wav (8/16 bit PCM)
|
||||
- .pos (8/16 bit PCM)
|
||||
- .pos (loop info for .wav)
|
||||
- .nwa (16 bit PCM)
|
||||
- .xss (16 bit PCM)
|
||||
- .sl3 (PS2 ADPCM)
|
||||
@ -128,6 +128,7 @@ File types supported by this version of vgmstream:
|
||||
- .kcey (EACS IMA ADPCM)
|
||||
- .rstm (PS2 ADPCM)
|
||||
- .acm (InterPlay ACM)
|
||||
- .sli (loop info for .ogg)
|
||||
|
||||
Enjoy!
|
||||
-hcs
|
||||
|
@ -99,7 +99,8 @@ META_OBJS=meta/adx_header.o \
|
||||
meta/mus_acm.o \
|
||||
meta/ps2_kces.o \
|
||||
meta/ps2_dxh.o \
|
||||
meta/ps2_psh.o
|
||||
meta/ps2_psh.o \
|
||||
meta/sli.o
|
||||
|
||||
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
||||
|
||||
|
@ -454,6 +454,10 @@
|
||||
RelativePath=".\meta\sat_dvi.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\sli.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\str_snds.c"
|
||||
>
|
||||
|
@ -76,5 +76,6 @@ libmeta_la_SOURCES += ps2_kces.c
|
||||
libmeta_la_SOURCES += ps2_dxh.c
|
||||
libmeta_la_SOURCES += ps2_psh.c
|
||||
libmeta_la_SOURCES += mus_acm.c
|
||||
libmeta_la_SOURCES += sli.c
|
||||
|
||||
EXTRA_DIST = meta.h
|
||||
|
@ -85,6 +85,8 @@ VGMSTREAM * init_vgmstream_amts(STREAMFILE *streamFile);
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE * streamFile);
|
||||
#endif
|
||||
|
||||
VGMSTREAM * init_vgmstream_sadb(STREAMFILE *streamFile);
|
||||
|
98
src/meta/sli.c
Normal file
98
src/meta/sli.c
Normal file
@ -0,0 +1,98 @@
|
||||
#include "../vgmstream.h"
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
|
||||
#include <ctype.h>
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define DIRSEP '\\'
|
||||
#else
|
||||
#define DIRSEP '/'
|
||||
#endif
|
||||
|
||||
/* .sli is a file with loop points, associated with a similarly named .ogg */
|
||||
|
||||
VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
||||
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE * streamFileOGG = NULL;
|
||||
char filename[260];
|
||||
char filenameOGG[260];
|
||||
char linebuffer[260];
|
||||
off_t bytes_read;
|
||||
off_t sli_offset;
|
||||
int done;
|
||||
int32_t loop_start = -1;
|
||||
int32_t loop_length = -1;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("sli",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check for .OGG file */
|
||||
strcpy(filenameOGG,filename);
|
||||
/* strip off .sli */
|
||||
filenameOGG[strlen(filenameOGG)-4]='\0';
|
||||
|
||||
streamFileOGG = streamFile->open(streamFile,filenameOGG,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!streamFileOGG) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* let the real initer do the parsing */
|
||||
vgmstream = init_vgmstream_ogg_vorbis(streamFileOGG);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
close_streamfile(streamFileOGG);
|
||||
streamFileOGG = NULL;
|
||||
|
||||
sli_offset = 0;
|
||||
while ((loop_start == -1 || loop_length == -1) && sli_offset < get_streamfile_size(streamFile)) {
|
||||
char *endptr;
|
||||
bytes_read=get_streamfile_dos_line(sizeof(linebuffer),linebuffer,sli_offset,streamFile,&done);
|
||||
if (!done) goto fail;
|
||||
|
||||
if (!memcmp("LoopStart=",linebuffer,10) && linebuffer[10]!='\0') {
|
||||
loop_start = strtol(linebuffer+10,&endptr,10);
|
||||
if (*endptr != '\0') {
|
||||
/* if it didn't parse cleanly */
|
||||
loop_start = -1;
|
||||
}
|
||||
}
|
||||
else if (!memcmp("LoopLength=",linebuffer,11) && linebuffer[11]!='\0') {
|
||||
loop_length = strtol(linebuffer+11,&endptr,10);
|
||||
if (*endptr != '\0') {
|
||||
/* if it didn't parse cleanly */
|
||||
loop_length = -1;
|
||||
}
|
||||
}
|
||||
|
||||
sli_offset += bytes_read;
|
||||
}
|
||||
|
||||
if (loop_start != -1 && loop_length != -1) {
|
||||
/* install loops */
|
||||
if (!vgmstream->loop_flag) {
|
||||
vgmstream->loop_flag = 1;
|
||||
vgmstream->loop_ch = calloc(vgmstream->channels,
|
||||
sizeof(VGMSTREAMCHANNEL));
|
||||
if (!vgmstream->loop_ch) goto fail;
|
||||
}
|
||||
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_start+loop_length;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_OGG_SLI;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (streamFileOGG) close_streamfile(streamFileOGG);
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
@ -56,6 +56,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_genh,
|
||||
#ifdef VGM_USE_VORBIS
|
||||
init_vgmstream_ogg_vorbis,
|
||||
init_vgmstream_sli_ogg,
|
||||
#endif
|
||||
init_vgmstream_sadb,
|
||||
init_vgmstream_ps2_bmdx,
|
||||
@ -170,7 +171,7 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
|
||||
* really hit the loop start. */
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
if (vgmstream->meta_type==meta_ogg_vorbis) {
|
||||
if (vgmstream->coding_type==coding_ogg_vorbis) {
|
||||
ogg_vorbis_codec_data *data = vgmstream->codec_data;
|
||||
|
||||
OggVorbis_File *ogg_vorbis_file = &(data->ogg_vorbis_file);
|
||||
@ -285,7 +286,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
||||
if (vgmstream->start_vgmstream) free(vgmstream->start_vgmstream);
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
if (vgmstream->meta_type==meta_ogg_vorbis) {
|
||||
if (vgmstream->coding_type==coding_ogg_vorbis) {
|
||||
ogg_vorbis_codec_data *data = vgmstream->codec_data;
|
||||
if (vgmstream->codec_data) {
|
||||
OggVorbis_File *ogg_vorbis_file = &(data->ogg_vorbis_file);
|
||||
@ -795,7 +796,7 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
|
||||
#endif
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
if (vgmstream->meta_type==meta_ogg_vorbis) {
|
||||
if (vgmstream->coding_type==coding_ogg_vorbis) {
|
||||
ogg_vorbis_codec_data *data =
|
||||
(ogg_vorbis_codec_data *)(vgmstream->codec_data);
|
||||
OggVorbis_File *ogg_vorbis_file = &(data->ogg_vorbis_file);
|
||||
@ -1251,6 +1252,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case meta_ogg_vorbis:
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis");
|
||||
break;
|
||||
case meta_OGG_SLI:
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis with .sli for looping");
|
||||
break;
|
||||
#endif
|
||||
case meta_DSP_SADB:
|
||||
snprintf(temp,TEMPSIZE,"sadb header");
|
||||
|
@ -216,6 +216,7 @@ typedef enum {
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
meta_ogg_vorbis, /* ogg vorbis */
|
||||
meta_OGG_SLI, /* Ogg Vorbis file w/ companion .sli for looping */
|
||||
#endif
|
||||
|
||||
meta_AIFC, /* Audio Interchange File Format AIFF-C */
|
||||
|
@ -90,6 +90,7 @@ gchar *vgmstream_exts [] = {
|
||||
"rstm",
|
||||
"acm",
|
||||
"mus",
|
||||
"sli",
|
||||
/* terminator */
|
||||
NULL
|
||||
};
|
||||
|
@ -154,6 +154,7 @@ char * extension_list[] = {
|
||||
"kces\0KCES Audio File (*.KCES)\0",
|
||||
"dxh\0DXH Audio File (*.DXH)\0",
|
||||
"psh\0PSH Audio File (*.PSH)\0",
|
||||
"sli\0SLI Audio File (*.SLI)\0",
|
||||
};
|
||||
|
||||
void about(HWND hwndParent) {
|
||||
|
Loading…
Reference in New Issue
Block a user