Beispiel #1
0
void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
{
	if(protocol_version <= 17)
		writeU8(os, 1); // version
	else
		writeU8(os, 2); // version
	writeF1000(os, full_punch_interval);
	writeS16(os, max_drop_level);
	writeU32(os, groupcaps.size());
	for(std::map<std::string, ToolGroupCap>::const_iterator
			i = groupcaps.begin(); i != groupcaps.end(); i++){
		const std::string *name = &i->first;
		const ToolGroupCap *cap = &i->second;
		os<<serializeString(*name);
		writeS16(os, cap->uses);
		writeS16(os, cap->maxlevel);
		writeU32(os, cap->times.size());
		for(std::map<int, float>::const_iterator
				i = cap->times.begin(); i != cap->times.end(); i++){
			writeS16(os, i->first);
			writeF1000(os, i->second);
		}
	}
	if(protocol_version > 17){
		writeU32(os, damageGroups.size());
		for(std::map<std::string, s16>::const_iterator
				i = damageGroups.begin(); i != damageGroups.end(); i++){
			os<<serializeString(i->first);
			writeS16(os, i->second);
		}
	}
}
void U3DBitStreamWriter::writeCompressedU32(MLuint32 context, MLuint32 uValue)
{
  if (context == U3DContext_StaticFull)   // In this case a division by zero might occur in _writeSymbol() so we capture it here 
  {
    writeU32(uValue);
  }
  else
  {
    _compressed = true;
    bool escape = false;

    if((context != 0) && (context < U3D_MaxRange))
    {
      writeSymbol(context, uValue, escape);

      if(escape == true)
      {
        writeU32(uValue);
        _contextManager.addSymbol(context, uValue + 1U);
      }
    }
    else
    {
      writeU32(uValue);
    }
  }
}
Beispiel #3
0
status WAVEFile::writeFrameCount()
{
	uint32_t factSize = 4;
	uint32_t totalFrameCount;

	Track *track = getTrack();

	/* Omit the fact chunk only for uncompressed integer audio formats. */
	if (track->f.compressionType == AF_COMPRESSION_NONE &&
		(track->f.sampleFormat == AF_SAMPFMT_TWOSCOMP ||
		track->f.sampleFormat == AF_SAMPFMT_UNSIGNED))
		return AF_SUCCEED;

	/*
		If the offset for the fact chunk hasn't been set yet,
		set it to the file's current position.
	*/
	if (factOffset == 0)
		factOffset = fh->tell();
	else
		fh->seek(factOffset, File::SeekFromBeginning);

	fh->write("fact", 4);
	writeU32(&factSize);

	totalFrameCount = track->totalfframes;
	writeU32(&totalFrameCount);

	return AF_SUCCEED;
}
Beispiel #4
0
status CAFFile::writeDescription()
{
	Track *track = getTrack();

	Tag desc("desc");
	int64_t chunkLength = 32;
	double sampleRate = track->f.sampleRate;
	Tag formatID("lpcm");
	uint32_t formatFlags = 0;
	if (track->f.byteOrder == AF_BYTEORDER_LITTLEENDIAN)
		formatFlags |= kCAFLinearPCMFormatFlagIsLittleEndian;
	if (track->f.isFloat())
		formatFlags |= kCAFLinearPCMFormatFlagIsFloat;
	uint32_t bytesPerPacket = track->f.bytesPerFrame(false);
	uint32_t framesPerPacket = 1;
	uint32_t channelsPerFrame = track->f.channelCount;
	uint32_t bitsPerChannel = track->f.sampleWidth;

	if (track->f.compressionType == AF_COMPRESSION_G711_ULAW)
	{
		formatID = "ulaw";
		formatFlags = 0;
		bytesPerPacket = channelsPerFrame;
		bitsPerChannel = 8;
	}
	else if (track->f.compressionType == AF_COMPRESSION_G711_ALAW)
	{
		formatID = "alaw";
		formatFlags = 0;
		bytesPerPacket = channelsPerFrame;
		bitsPerChannel = 8;
	}
	else if (track->f.compressionType == AF_COMPRESSION_IMA)
	{
		formatID = "ima4";
		formatFlags = 0;
		bytesPerPacket = track->f.bytesPerPacket;
		framesPerPacket = track->f.framesPerPacket;
		bitsPerChannel = 16;
	}

	if (!writeTag(&desc) ||
		!writeS64(&chunkLength) ||
		!writeDouble(&sampleRate) ||
		!writeTag(&formatID) ||
		!writeU32(&formatFlags) ||
		!writeU32(&bytesPerPacket) ||
		!writeU32(&framesPerPacket) ||
		!writeU32(&channelsPerFrame) ||
		!writeU32(&bitsPerChannel))
		return AF_FAIL;
	return AF_SUCCEED;
}
Beispiel #5
0
status VOCFile::writeSoundData()
{
	if (m_soundDataOffset == -1)
		m_soundDataOffset = m_fh->tell();
	else
		m_fh->seek(m_soundDataOffset, File::SeekFromBeginning);

	Track *track = getTrack();

	assert((track->f.isSigned() && track->f.sampleWidth == 16) ||
		(track->f.isUnsigned() && track->f.sampleWidth == 8));

	uint8_t blockType = kVOCSoundDataNew;
	uint32_t blockSize = 12 + track->data_size;
	uint32_t blockHeader = blockSize << 8 | blockType;
	if (!writeU32(&blockHeader))
		return AF_FAIL;

	uint32_t sampleRate = track->f.sampleRate;
	uint8_t bitsPerSample = track->f.sampleWidth;
	uint8_t channels = track->f.channelCount;
	uint16_t format;
	if (track->f.compressionType == AF_COMPRESSION_G711_ULAW)
	{
		format = kVOCFormatUlaw;
		bitsPerSample = 8;
	}
	else if (track->f.compressionType == AF_COMPRESSION_G711_ALAW)
	{
		format = kVOCFormatAlaw;
		bitsPerSample = 8;
	}
	else if (track->f.compressionType == AF_COMPRESSION_NONE)
	{
		if (track->f.isUnsigned())
			format = kVOCFormatU8;
		else
			format = kVOCFormatS16;
	}
	uint32_t pad = 0;
	if (!writeU32(&sampleRate) ||
		!writeU8(&bitsPerSample) ||
		!writeU8(&channels) ||
		!writeU16(&format) ||
		!writeU32(&pad))
		return AF_FAIL;

	if (track->fpos_first_frame == 0)
		track->fpos_first_frame = m_fh->tell();

	return AF_SUCCEED;
}
Beispiel #6
0
status SampleVisionFile::writeLoops()
{
	for (int i=0; i<8; i++)
	{
		uint32_t startFrame = kSMPInvalidSamplePosition, endFrame = 0;
		uint8_t type = 0;
		uint16_t count = 0;
		writeU32(&startFrame);
		writeU32(&endFrame);
		writeU8(&type);
		writeU16(&count);
	}
	return AF_SUCCEED;
}
Beispiel #7
0
U32		PGRFPaxosLeaderKeepAliveReq::serialize( S8 *  buf,  S32 offset ) const
{
    U32 cur_pos = PPacketBase::serialize(buf, offset);
    S8 * buff = buf + offset;

    writeU32(buff + cur_pos, m_iServerID);
    cur_pos += sizeof(U32);

    writeU32(buff + cur_pos, m_iEpoch);
    cur_pos += sizeof(U32);

    return cur_pos;

}
Beispiel #8
0
status IFFFile::writeVHDR()
{
	uint32_t chunkSize;
	uint32_t oneShotSamples, repeatSamples, samplesPerRepeat;
	uint16_t sampleRate;
	uint8_t octaves, compression;
	uint32_t volume;

	/*
		If VHDR_offset hasn't been set yet, set it to the
		current offset.
	*/
	if (m_VHDR_offset == 0)
		m_VHDR_offset = m_fh->tell();
	else
		m_fh->seek(m_VHDR_offset, File::SeekFromBeginning);

	Track *track = getTrack();

	m_fh->write("VHDR", 4);

	chunkSize = 20;
	writeU32(&chunkSize);

	/*
		IFF/8SVX files have only one audio channel, so the
		number of samples is equal to the number of frames.
	*/
	oneShotSamples = track->totalfframes;
	writeU32(&oneShotSamples);
	repeatSamples = 0;
	writeU32(&repeatSamples);
	samplesPerRepeat = 0;
	writeU32(&samplesPerRepeat);

	sampleRate = track->f.sampleRate;
	writeU16(&sampleRate);

	octaves = 0;
	compression = 0;
	writeU8(&octaves);
	writeU8(&compression);

	/* Volume is in fixed-point notation; 65536 means gain of 1.0. */
	volume = 65536;
	writeU32(&volume);

	return AF_SUCCEED;
}
Beispiel #9
0
void MapBlock::serializeDiskExtra(std::ostream &os, u8 version)
{
	// Versions up from 9 have block objects. (DEPRECATED)
	if(version >= 9)
	{
		// count=0
		writeU16(os, 0);
	}
	
	// Versions up from 15 have static objects.
	if(version >= 15)
	{
		m_static_objects.serialize(os);
	}

	// Timestamp
	if(version >= 17)
	{
		writeU32(os, getTimestamp());
	}

	// Scan and write node definition id mapping
	if(version >= 21){
		NameIdMapping nimap;
		getBlockNodeIdMapping(&nimap, this, m_gamedef->ndef());
		nimap.serialize(os);
	}
}
Beispiel #10
0
/*
	Minetest Schematic File Format

	All values are stored in big-endian byte order.
	[u32] signature: 'MTSM'
	[u16] version: 3
	[u16] size X
	[u16] size Y
	[u16] size Z
	For each Y:
		[u8] slice probability value
	[Name-ID table] Name ID Mapping Table
		[u16] name-id count
		For each name-id mapping:
			[u16] name length
			[u8[]] name
	ZLib deflated {
	For each node in schematic:  (for z, y, x)
		[u16] content
	For each node in schematic:
		[u8] probability of occurance (param1)
	For each node in schematic:
		[u8] param2
	}

	Version changes:
	1 - Initial version
	2 - Fixed messy never/always place; 0 probability is now never, 0xFF is always
	3 - Added y-slice probabilities; this allows for variable height structures
*/
void DecoSchematic::saveSchematicFile(INodeDefManager *ndef) {
	std::ostringstream ss(std::ios_base::binary);

	writeU32(ss, MTSCHEM_FILE_SIGNATURE);         // signature
	writeU16(ss, MTSCHEM_FILE_VER_HIGHEST_WRITE); // version
	writeV3S16(ss, size);                         // schematic size

	for (int y = 0; y != size.Y; y++)             // Y slice probabilities
		writeU8(ss, slice_probs[y]);

	std::vector<content_t> usednodes;
	int nodecount = size.X * size.Y * size.Z;
	build_nnlist_and_update_ids(schematic, nodecount, &usednodes);

	u16 numids = usednodes.size();
	writeU16(ss, numids); // name count
	for (int i = 0; i != numids; i++)
		ss << serializeString(ndef->get(usednodes[i]).name); // node names

	// compressed bulk node data
	MapNode::serializeBulk(ss, SER_FMT_VER_HIGHEST_WRITE, schematic,
				nodecount, 2, 2, true);

	fs::safeWriteToFile(filename, ss.str());
}
Beispiel #11
0
status IFFFile::writeBODY()
{
	uint32_t chunkSize;

	Track *track = getTrack();

	if (m_BODY_offset == 0)
		m_BODY_offset = m_fh->tell();
	else
		m_fh->seek(m_BODY_offset, File::SeekFromBeginning);

	m_fh->write("BODY", 4);

	/*
		IFF/8SVX supports only one channel, so the number of
		frames is equal to the number of samples, and each
		sample is one byte.
	*/
	chunkSize = track->totalfframes;
	writeU32(&chunkSize);

	if (track->fpos_first_frame == 0)
		track->fpos_first_frame = m_fh->tell();

	/* Add a pad byte to the end of the chunk if the chunk size is odd. */
	if ((chunkSize % 2) == 1)
	{
		uint8_t zero = 0;
		m_fh->seek(m_BODY_offset + 8 + chunkSize, File::SeekFromBeginning);
		writeU8(&zero);
	}

	return AF_SUCCEED;
}
Beispiel #12
0
void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
{
	if(protocol_version < 14){
		serializeOld(os, protocol_version);
		return;
	}

	writeU8(os, 6); // version
	os<<serializeString(name);
	writeU16(os, groups.size());
	for(ItemGroupList::const_iterator
			i = groups.begin(); i != groups.end(); i++){
		os<<serializeString(i->first);
		writeS16(os, i->second);
	}
	writeU8(os, drawtype);
	writeF1000(os, visual_scale);
	writeU8(os, 6);
	for(u32 i=0; i<6; i++)
		tiledef[i].serialize(os, protocol_version);
	writeU8(os, CF_SPECIAL_COUNT);
	for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
		tiledef_special[i].serialize(os, protocol_version);
	}
	writeU8(os, alpha);
	writeU8(os, post_effect_color.getAlpha());
	writeU8(os, post_effect_color.getRed());
	writeU8(os, post_effect_color.getGreen());
	writeU8(os, post_effect_color.getBlue());
	writeU8(os, param_type);
	writeU8(os, param_type_2);
	writeU8(os, is_ground_content);
	writeU8(os, light_propagates);
	writeU8(os, sunlight_propagates);
	writeU8(os, walkable);
	writeU8(os, pointable);
	writeU8(os, diggable);
	writeU8(os, climbable);
	writeU8(os, buildable_to);
	os<<serializeString(""); // legacy: used to be metadata_name
	writeU8(os, liquid_type);
	os<<serializeString(liquid_alternative_flowing);
	os<<serializeString(liquid_alternative_source);
	writeU8(os, liquid_viscosity);
	writeU8(os, liquid_renewable);
	writeU8(os, light_source);
	writeU32(os, damage_per_second);
	node_box.serialize(os);
	selection_box.serialize(os);
	writeU8(os, legacy_facedir_simple);
	writeU8(os, legacy_wallmounted);
	serializeSimpleSoundSpec(sound_footstep, os);
	serializeSimpleSoundSpec(sound_dig, os);
	serializeSimpleSoundSpec(sound_dug, os);
	writeU8(os, rightclickable);
	// Stuff below should be moved to correct place in a version that otherwise changes
	// the protocol version
	writeU8(os, drowning);
}
Beispiel #13
0
static void writeString(const plString& v, unsigned char*& buffer, size_t& size) {
    plString::Wide ws = v.wstr();
    size_t len = (ws.len() + 1) * sizeof(pl_wchar_t);
    writeU32(len, buffer, size);
    memcpy(buffer, ws.data(), len);  // Includes the '\0'
    buffer += len;
    size -= len;
}
Beispiel #14
0
U32		PGRFAttrSetResPkt::serialize( S8 *  buf,  S32 offset ) const 
{
	U32 cur_pos = PPacketBase::serialize(buf, offset);
	S8 * buff = buf + offset;

	writeU32(buff + cur_pos, m_event);
	cur_pos += sizeof(U32);

	writeU32(buff + cur_pos, m_iHandle);
	cur_pos += sizeof(U32);

	writeB8(buff + cur_pos, m_bOk);
	cur_pos += sizeof(B8);
	//cur_pos += m_oAddr.serialize(buff + cur_pos,0);

	return cur_pos;

}
Beispiel #15
0
U32		PGRFCloseReqPkt::serialize( S8 *  buf,  S32 offset ) const 
{
	U32 cur_pos = PPacketBase::serialize(buf, offset);
	S8 * buff = buf + offset;

	writeU32(buff + cur_pos, m_event);
	cur_pos += sizeof(U32);

	writeU32(buff + cur_pos, m_iSessionID);
	cur_pos += sizeof(U32);

	writeU32(buff + cur_pos, m_iHandle);
	cur_pos += sizeof(U32);
	//cur_pos += m_oAddr.serialize(buff + cur_pos,0);

	return cur_pos;

}
Beispiel #16
0
status SampleVisionFile::update()
{
	m_fh->seek(m_frameCountOffset, File::SeekFromBeginning);
	Track *track = getTrack();
	uint32_t frameCount = track->totalfframes;
	writeU32(&frameCount);
	writeTrailer();
	return AF_SUCCEED;
}
Beispiel #17
0
void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
{
	if(protocol_version == 13)
	{
		writeU8(os, 5); // version
		os<<serializeString(name);
		writeU16(os, groups.size());
		for(ItemGroupList::const_iterator
				i = groups.begin(); i != groups.end(); i++){
			os<<serializeString(i->first);
			writeS16(os, i->second);
		}
		writeU8(os, drawtype);
		writeF1000(os, visual_scale);
		writeU8(os, 6);
		for(u32 i=0; i<6; i++)
			tiledef[i].serialize(os, protocol_version);
		writeU8(os, CF_SPECIAL_COUNT);
		for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
			tiledef_special[i].serialize(os, protocol_version);
		}
		writeU8(os, alpha);
		writeU8(os, post_effect_color.getAlpha());
		writeU8(os, post_effect_color.getRed());
		writeU8(os, post_effect_color.getGreen());
		writeU8(os, post_effect_color.getBlue());
		writeU8(os, param_type);
		writeU8(os, param_type_2);
		writeU8(os, is_ground_content);
		writeU8(os, light_propagates);
		writeU8(os, sunlight_propagates);
		writeU8(os, walkable);
		writeU8(os, pointable);
		writeU8(os, diggable);
		writeU8(os, climbable);
		writeU8(os, buildable_to);
		os<<serializeString(""); // legacy: used to be metadata_name
		writeU8(os, liquid_type);
		os<<serializeString(liquid_alternative_flowing);
		os<<serializeString(liquid_alternative_source);
		writeU8(os, liquid_viscosity);
		writeU8(os, light_source);
		writeU32(os, damage_per_second);
		node_box.serialize(os, protocol_version);
		selection_box.serialize(os, protocol_version);
		writeU8(os, legacy_facedir_simple);
		writeU8(os, legacy_wallmounted);
		serializeSimpleSoundSpec(sound_footstep, os);
		serializeSimpleSoundSpec(sound_dig, os);
		serializeSimpleSoundSpec(sound_dug, os);
	}
	else
	{
		throw SerializationError("ContentFeatures::serialize(): Unsupported version requested");
	}
}
Beispiel #18
0
HookRecord::HookRecord()
{
	Debug::start("debug_rec.txt");
	getRecordOptions();

	g_packet = new PacketRecord;
	g_packet->setRecorder(g_options);

	writeU32(g_info.hook_recv, (uint32_t)&recvHook);
	gameStateAddr = g_info.gameState;
}
Beispiel #19
0
status WAVEFile::update()
{
	Track *track = getTrack();

	if (track->fpos_first_frame != 0)
	{
		uint32_t dataLength, fileLength;

		/* Update the frame count chunk if present. */
		writeFrameCount();

		/* Update the length of the data chunk. */
		fh->seek(dataSizeOffset, File::SeekFromBeginning);

		/*
			We call _af_format_frame_size to calculate the
			frame size of normal PCM data or compressed data.
		*/
		dataLength = (uint32_t) track->data_size;
		writeU32(&dataLength);

		/* Update the length of the RIFF chunk. */
		fileLength = (uint32_t) fh->length();
		fileLength -= 8;

		fh->seek(4, File::SeekFromBeginning);
		writeU32(&fileLength);
	}

	/*
		Write the actual data that was set after initializing
		the miscellaneous IDs.	The size of the data will be
		unchanged.
	*/
	writeMiscellaneous();

	/* Write the new positions; the size of the data will be unchanged. */
	writeCues();

	return AF_SUCCEED;
}
Beispiel #20
0
void NodeMetadata::serialize(std::ostream &os) const
{
	int num_vars = m_stringvars.size();
	writeU32(os, num_vars);
	for(std::map<std::string, std::string>::const_iterator
			i = m_stringvars.begin(); i != m_stringvars.end(); i++){
		os<<serializeString(i->first);
		os<<serializeLongString(i->second);
	}

	m_inventory->serialize(os);
}
Beispiel #21
0
status AVRFile::update()
{
	uint32_t	size, loopStart, loopEnd;

	Track *track = getTrack();

	/* Seek to the position of the size field. */
	m_fh->seek(26, File::SeekFromBeginning);

	size = track->totalfframes;

	/* For the case of no loops, loopStart = 0 and loopEnd = size. */
	loopStart = 0;
	loopEnd = size;

	writeU32(&size);
	writeU32(&loopStart);
	writeU32(&loopEnd);

	return AF_SUCCEED;
}
U3DDataVector U3DBitStreamWriter::closeAndGet()
{
  if (_compressed) // Flush the arithmetic coder
  {
    writeU32(0);
  }

  alignToByte();
  putLocal();

  return _data;
}
Beispiel #23
0
void ToolCapabilities::serialize(std::ostream &os) const
{
	writeU8(os, 0); // version
	writeF1000(os, full_punch_interval);
	writeS16(os, max_drop_level);
	writeU32(os, groupcaps.size());
	for(std::map<std::string, ToolGroupCap>::const_iterator
			i = groupcaps.begin(); i != groupcaps.end(); i++){
		const std::string *name = &i->first;
		const ToolGroupCap *cap = &i->second;
		os<<serializeString(*name);
		writeF1000(os, cap->maxwear);
		writeF1000(os, cap->maxlevel);
		writeU32(os, cap->times.size());
		for(std::map<int, float>::const_iterator
				i = cap->times.begin(); i != cap->times.end(); i++){
			writeS16(os, i->first);
			writeF1000(os, i->second);
		}
	}
}
/**
 * データを書き込む。
 * float -> fixed変換を行なって書き込む。
 */
