Launch Intro Music in XNA with SoundEffect

I have two sound files:

  • Sound A is an 18-second intro designed to play once.
  • Sound B is a 1-minute loop track

I would like to play sound A once, then as soon as sound A is finished, immediately start Sound B and continue the Sound B cycle until I stop it. This is supposed to be cyclical urban music in an RPG.

I tried to do this in code using only SoundEffect, but there is a tiny but noticeable gap between the end of sound A and the start of sound B. Even if I put the control code while watching Sound A SoundEffectInstance.State in update (), I could not run Sound B is exactly when Sound A ends so that it is seamless.

I would prefer to use SoundEffect because I can upload WMA files rather than get stuck with WAV in XACT.

+3
source share
2 answers

Possible second option. I assume that the break you hear is probably because the second sound must either be loaded into memory, initialized, or the stream open (not sure about the internal implementation). But if that is the case, I am wondering if you can do something like this:

  • Download two sound effects (a and b)
  • Starting to play sound effect A
  • start playing sound effect immediately B
  • pause sound effect B after one frame
  • when sound effect A ends, restarts sound effect A

, , B , , . , , : -)

+2

, API SoundEffect . - , XACT ... , , , XACT.

+2

Source: https://habr.com/ru/post/1744966/


All Articles