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


C++ Music::getTracks方法代码示例

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


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

示例1: LoadMWMusicFile

bool CMusicStudioDoc::LoadMWMusicFile(CArchive &ar)
{
	if (!ar.IsLoading())
	{
		return false;
	}

	OnNewDocument();

	mGenericInfo = CString(_T("Originaly converted from the MW music file: ")) + ar.GetFile()->GetFileName() + _T("\x0d\x0a");

	Music music;
	CStringA filenameA(ar.GetFile()->GetFilePath());
	const char *filename = filenameA.GetBuffer();
	music.LoadMusic(filename);
	music.Compact();

	ZeroMemory(mTracks,sizeof(mTracks));
	ZeroMemory(mTablesControls,sizeof(mTablesControls));
	ZeroMemory(mTablesValues,sizeof(mTablesValues));

	for (int i = 0 ; i < MusicStudio1::MusicFile::kMaxEnvelopes ; i++)
	{
		mEnvelopeNames[i] = "";
		mEnvelopes[i] = MusicStudio1::Envelope();
	}

	OptimiseTables(true);

	const std::vector<Block> &tracks = music.getTracks();

	size_t channelPos[3] = {0,0,0};
	size_t blockIndex = 0;
	int channel = 0;

	for (size_t blockIndex = 0 ; blockIndex < tracks.size() ; blockIndex++)
	{
		channel = blockIndex % MusicStudio1::MusicFile::kMaxTracks;

		if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength)
		{
			break;
		}

		const Block &trackBlock = tracks[blockIndex];

		for (size_t i = 0 ; i < trackBlock.size() ; i++)
		{
			if (trackBlock[i] == 0xff )
			{
				mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_LoopTrack;
				channelPos[channel]++;
				break;
			}
			else if (trackBlock[i] == 0xfe )
			{
				mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_StopAllTracks;
				channelPos[channel]++;
				break;
			}
			else if (trackBlock[i] == 0xfd )
			{
				// TODO: fade down?
				mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_StopAllTracks;
				channelPos[channel]++;
				break;
			}
			if ((trackBlock[i] & 0x40) == 0x40)
			{
				// TODO: Loop start/end across a range of track entries
				// Ignore for now
				i++;
			}
			unsigned char numTimes = trackBlock[i];
			i++;
			unsigned char sequence = trackBlock[i];
			// TODO: Output a warning if the sequence/block index is out of range of MusicStudio1::MusicFile::kMaxBlocks ?
			// Finally the sequence number
			if (sequence >= MusicStudio1::MusicFile::kMaxBlocks)
			{
				continue;
			}

			if (numTimes > 2)
			{
				mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_RepeatBlock | numTimes;
				channelPos[channel]++;
				if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength)
				{
					break;
				}
			}

			// Finally the sequence number
			// The sequence range is less in this format
			mTracks[channel][channelPos[channel]] = sequence & (MusicStudio1::MusicFile::kMaxBlocks - 1);
			channelPos[channel]++;
			if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength)
			{
				break;
//.........这里部分代码省略.........
开发者ID:martinpiper,项目名称:C64Public,代码行数:101,代码来源:MusicStudioDocMWMusic.cpp


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