Mercurial > otakunoraifu
changeset 2:422f3cb3614b
Enabled voice playing with "%04d/%04d%05d.ogg" format. Don't use a cache for this
author | thib |
---|---|
date | Fri, 01 Aug 2008 19:17:15 +0000 |
parents | b753afeb3f34 |
children | c4af1e9ab8d1 |
files | music2/koedec.cc music2/koedec_ogg.cc music2/music.h |
diffstat | 3 files changed, 28 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/music2/koedec.cc +++ b/music2/koedec.cc @@ -33,6 +33,7 @@ #include <algorithm> #include"music.h" #include"system/file.h" +#include"system/file_impl.h" using namespace std; @@ -85,7 +86,7 @@ static AvgKoeCache koe_cache; AvgKoeInfo FindKoe(int file_number, int index) { return koe_cache.Find(file_number, index); }; - +extern int ogg_get_rate(FILE*); AvgKoeInfo AvgKoeCache::Find(int file_number, int index) { AvgKoeInfo info; info.stream = 0; info.length = 0; info.offset = 0; @@ -108,6 +109,24 @@ AvgKoeInfo AvgKoeCache::Find(int file_nu sprintf(fname, "z%04d.ovk", file_number); arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk"); } + if (arcinfo == 0) { + DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe"); + sprintf(fname, "%04d", file_number); + koedir = new DIRFILE(koedir->SearchFile(fname)); + sprintf(fname, "z%04d%05d.ogg", file_number, index); + arcinfo = koedir->Find(fname, ".ogg"); + delete koedir; + + if (arcinfo == 0) return info; + FILE* stream = arcinfo->OpenFile(); + info.rate = ogg_get_rate(stream); + fseek(stream, 0L, SEEK_END); + info.length = ftell(stream); + fseek(stream, 0L, SEEK_CUR); + info.type = koe_ogg; + info.stream = stream; + return info; + } if (arcinfo == 0) return info; FILE* stream = arcinfo->OpenFile(); delete arcinfo; @@ -141,6 +160,7 @@ AvgKoeHead::AvgKoeHead(const AvgKoeHead& table = from.table; type = from.type; } + AvgKoeHead::AvgKoeHead(FILE* _s, int _file_number, KoeType _type) { char head[0x20]; stream = _s; file_number = _file_number;
--- a/music2/koedec_ogg.cc +++ b/music2/koedec_ogg.cc @@ -98,6 +98,12 @@ static long ogg_tellfunc(void* datasourc static int ogg_closefunc(void* datasource) { return 0; } +int ogg_get_rate(FILE *stream) +{ + OggVorbis_File vf; + ov_open(stream, &vf, NULL, 0); + return vf.vi->rate; +} extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { if (info.stream == 0) return 0;