status WAVEFile::writeInit(AFfilesetup setup) { uint32_t zero = 0; if (_af_filesetup_make_handle(setup, this) == AF_FAIL) return AF_FAIL; fh->seek(0, File::SeekFromBeginning); fh->write("RIFF", 4); fh->write(&zero, 4); fh->write("WAVE", 4); writeMiscellaneous(); writeCues(); writeFormat(); writeFrameCount(); writeData(); return AF_SUCCEED; }
status _af_wave_write_init (AFfilesetup setup, AFfilehandle filehandle) { u_int32_t zero = 0; if (_af_filesetup_make_handle(setup, filehandle) == AF_FAIL) return AF_FAIL; filehandle->formatSpecific = waveinfo_new(); af_fseek(filehandle->fh, 0, SEEK_SET); af_fwrite("RIFF", 4, 1, filehandle->fh); af_fwrite(&zero, 4, 1, filehandle->fh); af_fwrite("WAVE", 4, 1, filehandle->fh); WriteMiscellaneous(filehandle); WriteFormat(filehandle); WriteData(filehandle); return AF_SUCCEED; }
status NeXTFile::writeInit(AFfilesetup setup) { if (_af_filesetup_make_handle(setup, this) == AF_FAIL) return AF_FAIL; if (miscellaneousCount > 0) { _af_error(AF_BAD_NUMMISC, "NeXT format supports no miscellaneous chunks"); return AF_FAIL; } writeHeader(); Track *track = getTrack(); track->fpos_first_frame = 28; track->f.byteOrder = AF_BYTEORDER_BIGENDIAN; return AF_SUCCEED; }
status _af_next_write_init (AFfilesetup setup, AFfilehandle filehandle) { _Track *track; if (_af_filesetup_make_handle(setup, filehandle) == AF_FAIL) return AF_FAIL; filehandle->formatSpecific = NULL; if (filehandle->miscellaneousCount > 0) { _af_error(AF_BAD_NUMMISC, "NeXT format supports no miscellaneous chunks"); return AF_FAIL; } next_write_header(filehandle); track = _af_filehandle_get_track(filehandle, AF_DEFAULT_TRACK); track->fpos_first_frame = 28; track->f.byteOrder = AF_BYTEORDER_BIGENDIAN; return AF_SUCCEED; }
status _af_avr_write_init (AFfilesetup setup, AFfilehandle filehandle) { _Track *track; char name[8]; uint16_t mono, resolution, sign, loop, midi; uint32_t rate, size, loopStart, loopEnd; char reserved[26]; char user[64]; if (_af_filesetup_make_handle(setup, filehandle) == AF_FAIL) return AF_FAIL; filehandle->formatSpecific = NULL; track = _af_filehandle_get_track(filehandle, AF_DEFAULT_TRACK); if (af_fseek(filehandle->fh, 0, SEEK_SET) != 0) { _af_error(AF_BAD_LSEEK, "bad seek"); return AF_FAIL; } af_fwrite("2BIT", 4, 1, filehandle->fh); memset(name, 0, 8); if (filehandle->fileName != NULL) strncpy(name, af_basename(filehandle->fileName), 8); af_fwrite(name, 8, 1, filehandle->fh); if (track->f.channelCount == 1) mono = 0x0; else mono = 0xffff; af_write_uint16_be(&mono, filehandle->fh); resolution = track->f.sampleWidth; af_write_uint16_be(&resolution, filehandle->fh); if (track->f.sampleFormat == AF_SAMPFMT_UNSIGNED) sign = 0x0; else sign = 0xffff; af_write_uint16_be(&sign, filehandle->fh); /* We do not currently support loops. */ loop = 0; af_write_uint16_be(&loop, filehandle->fh); midi = 0xffff; af_write_uint16_be(&midi, filehandle->fh); rate = track->f.sampleRate; /* Set the high-order byte of rate to 0xff. */ rate |= 0xff000000; size = track->totalfframes; loopStart = 0; loopEnd = size; af_write_uint32_be(&rate, filehandle->fh); af_write_uint32_be(&size, filehandle->fh); af_write_uint32_be(&loopStart, filehandle->fh); af_write_uint32_be(&loopEnd, filehandle->fh); memset(reserved, 0, 26); af_fwrite(reserved, 26, 1, filehandle->fh); memset(user, 0, 64); af_fwrite(user, 64, 1, filehandle->fh); if (track->fpos_first_frame == 0) track->fpos_first_frame = af_ftell(filehandle->fh); return AF_SUCCEED; }