Mercurial > otakunoraifu
comparison music2/koedec.cc @ 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 | 223b71206888 |
children | c9e218c2c3f1 |
comparison
equal
deleted
inserted
replaced
1:b753afeb3f34 | 2:422f3cb3614b |
---|---|
31 #include <vector> | 31 #include <vector> |
32 #include <list> | 32 #include <list> |
33 #include <algorithm> | 33 #include <algorithm> |
34 #include"music.h" | 34 #include"music.h" |
35 #include"system/file.h" | 35 #include"system/file.h" |
36 #include"system/file_impl.h" | |
36 | 37 |
37 using namespace std; | 38 using namespace std; |
38 | 39 |
39 /********************************************* | 40 /********************************************* |
40 ** | 41 ** |
83 static AvgKoeCache koe_cache; | 84 static AvgKoeCache koe_cache; |
84 | 85 |
85 AvgKoeInfo FindKoe(int file_number, int index) { | 86 AvgKoeInfo FindKoe(int file_number, int index) { |
86 return koe_cache.Find(file_number, index); | 87 return koe_cache.Find(file_number, index); |
87 }; | 88 }; |
88 | 89 extern int ogg_get_rate(FILE*); |
89 AvgKoeInfo AvgKoeCache::Find(int file_number, int index) { | 90 AvgKoeInfo AvgKoeCache::Find(int file_number, int index) { |
90 AvgKoeInfo info; | 91 AvgKoeInfo info; |
91 info.stream = 0; info.length = 0; info.offset = 0; | 92 info.stream = 0; info.length = 0; info.offset = 0; |
92 | 93 |
93 list<AvgKoeHead>::iterator it; | 94 list<AvgKoeHead>::iterator it; |
106 if (arcinfo == 0) { | 107 if (arcinfo == 0) { |
107 type = koe_ovk; | 108 type = koe_ovk; |
108 sprintf(fname, "z%04d.ovk", file_number); | 109 sprintf(fname, "z%04d.ovk", file_number); |
109 arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk"); | 110 arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk"); |
110 } | 111 } |
112 if (arcinfo == 0) { | |
113 DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe"); | |
114 sprintf(fname, "%04d", file_number); | |
115 koedir = new DIRFILE(koedir->SearchFile(fname)); | |
116 sprintf(fname, "z%04d%05d.ogg", file_number, index); | |
117 arcinfo = koedir->Find(fname, ".ogg"); | |
118 delete koedir; | |
119 | |
120 if (arcinfo == 0) return info; | |
121 FILE* stream = arcinfo->OpenFile(); | |
122 info.rate = ogg_get_rate(stream); | |
123 fseek(stream, 0L, SEEK_END); | |
124 info.length = ftell(stream); | |
125 fseek(stream, 0L, SEEK_CUR); | |
126 info.type = koe_ogg; | |
127 info.stream = stream; | |
128 return info; | |
129 } | |
111 if (arcinfo == 0) return info; | 130 if (arcinfo == 0) return info; |
112 FILE* stream = arcinfo->OpenFile(); | 131 FILE* stream = arcinfo->OpenFile(); |
113 delete arcinfo; | 132 delete arcinfo; |
114 if (stream == 0) return info; | 133 if (stream == 0) return info; |
115 cache.push_front(AvgKoeHead(stream, file_number, type)); | 134 cache.push_front(AvgKoeHead(stream, file_number, type)); |
139 file_number = from.file_number; | 158 file_number = from.file_number; |
140 rate = from.rate; | 159 rate = from.rate; |
141 table = from.table; | 160 table = from.table; |
142 type = from.type; | 161 type = from.type; |
143 } | 162 } |
163 | |
144 AvgKoeHead::AvgKoeHead(FILE* _s, int _file_number, KoeType _type) { | 164 AvgKoeHead::AvgKoeHead(FILE* _s, int _file_number, KoeType _type) { |
145 char head[0x20]; | 165 char head[0x20]; |
146 stream = _s; file_number = _file_number; | 166 stream = _s; file_number = _file_number; |
147 int offset = ftell(stream); | 167 int offset = ftell(stream); |
148 rate = 22050; | 168 rate = 22050; |