本文整理汇总了C++中SoundData::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundData::GetData方法的具体用法?C++ SoundData::GetData怎么用?C++ SoundData::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundData
的用法示例。
在下文中一共展示了SoundData::GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SD_PlayDigitized
int SD_PlayDigitized(const SoundData &which,int leftpos,int rightpos,SoundChannel chan)
{
if (!DigiMode)
return 0;
// If this sound has been played too recently, don't play it again.
// (Fix for extremely loud sounds when one plays over itself too much.)
uint32_t currentTick = SDL_GetTicks();
if (currentTick - SoundInfo.GetLastPlayTick(which) < MIN_TICKS_BETWEEN_DIGI_REPEATS)
return 0;
SoundInfo.SetLastPlayTick(which, currentTick);
int channel = chan;
if(chan == SD_GENERIC)
{
channel = Mix_GroupAvailable(1);
if(channel == -1) channel = Mix_GroupOldest(1);
if(channel == -1) // All sounds stopped in the meantime?
channel = Mix_GroupAvailable(1);
}
SD_SetPosition(channel, leftpos,rightpos);
DigiPlaying = true;
Mix_Chunk *sample = reinterpret_cast<Mix_Chunk*> (which.GetData(SoundData::DIGITAL));
if(sample == NULL)
return 0;
Mix_Volume(channel, static_cast<int> (ceil(128.0*MULTIPLY_VOLUME(SoundVolume))));
if(Mix_PlayChannel(channel, sample, 0) == -1)
{
printf("Unable to play sound: %s\n", Mix_GetError());
return 0;
}
// Return channel + 1 because zero is a valid channel.
return channel + 1;
}