MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / taunt_ImportWave

Function taunt_ImportWave

Descent3/audiotaunts.cpp:217–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215// compress the wav file.
216#define FILEBUFFER_LENGTH (4 * 1024)
217bool taunt_ImportWave(char *wave_filename, char *outputfilename) {
218 ASSERT(wave_filename);
219 ASSERT(outputfilename);
220 bool ret = true;
221 CFILE *file = NULL;
222 int amount_to_flush;
223 tWaveFile wavdata;
224 int samples, rate, chan;
225 char temp_filename[_MAX_PATH];
226 char osftemp_filename[_MAX_PATH];
227 uint8_t *StaticFileBuffer = NULL;
228 *temp_filename = *osftemp_filename = '\0';
229 OSFArchive osf;
230 CFILE *fpin = NULL;
231 bool osfopened;
232 osfopened = false;
233
234 if (!wave_filename || !outputfilename) {
235 TauntLastError = TAUNTIMPERR_NOTFOUND;
236 return false;
237 }
238
239 // first make sure the wave file exists
240 if (!cfexist(wave_filename)) {
241 mprintf(0, "AudioTaunt: Can't Import wav, missing %s\n", wave_filename);
242 TauntLastError = TAUNTIMPERR_NOTFOUND;
243 return false;
244 }
245
246 // make sure the output file doesn't exist so we don't overwrite
247 if (cfexist(outputfilename)) {
248 mprintf(0, "AudioTaunt: Can't Import wav, %s already exists\n", outputfilename);
249 TauntLastError = TAUNTIMPERR_OSFEXISTS;
250 return false;
251 }
252
253 // Open the file and import
254 char wave_ret = taunt_LoadWaveFile(wave_filename, &wavdata);
255 if (wave_ret != 0) {
256 mprintf(0, "TAUNT: Unable to load wave\n");
257 switch (wave_ret) {
258 case 1:
259 TauntLastError = TAUNTIMPERR_NOTFOUND;
260 break;
261 case 2:
262 TauntLastError = TAUNTIMPERR_NOTRIFF;
263 break;
264 case 3:
265 TauntLastError = TAUNTIMPERR_NOTWAVE;
266 break;
267 case 4:
268 case 5:
269 TauntLastError = TAUNTIMPERR_INVALIDFILE;
270 break;
271 case 6:
272 TauntLastError = TAUNTIMPERR_NOTSUPPORTED;
273 break;
274 case 7:

Callers 1

PltSelectShipFunction · 0.85

Calls 15

cfexistFunction · 0.85
taunt_LoadWaveFileFunction · 0.85
cfopenFunction · 0.85
cf_WriteBytesFunction · 0.85
cfcloseFunction · 0.85
aenc_CompressFunction · 0.85
cfilelengthFunction · 0.85
cf_ReadBytesFunction · 0.85
WriteBlockMethod · 0.80
SaveHeaderMethod · 0.80
ddio_GetTempFileNameFunction · 0.50
ddio_SplitPathFunction · 0.50

Tested by

no test coverage detected