本文整理汇总了C++中SoundPtr::setVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundPtr::setVolume方法的具体用法?C++ SoundPtr::setVolume怎么用?C++ SoundPtr::setVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundPtr
的用法示例。
在下文中一共展示了SoundPtr::setVolume方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
// Add a sound to the list and play it
void SoundManager::add(const std::string &file,
MWWorld::Ptr ptr,
const std::string &id,
float volume, float pitch,
float min, float max,
bool loop, bool untracked)
{
try
{
SoundPtr snd = mgr->load(file);
snd->setRepeat(loop);
snd->setVolume(volume);
snd->setPitch(pitch);
snd->setRange(min,max);
setPos(snd, ptr);
snd->play();
if (!untracked)
{
sounds[ptr][id] = WSoundPtr(snd);
}
}
catch(...)
{
std::cout << "Error loading " << file << ", skipping.\n";
}
}
示例2: playSound
void SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
{
float min, max;
const std::string &file = lookup(soundId, volume, min, max);
if (file != "")
{
SoundPtr snd = mgr->load(file);
snd->setRepeat(loop);
snd->setVolume(volume);
snd->setRange(min,max);
snd->setPitch(pitch);
snd->setRelative(true);
snd->play();
if (loop)
{
// Only add the looping sound once
IDMap::iterator it = mLoopedSounds.find(soundId);
if(it == mLoopedSounds.end())
{
mLoopedSounds[soundId] = WSoundPtr(snd);
}
}
}
}
示例3: TutorialCollisionListener
TutorialCollisionListener(Path SoundFilePath)
{
_CollisionSound = SoundManager::the()->createSound();
beginEditCP(_CollisionSound, Sound::FileFieldMask | Sound::VolumeFieldMask | Sound::StreamingFieldMask | Sound::LoopingFieldMask);
_CollisionSound->setFile(SoundFilePath);
_CollisionSound->setVolume(1.0);
_CollisionSound->setStreaming(false);
_CollisionSound->setLooping(0);
endEditCP(_CollisionSound, Sound::FileFieldMask | Sound::VolumeFieldMask | Sound::StreamingFieldMask | Sound::LoopingFieldMask);
}
示例4: playSound
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
{
if(!mData) return;
// Play and forget
float min, max;
const std::string &file = mData->lookup(soundId, volume, min, max);
if(file != "")
{
SoundPtr snd = mData->mgr->load(file);
snd->setVolume(volume);
snd->setRange(min,max);
snd->setPitch(pitch);
snd->play();
}
}
示例5: main
//.........这里部分代码省略.........
// Make Main Scene Node and add the Torus
scene = osg::Node::create();
beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
scene->setCore(osg::Group::create());
scene->addChild(TorusGeometryNode);
endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
// Create the Graphics
GraphicsPtr TutorialGraphics = osg::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
LayoutPtr MainInternalWindowLayout = osg::FlowLayout::create();
PanelPtr CaptionContainer = osg::Panel::create();
beginEditCP(CaptionContainer, Panel::PreferredSizeFieldMask | Panel::LayoutFieldMask);
CaptionContainer->setPreferredSize(Pnt2f(250.0,30.0));
CaptionContainer->setLayout(MainInternalWindowLayout);
endEditCP(CaptionContainer, Panel::PreferredSizeFieldMask | Panel::LayoutFieldMask);
//Initialize the Sound Manager
SoundManager::the()->attachUpdateProducer(TutorialWindowEventProducer);
TutorialSound = SoundManager::the()->createSound();
beginEditCP(TutorialSound, Sound::FileFieldMask | Sound::VolumeFieldMask | Sound::StreamingFieldMask | Sound::LoopingFieldMask);
TutorialSound->setFile(Path("./Data/captionSoundFile.ogg"));
TutorialSound->setVolume(1.0);
TutorialSound->setStreaming(true);
TutorialSound->setLooping(0);
endEditCP(TutorialSound, Sound::FileFieldMask | Sound::VolumeFieldMask | Sound::StreamingFieldMask | Sound::LoopingFieldMask);
// Create the Caption
TutorialCaption = osg::Caption::create();
//Add the segments of text to be displayed
TutorialCaption->captionSegment("Listeners can be used for a variety",1.7,3.4);
TutorialCaption->captionSegment("of different applications.",3.4,4.7);
TutorialCaption->captionSegment("In this tutorial we will",5.0,6.35);
TutorialCaption->captionSegment("simply be changing the background though.",6.35,8.0);
TutorialCaption->captionSegment("First we will change the",8.8,10.2);
TutorialCaption->captionSegment("torus on screen to a sphere.",10.2,11.75);
TutorialCaption->captionSegment("By timing things correctly we can make",12.7,14.6);
TutorialCaption->captionSegment("the changes right as the word is spoken.",14.6,16.75);
TutorialCaption->captionSegment("Such as changing the sphere to a cube",17.3,20.0);
TutorialCaption->captionSegment("but personally I would prefer",20.33,21.65);
TutorialCaption->captionSegment("the background to be blank.",21.65,22.8);
TutorialCaption->captionSegment("Much better!",23.8,25.0);
//Add the tutorial Caption Listener to the Caption that was set up for the tutorial
TutorialCaptionListener TheCaptionListener;
TutorialCaption->addCaptionListener(&TheCaptionListener);
//Create the Caption component Generator
TutorialCapGen = DefaultCaptionComponentGenerator::create();
TutorialCaption->attachWindowEventProducer(TutorialWindowEventProducer);
beginEditCP(TutorialCaption, Caption::ParentContainerFieldMask | Caption::ComponentGeneratorFieldMask | Caption::CaptionDialogSoundFieldMask);
TutorialCaption->setParentContainer(CaptionContainer);