当前位置: 首页>>代码示例>>C++>>正文


C++ FileReader::SkipBack方法代码示例

本文整理汇总了C++中FileReader::SkipBack方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::SkipBack方法的具体用法?C++ FileReader::SkipBack怎么用?C++ FileReader::SkipBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileReader的用法示例。


在下文中一共展示了FileReader::SkipBack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IMAADPCMUnpack16

// Note: Only works for mono samples.
bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, FileReader file, uint16 blockAlign)
//-------------------------------------------------------------------------------------------
{
	static const int32 IMAIndexTab[8] =  { -1, -1, -1, -1, 2, 4, 6, 8 };
	static const int32 IMAUnpackTable[90] =
	{
		7,     8,     9,    10,    11,    12,    13,    14,
		16,    17,    19,    21,    23,    25,    28,    31,
		34,    37,    41,    45,    50,    55,    60,    66,
		73,    80,    88,    97,   107,   118,   130,   143,
		157,   173,   190,   209,   230,   253,   279,   307,
		337,   371,   408,   449,   494,   544,   598,   658,
		724,   796,   876,   963,  1060,  1166,  1282,  1411,
		1552,  1707,  1878,  2066,  2272,  2499,  2749,  3024,
		3327,  3660,  4026,  4428,  4871,  5358,  5894,  6484,
		7132,  7845,  8630,  9493, 10442, 11487, 12635, 13899,
		15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794,
		32767, 0
	};

	if((sampleLen < 4) || (!target) || (blockAlign < 5) || (blockAlign > file.GetLength()))
		return false;

	SmpLength nPos = 0;
	while((nPos < sampleLen) && file.CanRead(5))
	{
		int32 value = file.ReadIntLE<int16>();
		int32 nIndex = file.ReadIntLE<uint8>();
		nIndex = Clamp(nIndex, 0, 89);
		file.Skip(1);
		target[nPos++] = (int16)value;
		for(uint32 i = 0; (i < (blockAlign - 4u) * 2u) && (nPos < sampleLen) && file.AreBytesLeft(); i++)
		{
			uint8 delta;
			if(i & 1)
			{
				delta = (file.ReadIntLE<uint8>() >> 4) & 0x0F;
			} else
			{
				delta = file.ReadIntLE<uint8>() & 0x0F;
				file.SkipBack(1);
			}
			int32 v = IMAUnpackTable[nIndex] >> 3;
			if (delta & 1) v += IMAUnpackTable[nIndex] >> 2;
			if (delta & 2) v += IMAUnpackTable[nIndex] >> 1;
			if (delta & 4) v += IMAUnpackTable[nIndex];
			if (delta & 8) value -= v; else value += v;
			nIndex += IMAIndexTab[delta & 7];
			nIndex = Clamp(nIndex, 0, 88);
			target[nPos++] = static_cast<int16>(Clamp(value, -32768, 32767));
		}
开发者ID:fgenesis,项目名称:tyrsound,代码行数:52,代码来源:Load_wav.cpp

示例2: ReadITQ


//.........这里部分代码省略.........
			minPtr = std::min(minPtr, patPos[n]);
		}
	}

	if(fileHeader.special & ITFileHeader::embedSongMessage)
	{
		minPtr = std::min(minPtr, fileHeader.msgoffset);
	}

	// Reading IT Edit History Info
	// This is only supposed to be present if bit 1 of the special flags is set.
	// However, old versions of Schism and probably other trackers always set this bit
	// even if they don't write the edit history count. So we have to filter this out...
	// This is done by looking at the parapointers. If the history data end after
	// the first parapointer, we assume that it's actually no history data.
	if(fileHeader.special & ITFileHeader::embedEditHistory)
	{
		const uint16 nflt = file.ReadUint16LE();

		if(file.CanRead(nflt * sizeof(ITHistoryStruct)) && file.GetPosition() + nflt * sizeof(ITHistoryStruct) <= minPtr)
		{
			m_FileHistory.reserve(nflt);
			for(size_t n = 0; n < nflt; n++)
			{
				FileHistory mptHistory;
				ITHistoryStruct itHistory;
				file.ReadConvertEndianness(itHistory);
				itHistory.ConvertToMPT(mptHistory);
				m_FileHistory.push_back(mptHistory);
			}
		} else
		{
			// Oops, we were not supposed to read this.
			file.SkipBack(2);
		}
	} else if(fileHeader.highlight_major == 0 && fileHeader.highlight_minor == 0 && fileHeader.cmwt == 0x0214 && fileHeader.cwtv == 0x0214 && !memcmp(fileHeader.reserved, "\0\0\0\0", 4) && (fileHeader.special & (ITFileHeader::embedEditHistory | ITFileHeader::embedPatternHighlights)) == 0)
	{
		// Another non-conforming application is unmo3 < v2.4.0.1, which doesn't set the special bit
		// at all, but still writes the two edit history length bytes (zeroes)...
		if(file.ReadUint16LE() != 0)
		{
			// These were not zero bytes -> We're in the wrong place!
			file.SkipBack(2);
			madeWithTracker = "UNMO3";
		}
	}

	// Reading MIDI Output & Macros
	if(m_SongFlags[SONG_EMBEDMIDICFG] && file.Read(m_MidiCfg))
	{
			m_MidiCfg.Sanitize();
	}

	// Ignore MIDI data. Fixes some files like denonde.it that were made with old versions of Impulse Tracker (which didn't support Zxx filters) and have Zxx effects in the patterns.
	if(fileHeader.cwtv < 0x0214)
	{
		MemsetZero(m_MidiCfg.szMidiSFXExt);
		MemsetZero(m_MidiCfg.szMidiZXXExt);
		m_SongFlags.set(SONG_EMBEDMIDICFG);
	}

	if(file.ReadMagic("MODU"))
	{
		madeWithTracker = "BeRoTracker";
	}
开发者ID:MrEricSir,项目名称:Modipulate,代码行数:66,代码来源:Load_itq.cpp


注:本文中的FileReader::SkipBack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。