0
\$\begingroup\$

I've been trying to make a soundmanager recently which has several functions which fits my needs. But one thing I can't solve, is the offsetting the soundeffects.

Is it possible to play a soundeffect from a specific point? I know I have to use the buffering, but I couldn't find anything on the net about it. Any help would be appreciated!

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

When you say "from a specific point" do you mean "from a specific time" or "from a specific 3D location"? For the latter see this guide for how to do positional audio using AudioListener and AudioEmitter with SoundEffectInstance.

For the former, it's more complicated. The SoundEffect API doesn't easily expose this functionality. One approach would be to read in the raw PCM data and feed only the portion you want to play to the DynamicSoundEffectInstance class. It's a little annoying but should be perfectly doable.

XACT may offer you this functionality as well, though I'm not well versed enough to know for sure.

If you just want to resume a previously playing sound, look into use a SoundEffectInstance. If you play a SoundEffectInstance you can use Pause() to "stop" it rather than calling Stop(). If you pause an instance, you can just Resume() it to continue where it left off.

The bigger question I'd ask is what are you trying to achieve? I've not seen any examples where you'd author a sound effect and then want to start playback somewhere other than the beginning. I'd consider your actual goals and determine if this is the right solution for the problem you're actually trying to address.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .