Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to embed music in my XNA game's .exe (with resources) but compiling them as a sound effect stores the music in uncompressed form, which results in a 16 MB .exe.

I can compress my music with wma, and compile it as a song, which unfortunately (in my case) leaves the music as a plain .wma file.

Basically, I want a single standalone .exe, with my content stored as resources. If I could compile a wma song to a single .xnb content file, I could embed that file. I don't know how to do that without uncompressing the music. It might be possible to keep the wma file separate and store it in the resources, but I haven't figured out how to get the .xnb content file to work with it.

In order of preference:

  • Can I compile a wma to a xnb without decompressing it?

  • Can I store the wma in the exe resources and load it into a song?

  • Is there any other way to decrease the size of an exe with embedded music?

EDIT: The comments mentioned using XACT. This seems like a good solution. I have another question. Since the XACT sounds are not loaded with Content.Load, it will not automatically look in the application resources (I have Content set up to do so). Is there a way to load XACT sounds from resources? If not, I will accept having to load content from separate files.

share|improve this question
1  
Is there any particular reason you want to do this? Is it just to protect your assets? –  Richard Marskell - Drackir Jan 13 '12 at 15:12
1  
Partly to protect my assets, partly to package everything into one .exe, but mostly because I'm trying to keep an easter egg from being too obvious. ;) –  Kendall Frey Jan 13 '12 at 15:24
    
I love Easter Eggs! –  Nate Jan 13 '12 at 15:41
    
Have you tried using XACT? –  ChrisC Jan 13 '12 at 20:28
    
@CCRicers: That is wav only, from what I read. –  Kendall Frey Jan 13 '12 at 20:38
show 2 more comments

1 Answer

Can I compile a wma to a xnb without decompressing it?

Don't think so. Unless there is drop down option in the properties when you select is in the content project.

Can I store the wma in the exe resources and load it into a song?

Yes this project creates .xnbs from what ever during runtime. I'm sure you could do something similar or even use the project directly feeding in your file instead of the selection box.

Is there any other way to decrease the size of an exe with embedded music?

Assuming the library is small enough to be worth the gain you could use a generic compression algorithm to compress the .xnb then uncompress it at load time.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.