本文整理汇总了C++中Music::Compact方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::Compact方法的具体用法?C++ Music::Compact怎么用?C++ Music::Compact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Music
的用法示例。
在下文中一共展示了Music::Compact方法的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;
//.........这里部分代码省略.........