microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.57k stars 510 forks source link

Audio play mp3 Enhancement #266

Open cpyburn opened 3 years ago

cpyburn commented 3 years ago

Would be awesome if you added mp3 support to the audio.

walbourn commented 3 years ago

The SoundStreamInstance class is designed to stream content from XACT WaveBanks, so that class will only support what XACT did: PCM, ADPCM, xWMA, and XMA2 (Xbox only).

For MP3 you can use DynamicSoundEffectInstance to integrate into the DirectX Tool Kit for Audio if you have a decompression library for the format. I don't have an explicit tutorial on this, but I should so I'll make this issue a doc request. I do have this implemented using WMA via MediaFoundation in the test suite.

I also have a Xaudio2 sample (i.e. doesn't use DirectX Tool Kit for Audio) for WMA here.

Note that due to patent issues, my tutorial on additional compressed streaming formats would likely not be MP3 but Ogg Vorbis instead, but the basic pattern would apply to any audio decompression library that produces PCM data. For background on the concerns here, see wikipedia.

walbourn commented 3 years ago

It looks like there's an Ogg Vorbis library on NuGet I could use for the tutorial here:

https://www.nuget.org/packages/ogg-msvc-x64/

https://www.nuget.org/packages/ogg-msvc-x86/

cpyburn commented 3 years ago

The SoundStreamInstance class is designed to stream content from XACT WaveBanks, so that class will only support what XACT did: PCM, ADPCM, xWMA, and XMA2 (Xbox only).

For MP3 you can use DynamicSoundEffectInstance to integrate into the DirectX Tool Kit for Audio if you have a decompression library for the format. I don't have an explicit tutorial on this, but I should so I'll make this issue a doc request. I do have this implemented using WMA via MediaFoundation in the test suite.

I also have a Xaudio2 sample (i.e. doesn't use DirectX Tool Kit for Audio) for WMA here.

Note that due to patent issues, my tutorial on additional compressed streaming formats would likely not be MP3 but Ogg Vorbis instead, but the basic pattern would apply to any audio decompression library that produces PCM data. For background on the concerns here, see wikipedia.

Awesome, will you update here once you have the document completed?

walbourn commented 3 years ago

Yes.

cpyburn commented 2 years ago

Hey Chuck, I was about to give this a shot. I see that you posted some helpful links previously but haven't gotten around to the documentation. Just curious if this is still on your radar or if I should just try to backwards engineer what you have already done?

"I do have this implemented using WMA via MediaFoundation in the test suite."