void BinaryOutputStream::writeFixed32Array(const float *data, const u32 data_length, const s32 bits) {
    fixed32 *data_array = new s32[data_length];

    // 全てfixed変換を行う
    for (u32 i = 0; i < data_length; ++i) {
        data_array[i] = real2fixed<float, fixed32>(data[i], bits);
    }

    writeU32(data_length);
    stream->write((u8*) data_array, sizeof(fixed32) * data_length);

    SAFE_DELETE_ARRAY(data_array);
}
Beispiel #25
0
status NeXTFile::writeHeader()
{
	Track *track = getTrack();

	if (fh->seek(0, File::SeekFromBeginning) != 0)
		_af_error(AF_BAD_LSEEK, "bad seek");

	uint32_t offset = track->fpos_first_frame;
	uint32_t length = track->data_size;
	uint32_t encoding = nextencodingtype(&track->f);
	uint32_t sampleRate = track->f.sampleRate;
	uint32_t channelCount = track->f.channelCount;

	fh->write(".snd", 4);
	writeU32(&offset);
	writeU32(&length);
	writeU32(&encoding);
	writeU32(&sampleRate);
	writeU32(&channelCount);

	return AF_SUCCEED;
}
Beispiel #26
0
void NodeMetadata::serialize(std::ostream &os) const
{
	int num_vars = m_stringvars.size();
	writeU32(os, num_vars);
	for (StringMap::const_iterator
			it = m_stringvars.begin();
			it != m_stringvars.end(); ++it) {
		os << serializeString(it->first);
		os << serializeLongString(it->second);
	}

	m_inventory->serialize(os);
}
Beispiel #27
0
status SampleVisionFile::writeMarkers()
{
	for (int i=0; i<8; i++)
	{
		char name[kSMPMarkerNameLength + 1];
		memset(name, ' ', kSMPMarkerNameLength);
		name[kSMPMarkerNameLength] = '\0';
		m_fh->write(name, kSMPMarkerNameLength);
		uint32_t position = kSMPInvalidSamplePosition;
		writeU32(&position);
	}
	return AF_SUCCEED;
}
U32		PGRFBroadcastEventPkt::serialize( S8 *  buf,  S32 offset ) const 
{
	U32 cur_pos = PPacketBase::serialize(buf, offset);
	S8 * buff = buf + offset;

	writeU32(buff + cur_pos, m_iPaxosType);
	cur_pos += sizeof(U32);

	writeU32(buff + cur_pos, m_iID);
	cur_pos += sizeof(U32);

	writeU32(buff + cur_pos, m_iEpoch);
	cur_pos += sizeof(U32);

	writeU64(buff + cur_pos, m_lTxid);
	cur_pos += sizeof(U64);

	cur_pos += writeString(buff + cur_pos, m_sKey);
	cur_pos += writeString(buff + cur_pos, m_sValue);

	return cur_pos;

}
Beispiel #29
0
status WAVEFile::writeData()
{
	Track *track = getTrack();

	fh->write("data", 4);
	dataSizeOffset = fh->tell();

	uint32_t chunkSize = track->data_size;

	writeU32(&chunkSize);
	track->fpos_first_frame = fh->tell();

	return AF_SUCCEED;
}
Beispiel #30
0
status SampleVisionFile::writeTrailer()
{
	Track *track = getTrack();

	m_fh->seek(track->fpos_after_data, File::SeekFromBeginning);

	uint16_t reserved = 0;
	writeU16(&reserved);

	writeLoops();
	writeMarkers();

	uint8_t midiNote = kSMPMIDIUnityPlaybackNote;
	uint32_t sampleRate = track->f.sampleRate;
	uint32_t smpteOffset = 0;
	uint32_t cycleLength = 0;

	writeU8(&midiNote);
	writeU32(&sampleRate);
	writeU32(&smpteOffset);
	writeU32(&cycleLength);
	return AF_SUCCEED;
}