As far as music is concerned I'm basically the equivalent of a deranged monkey smashing two cymbals together. That is to say rather bluntly, not only do I not have any kind of musical talent, or a single musical bone in my body, I also don't have any real discernible musical taste. I couldn't tell you if what I am listening is good or not, let alone try and make something decent myself.
Not only am I unable to create music myself, I also need to figure out how to stream it in game. I'd rather not touch the MP3 format with a 10ft pole. Instead, the best alternative is the free and open OGG file format. I had a look around for several C# libraries for the format, but ultimately decided I'd try and write a managed wrapper for it myself. I've recently started to try learn C++ at work, so how bad could it be?
Ogg Vorbis is a very comprehensive library for compressing and uncompressing OGG data. They also provide a very simplified library called VorbisFile for reading OGG files. I figured that all I really needed to do was wrap the bare minimum required functionality in managed c++. Further more, I thought it would be wise to handle all of the memory management on the C++ side, copying directly into my Xaudio 2 buffers. Other than those two requirements, everything else could be handled in C#. While the actual C++ code for I wrote for wrapping VorbisFile is pretty small, however it wound up representing only a small fraction of the challenge for this portion of the project.
As per usual with my admittedly very small amount of C++ experience, most of the challenge was in project set up and management. First and foremost, the most intimidating thing when diving into any C++ project with external libraries, is just getting the damn things to compile. Ok, so this time not so bad. I pulled down the libraries through git, and made sure the folder structure represented what each one expected. BAM, they compiled (honestly that usually never happens). I quickly compiled the 32bit, 64bit, Release and Debug versions of the project. I set up my project, and set the "Additional Include Directories" and "Additional Dependencies" properties to include the VorbisFile library.
So what now? Guess it's time to link it with my game engine. I dropped the code in, and then hit compile. Yup, doesn't compile. So here's something I'd never really thought about. What does “Any CPU” mean anyway? Turns out it's referring to .NET just in time compiling for the hardware it's running on. So now my 32bit compiled library I'm referencing doesn't work with my "Any CPU" project because my local machine is 64bit. After doing some digging around on the good old internet, I came across a post from Scott Bilas to do with this exact problem when using a Perforce API in C#. I tried a variety of methods referenced in his post, and from the comments section, but ultimately settled on my own variation.
I have three projects set up for my music streaming library.
What works really well with this, is that the .NET C# code is the only project that needs to be referenced by any other project in the solution. The fact that the DLLs are marked as “Copy if newer” means that they always get dragged along for the ride!
The main point of this project is to get out of my comfort zone, and get some experience in every single facet of production. So in that vein, I decided that I would have a go at making the music myself.
After downloading LMMS and starting to mix some beats together, I immediately knew I was in over my head. It took me weeks to learn enough to put together 1 minute of music. I know that my first try at something isn't going to go so well, so I'm considering this music place holder, and I'll definitely be replacing it later. So with that in mind, have a listen to the video below, and try not to judge me too harshly! After all at least I gave it a go!
With art I've found that if you want to get good results, you just have to keep producing art. You'll make a lot of really bad art, but with time, and lots of iteration, each piece gets better than the last. I'm sure that the same will apply with music. However, I'm not sure if I want to spend the rest of this project (and subsequent years) working on that side of things. If I'm going to release a commercial product, I may have to spend some money, and either get some help, or buy pre-existing music.
I've realised that music and sound design are hard, and the people I work with that are in this field are extremely talented. I now have a huge amount of respect for the sound team at work! As somebody who has always been able to take care of the art and code side of a production, this has been a somewhat humbling experience. I now know how many programmers feel when faced with the choice of buying art, or learning to make it.