本文整理汇总了C++中fmod::Sound::getMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::getMode方法的具体用法?C++ Sound::getMode怎么用?C++ Sound::getMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::Sound
的用法示例。
在下文中一共展示了Sound::getMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlaySound
cgID cgFMODSoundPlayerImpl::PlaySound( cgID sound , float fVolume)
{
FMOD::Sound * pkSound = m_pkSoundStorage->Find(sound);
if (!pkSound)
return CG_INVALID_ID;
FMOD::Channel * pkChannel = NULL;
m_pkFmodSystem->playSound(FMOD_CHANNEL_FREE, pkSound, true, &pkChannel);
pkChannel->setVolume(fVolume);
pkChannel->setPaused(false);
FMOD_MODE mode;
pkSound->getMode(&mode);
if(mode & FMOD_LOOP_NORMAL)
return m_pkChannelStorage->Add(pkChannel);
return CG_INVALID_ID;
}
示例2: PlayMusic
UBOOL USwFMOD::PlayMusic( UMusic* Music, FMOD::Channel* channel, BYTE SongSection, BYTE CdTrack, EMusicTransition Transition )
{
guard(USwFMOD::PlayMusic);
//SWF_LOG( NAME_DevSound, TEXT("%s >> %s :: [%s]"), SWF_PLOG, *ToStr(Music), *ToStr(SongSection), *ToStr(CdTrack), *ToStr(Transition) );
FMOD_RESULT result;
if( !Music )
return 0;
/*if( channel )
{
// there can be only one music
//SWF_LOG( NAME_DevSound, TEXT("%s :: %s :: StopMusic %s"), SWF_PLOG, *PrintChannel(musicchannel) );
SWF_FMOD_RCALL0( musicchannel->setUserData(NULL) );
SWF_FMOD_RCALL0( musicchannel->stop() );
}*/
// Non-modules use one UMusic object for each SongSection
if( Music->FileType == SoundType_OGG
|| Music->FileType == SoundType_MP2
|| Music->FileType == SoundType_MP3 )
{
Viewport->Actor->SongSection = 0;
FString postfix = GetSongSectionPostfix(SongSection);
if( postfix )
{
FString objname = FString::Printf( TEXT("%s%s.%s%s"), Music->GetName(), *postfix, Music->GetName(), *postfix);
UMusic* newmusic = Cast<UMusic>(StaticLoadObject( Music->GetClass(), NULL, *objname, NULL, LOAD_NoWarn | LOAD_Quiet, NULL ));
if( newmusic )
{
SWF_LOG( NAME_DevSound, TEXT("%s :: %s :: Dynamic Music: %s"), SWF_PLOG, *ToStr(objname) );
Music = newmusic;
Viewport->Actor->SongSection = SongSection;
}
}
SongSection = Viewport->Actor->SongSection;
}
// Register sample
FMOD::Sound* sample = RegisterMusicSample(Music);
if( !sample )
return 0;
// Sample defaults
FLOAT deffrequency;
FLOAT defvolume;
FLOAT defpanning;
INT defpriority;
FMOD_MODE fmode;
SWF_FMOD_RCALL0( sample->getDefaults( &deffrequency, &defvolume, &defpanning, &defpriority ) );
SWF_FMOD_RCALL0( sample->getMode(&fmode) );
// Channel defaults
FMOD::ChannelGroup* channelgroup = MusicChannels;
FMOD_CHANNELINDEX channelindex = IsChannelValid(channel) ? FMOD_CHANNEL_REUSE : FMOD_CHANNEL_FREE;
FLOAT frequency = deffrequency * 1.0f;
FLOAT volume = defvolume * 1.0f;
FLOAT panning = defpanning * 1.0f;
INT priority = PriorityMusic;
// Update FMOD to free finished channels
guard(UpdateFMOD);
SWF_FMOD_RCALL0( System->update() );
unguard;
// Play stream
SWF_FMOD_RCALL0( System->playSound(channelindex, sample, true, &channel) );
// SWF_FMOD_RCALL0( VerifyNewChannel(channel) );
// Update channel
SWF_FMOD_RCALL0( channel->setUserData(NULL) );
SWF_FMOD_RCALL0( channel->setChannelGroup(channelgroup) );
SWF_FMOD_RCALL0( channel->setMode(fmode) );
if( !HasFlag(fmode,FMOD_3D) )
{
SWF_FMOD_RCALL0( channel->setPan(panning) );
}
SWF_FMOD_RCALL0( channel->setFrequency(frequency) );
SWF_FMOD_RCALL0( channel->setVolume(volume) );
SWF_FMOD_RCALL0( channel->setPriority(priority) );
// restore position
result = channel->setPosition(SongSection,FMOD_TIMEUNIT_MODORDER);
FSwPosition pos = MusicPositions(SongSection);
if( pos.ms != 0 )
{
channel->setPosition(pos.ms,FMOD_TIMEUNIT_MS);
}
else
{
// TODO:: doesn't work?!
result = channel->setPosition(pos.pattern,FMOD_TIMEUNIT_MODPATTERN);
result = channel->setPosition(pos.row,FMOD_TIMEUNIT_MODROW);
}
//.........这里部分代码省略.........
示例3: FSwSoundId
UBOOL USwFMOD::PlaySound
(
AActor* Actor,
INT Id,
USound* Sound,
FVector Location,
FLOAT Volume,
FLOAT Radius,
FLOAT Pitch
)
{
guard(USwFMOD::PlaySound);
//SWF_LOG( NAME_DevSound, TEXT("%s >> %s :: [%s],[%s],[%s],[%s],[%s],[%s],[%s]"), SWF_PLOG, *ToStr(FSwSoundId(Id)), *ToStr(Actor,true), *ToStr(Sound), *ToStr(Location), *ToStr(Volume), *ToStr(Radius), *ToStr(Pitch) );
FMOD_RESULT result;
if( !Viewport || !Sound )
return 0;
// Sound slot rules
FSwSoundId SoundId = FSwSoundId(Id);
if( SoundId.GetSlot() != SLOT_None )
{
for( FSwChannelEnumerator it(System); it; ++it )
{
FMOD::Channel* channel = *it;
if( IsChannelValid(channel) )
{
FSwSoundId cid = GetChannelId(channel);
// If Actor is the same and Slot is the same:
// - prevent this sound from plaing if NoOverride
// - stop the old sound otherwise
if( cid.GetSlot() == SoundId.GetSlot()
&& cid.GetActor() == SoundId.GetActor() )
{
if( cid.GetNoOverride() )
{
//SWF_LOG( NAME_DevSound, TEXT("%s -- %s :: NO OVERRIDE <%s> <%s>"), SWF_PLOG, *ToStr(FSwSoundId(Id)), *PrintChannel(channel) );
return 0;
}
//SWF_LOG( NAME_DevSound, TEXT("%s -- %s :: STOP <%s> <%s>"), SWF_PLOG, *ToStr(SoundId), *PrintChannel(channel) );
SWF_FMOD_CALL( channel->setUserData(NULL) );
SWF_FMOD_CALL( channel->stop() );
}
}
}
}
// Register sample
FMOD::Sound* sample = RegisterSoundSample(Sound);
if( !sample )
return 0;
// Sample defaults
FLOAT deffrequency;
FLOAT defvolume;
FLOAT defpanning;
INT defpriority;
FMOD_MODE fmode;
SWF_FMOD_RCALL0( sample->getDefaults( &deffrequency, &defvolume, &defpanning, &defpriority ) );
SWF_FMOD_RCALL0( sample->getMode(&fmode) );
// Channel defaults
FMOD::ChannelGroup* channelgroup = EffectChannels;
FMOD_CHANNELINDEX channelindex = FMOD_CHANNEL_FREE;
FLOAT mindist = ToFMODFloat(DistanceMin);
FLOAT radius = ToFMODFloat(Radius);
TSwSortMinMax( mindist, radius );
FMOD_VECTOR location = ToFMODVector(Location);
FMOD_VECTOR velocity = ToFMODNormal(FVector(0,0,0));
FLOAT frequency = deffrequency * Pitch;
FLOAT volume = defvolume * Volume;
FLOAT panning = defpanning * 1.0f;
INT priority = PrioritySound;
// 2D or 3D?
AActor* ViewActor = Viewport->Actor->ViewTarget ? Viewport->Actor->ViewTarget : Viewport->Actor;
UBOOL bIs3D = Actor && (b3DCameraSounds || Actor != ViewActor);
if( bIs3D )
{
fmode &= ~FMOD_2D;
fmode |= FMOD_3D | FMOD_3D_LINEARROLLOFF;
// Radius, location & Velocity
FMOD_VECTOR location = ToFMODVector(Actor->Location);
FMOD_VECTOR velocity = ToFMODVector(Actor->Velocity);
SWF_VERIFY_FLOAT( mindist );
SWF_VERIFY_FLOAT( radius );
SWF_VERIFY_FMODVECTOR( location );
SWF_VERIFY_FMODVECTOR( velocity );
}
else
{
fmode &= ~FMOD_3D;
fmode |= FMOD_2D;
}
// Sound effects other than WAV go into compressed group (conversations most likely)
if( Sound->FileType != SoundType_WAV )
//.........这里部分代码省略.........