I am writing a playback mechanism for looping background music with XAudio2 and SharpDX.
I converted some perfectly looping WAV files to XWM(A) with the xWMAEncode
command line utility (from the DX SDK of June 2010), but as soon as I play back the XWM file in a looping audio buffer, I notice a significantly noticable silence before it loops over.
I found out that when filling an XAudio2 audio buffer manually with a synthesized vibrato sound, no looping bug occurs. To further support this, I decoded the XWM file back into WAV, and the WAV file had exactly the same amount of silence at the end as I noticed in the playback, which turns out to be of 0,06 seconds length:
My first question is if anyone noticed the same behavior of the xWMAEncode
utility, and if it is either a bug of the utility or even of the XWMA format itself.
I'd love to know some workaround for this if it can't be fixed by the encoding of the WAV itself.
I thought of setting the LoopLength sample of the audio buffer to exactly before the silence occurs. But for that I'd need to pray that such a silence isn't dynamic depending on the sample rate. Has anyone fixed it like this before and can provide or link me to details about this?
Head-shaking corner: MP3 adds silence to the start of each file, so XWM likes to put it at the end? Do we live in times were only OGG gets stuff looping correctly?
xwmaencode
documentation in the legacy DirectX SDK Documentation CTM, it states: "Note that when looping xWMA audio, a period of silence can be introduced. Because of this possibility, looping xWMA audio should generally only be used with sounds that have smooth fade ins and outs (such as ocean waves or other subtle ambient loops)." \$\endgroup\$