# HG changeset patch # User thib # Date 1217618235 0 # Node ID 422f3cb3614b9b76bb9ca600c48d28736c56031e # Parent b753afeb3f347a53695985d9fb2f7bfcc89a5cb6 Enabled voice playing with "%04d/%04d%05d.ogg" format. Don't use a cache for this diff --git a/music2/koedec.cc b/music2/koedec.cc --- a/music2/koedec.cc +++ b/music2/koedec.cc @@ -33,6 +33,7 @@ #include #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; diff --git a/music2/koedec_ogg.cc b/music2/koedec_ogg.cc --- 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; diff --git a/music2/music.h b/music2/music.h --- a/music2/music.h +++ b/music2/music.h @@ -15,7 +15,7 @@ #define DEFAULT_AUDIOBUF 4096 -enum KoeType { koe_unknown, koe_nwk, koe_ovk}; +enum KoeType { koe_unknown, koe_nwk, koe_ovk, koe_ogg}; typedef struct { FILE* stream; int length;