SoundEffect中和SoundEffectInstance类之间差异 [英] Difference between SoundEffect and SoundEffectInstance classes

查看:179
本文介绍了SoundEffect中和SoundEffectInstance类之间差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像的问题,我不明白什么是使用这些类之间的差异。有什么优点和每个类的限制。我看了很多教程,而且还不能决定我应该怎么做。

Like in question, i don't get what is the difference between using those classes. What are advantages and limitations of each class. I read many tutorials, and still can't decide what should i do.

为了让事情更清晰,我得到AudioModule,AudioEmitterComponent和AudioListenerComponent。 (我们的游戏的eninge是基于组件。当你创建和对象,它是一些声音(怪物或某事),我添加了发射剂组分的来源..和我有问题,那么我无法弄清楚如何最好地做到这一点。首先我想音频模块搞到名单,同为听众(同时也列出了波和音库)。现在,我得到的问题,而不是编码本身(目前),但这个概念是什么,在哪里,何时,为何,任何思想是宝贵的:)

To make things more clear, i got AudioModule, AudioEmitterComponent and AudioListenerComponent. (Our game's eninge is based on component. When you create and object which is source of some sounds (monster or sth), i add emitter component.. and i got problems then. I can't figure out how to do it best. First i wanted Audio Module to got List, the same for listeners (and also lists for wave and soundbanks). Now i got problem, not in coding itself (at the moment) but with the concept what, where, when, why. Any ideas are valuable :)

推荐答案

SoundEffect中想象成声音文件。您可以加载这些使用内容管理器。

Think of SoundEffect as being the sound file. You can load these using content manager.

SoundEffectInstance 作为节目播放声音文件。

And SoundEffectInstance as a program playing the sound file.

SoundEffect中有一个播放方法。这仅仅是为了方便。这是什么做的内部是创建一个 SoundEffectInstance ,播放它,然后清理,当它完成。 (称为射后不理。)

SoundEffect has a Play method. This is just for convenience. What this does internally is create a SoundEffectInstance, play it, and then clean up when it finishes. (Known as "fire and forget".)

在使用 SoundEffectInstance (您使用 SoundEffect.CreateInstance 创建),你需要管理所有的自己 - 其优点是可以操作的同时播放声音时的声音(音量等)的属性。您还可以循环的声音,停止或暂停部分通过的方式,等等。

When using SoundEffectInstance (that you create with SoundEffect.CreateInstance) you need to manage all of that yourself - the advantage is that you can manipulate the properties of the sound (volume, etc) while the sound is playing. You can also loop the sound, stop or pause part way through, etc.

当你完成你的 SoundEffectInstance ,不要忘了的Dispose()的吧!

When you finish with your SoundEffectInstance, don't forget to Dispose() of it!

您可以用 SoundEffectInstance 做的另一件事(这是完全的可选的)是应用3D效果吧。这给你一个简单的方法来地方的声音在三维空间。您的适用的使用 SoundEffectInstance.Apply3D (给它一个监听器和发射器提供有关相机和声源信息)的3D效果。这样做的具体细节最好留给应用一个3D定位效果,以一个声音文章在MSDN上。

Another thing you can do with SoundEffectInstance (which is entirely optional) is apply a 3D effect to it. This gives you an easy way to "place" the sound in 3D space. You apply the 3D effect using SoundEffectInstance.Apply3D (giving it a listener and an emitter that provide information about the camera and the sound source). The exact details of this are best left to the "Applying a 3D Positional Effect to a Sound" article on MSDN.

这篇关于SoundEffect中和SoundEffectInstance类之间差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