Apologies in advance for this long post, but a lot of people made comments that I would like to respond to in detail.
I think
revision 840 should have it fixed so it builds correctly not just with Code::Blocks and MS Visual C++ on Windows, but with the Autoconf script and Makefiles on Linux/Mac OS X/etc. although I need this verified.
As for how to disable music, it is quite easy. On the main title screen when the game starts it tells you how to enable/disable music. Once you are at your base you can (R)eview your Liberals and squads and move equipment and such and there's an option to enable/disable music. The third place you can enable/disable music is in site mode when you are at a site, you can go to options, and there are 2 options, 1 to enable/disable encounter warnings and another to enable/disable music. So in 3 different places you can enable/disable music, I've tried to make it as easy as possible.
As for MIDI files having bad sound quality, well not only can you disable the sound, but this SDL2 and SDL2_mixer solution is quite good at playing back all different formats of audio, including other formats like MP3 and OGG. Some of the other formats require additional dependencies, for instance libogg, libvorbis, and libvorbisfile are ALL required to play Ogg files (3 different .DLL files on Windows, and for people on UNIX-based systems they are 3 different library dependancies). MP3 requires the smpeg library (1 .DLL). FLAC requires the libFLAC library (1 .DLL). And MOD requires libMikMod and libModPlug (2 .DLLs). MIDI, WAV, VOC, and AIFF are supported by default without external libraries.
So, if you want to add support for Ogg, actually the code for this is very simple, and SDL2_mixer can load support for various sound file formats dynamically at runtime, without having to be built against those libraries as dependencies. Those libraries are just checked for at runtime. SDL2 and SDL2_mixer are quite well done, I think. They support a wide variety of sound file formats, they don't require you to link against those libraries but can dynamically load them at runtime, and so forth.
As for if you are having bad sound quality with MIDIs, well this is a matter of taste, some people like the sound of MIDIs, others can't stand them, and a lot of times it depends on which MIDI synthesizer your computer is using. The
BASSMIDI driver version 3.1 is a MIDI soft synthesizer for MS Windows that allows you to use any SoundFont you want.
CoolSoft VirtualMIDISynth does the same thing and is quite similar to the BASSMIDI driver. Similarly, the
FluidSynth 1.1.6 synthesizer is a cross-platform MIDI soft synthesizer that can be used as your Linux MIDI synthesizer on Linux and lets you use any SoundFont you want.
Timidity++ is another cross-platform MIDI soft synthesizer that can be used as a driver on either Windows or Linux and supports not just any SoundFont but also any Gravis UltraSound patchset for MIDI synthesis. And all of these are compatible with SDL2 and SDL2_mixer. There are many excellent free SoundFonts available that can be used with these MIDI synthesizers, such as the
Arachno SoundFont, one that I am quite fond of. Personally what I use is the Yamaha S-YXG50 Soft Synthesizer for Windows XP and earlier (doesn't work on later versions, or on other operating systems, although it does work on some earlier versions of Windows like Windows 9x and Windows 2000). It's a proprietary MIDI soft synth driver but the sound quality is unmatched. Listening to MIDI files on it is sheer bliss for me. It's a shame it got discontinued by Yamaha and was never updated to work with operating systems newer than Windows XP. But there is another driver, the
VST MIDI Driver that is compatible with VSTi plugins and can use them to playback MIDI music, and you can use it along with a VSTi MIDI software synth plugin, of which there are several by companies like Yamaha and Roland, including the Yamaha S-YXG50, Roland VSC-MP1, the open-source Juce OPL2 VST plugin, and SynthFont, among many others, and you can use it as your MIDI driver on Windows XP/Vista/7/8/8.1. The VST MIDI Driver is the most advanced one but also harder to figure out than the SoundFont-based synths, since you need to find a VSTi plugin for it and only certain ones work; its advantage is that it potentially offers better sound quality than any SoundFont-based MIDI driver, for instance if you use the Yamaha S-YXG50 VSTi plugin or some other Yamaha XG synthesizer plugin (some of them might work on your system and others might not; the VST MIDI Driver is a bit more complicated than the SoundFont stuff but the increased sound quality is well worth it). The VST MIDI Driver only works on Windows though, so users of other operating systems are out of luck, whereas there are SoundFont-based MIDI drivers for all the other operating systems. The CoreAudio system on Mac OS X actually has built-in support for both DLS format soft synths and SoundFonts so you don't even need an alternate sound driver on a Mac, the SoundFont support is built-in to the default MIDI driver.
And of course you can #define DONT_USE_SDL to completely disable the SDL dependencies and music and have it compiled without any of that at all. Actually this line is in common.h, not includes.h, because that's where it needs to be in order to disable SDL from ever being included. Or you could define DONT_USE_SDL using your CFLAGS or CPPFLAGS or using a command-line define option with your compiler ("-D DONT_USE_SDL" with GCC). Right near the top of common.h are these 2 lines:
// uncomment this next line if you want to disable SDL (which is for music/sound)
//#define DONT_INCLUDE_SDL
Pretty obvious what to do, if you want to disable SDL as a dependency, and its associated music/sound, completely.
Anyway I've made it possible to disable SDL and music at compile time through a #define or at runtime through menu options that occur in 3 different parts of the game (title screen, review mode screen that you can access in base mode, and settings screen for site mode). So it's easy to disable.
Also there are many options for improving the sound quality of MIDI files, many alternate MIDI synthesizer drivers that I listed above.
If you don't like the included MIDI files you can replace them with other ones that you like better.
If you don't think MIDI music sounds good, SDL and SDL_mixer are perfectly capable of playing other formats like MP3, OGG, and even FLAC if you want super-high-quality lossless audio. And the amount of code you would need to change to switch to those other formats is actually quite small, and it's well-documented in the SDL_mixer documentation online, just look for SDL_mixer on a search engine and you can find the documentation of its API and functions and how to play other types of sound files.
If you have difficulty compiling on other platforms, well I just did
revision 840 to fix that and get this dependency working on all platforms, hopefully. If there are any errors or mistakes in my Autoconf script and you are a developer on Linux please fix them.
So, I think I have done everything possible to make this MIDI music feature one that is easy to disable or modify and try and minimize any harm it causes as collateral damage.
As for how the music changes whenever you change from one activity to another... well that is the way I envisioned it, right now there are 34 different situations in the game that have their own music, for instance each of the 5 different curses movies has its own music, I think that adds to the variety of the game. I suppose it could also just play random music out of a selection, and change which music is being played less often, but this would be harder to implement. SDL_mixer allows you to provide a callback function for when a song stops playing but its API documentation says that you shouldn't call any SDL_mixer functions from that callback function, like for instance functions to start playing a different song. Also the current code works allows for music.play() to be called from throughout the code, whether or not SDL is included, and if SDL is not included, it just does nothing. Surrounding every single call to music.play() with #ifdefs and having no music-related code at all when SDL is disabled would be a bit of overkill... way too many #ifdefs throughout the code, the way I implemented it makes disabling SDL simple and easy using a single compiler define without having checks for it all over the place in the code, and I also implemented music as an object-oriented class so that the details would be abstracted away from most of the code and internal to the class itself, and thus all of the #ifdefs would also be only inside the class itself and not pollute the rest of the code.
And yes, the poll at the beginning might be a little biased in favor of including this feature, I am sorry about that, however everything like how it is moddable and easy to disable, that is all true as I have explained, so nothing in the poll is dishonest at all. Anyway if you don't like music in the game at all, you can define DONT_INCLUDE_SDL if you're compiling it, or if you're playing it, there are several different places in the game to easily turn it off, including right at the title screen right when the game starts up, you can turn it off immediately and never hear it again. If you don't like the MIDI files but have other MIDI files you do like you can replace them. There are other MIDI synthesizers with better sound quality than the one that comes with MS Windows which can be used as MIDI drivers. You are not stuck using the MIDI format, as SDL2 and SDL2_mixer support a variety of other formats, the notable ones for people here probably being OGG, MP3, and FLAC, and all you have to do is have the right libraries present at runtime, and call the correct functions as specified in the SDL_mixer API to dynamically load support for the sound file formats you want. Adding support for other sound file formats would require editing the source code, but it's not such a big deal.
Also all of the music I used is public domain and in the code I document what the songs are and who composed them, so if you want to find, for instance, OGG or MP3 or FLAC versions of them, and then change the code to play those instead of MIDI, well this is possible if you edit the source code and doesn't require very much changes.
Anyway I am sorry if this has inconvenienced anyone such as KA101, I have tried to make this as easy as possible for everyone and not have it cause problems for anyone. And I am not really interested in making people who disagree with me look bad, ff2, everyone is entitled to their own opinion, and I myself admit this didn't go quite as smoothly as it could have gone and there is still some room for improvement. Yes, if you have a new dependency and you have to change a line of code to not have that dependency anymore it's a little inconvenient. If you want to disable MIDI music when you're playing the game but don't yet know where the option is, that's a little inconvenient. If you don't like MIDI music but like some other format better, and you don't have a good MIDI synthesizer installed or just can't stand MIDI (plenty of people are like that), well then the whole thing is rather annoying, having to listen to this awful music you hate and then try and figure out how to disable it. And if new dependencies are installed and you're trying to compile it on a platform where the project files for your IDE or the Makefiles and Autoconf scripts haven't been fixed yet so you can compile it without errors, well that's a really big problem. But I have done my best to address and solve all of these problems as best as possible. I have also done a lot of play-testing to make sure that the game works with the music and that, at the very least, I enjoy it with the music and like the selection and think that the music tracks for each situation are appropriate for the mood. Nobody is perfect, certainly not me, but still I think I did a pretty good job at this, even if it's not perfect.
Anyway... 2 lines in common.h explain how to disable this completely, 1 is a comment to explain it, the other is the define that you uncomment to disable it. It is not that hard to disable. If you prefer OGG, which is what some other games like Dwarf Fortress and many other open-source games use, well that is another option besides MIDI. OGG, MP3, and FLAC all have better quality than MIDI unless you have a really nice-sounding MIDI soft synthesizer like the ones I mentioned earlier as your default MIDI device... and most people don't have really nice-sounding MIDI soft synthesizers installed as their default MIDI devices. I guess since my computer has an extremely awesome-sounding MIDI soft synthesizer installed, the Yamaha S-YXG50, I kinda take really nice-sounding MIDI for granted and sometimes forget the fact that most people's default MIDI devices sound terrible. So for the majority of people, OGG, MP3, or FLAC would be better sound quality, and the only drawbacks would be increased filesize and even more dependencies (MP3 and FLAC just require 1 additional .DLL file each on Windows, while OGG requires 3). But luckily those aren't compile or link-time dependencies but runtime dependencies so you can compile perfectly fine without them and you only need the .DLLs or libraries there when you run the game, thanks to the advanced modular architecture of SDL, plus SDL has extremely good cross-platform support.
Also, it's actually possible to use multiple different formats of audio in the same program. So we could have some music files that are MIDI, some that are OGG, some that are MP3, and some that are FLAC, and it would be able to work with that, as long as the right .DLLs or libraries were present. Practically speaking, this is a silly idea. Most open-source games just use one music file format. GNU FreeDink, based on Dink Smallwood, is one of the games that uses MIDI, and it also uses SDL and SDL_mixer, just an older version, 1.2 instead of 2.0. The most common format in open-source games is Ogg, used by the vast majority of open-source games that have music. A bunch of open-source games even use OGG files that were all generated from MIDI files using high-quality MIDI synthesizers. That is actually very common. Just one example of this is Vulture NetHack, a GUI version of NetHack that has very nice music which was all originally MIDI and then converted to OGG, all of it under the NetHack General Public License (incompatible with the GNU GPL). This seems ironic to me, because it would use less disk space to simply use the original MIDIs, plus then you could easily edit the MIDI files in a MIDI sequencer to do stuff like change instruments, change notes, change the volume, etc., to make the music file better. But once you convert the MIDI file to OGG you can't do that kind of editing anymore. Plus it takes up more disk space. I'm not sure about the cost/benefit analysis of that... to me, at least, it seems like using MIDI directly is a better idea than using OGG files that were created from MIDI files, and one of the major reasons is because then you are free to edit the MIDI files in a MIDI sequencer at any time to improve them. The sole benefit of OGG files made from MIDI files using a high-quality synthesizer is that people on computers where the MIDI sequencers are low-quality (unfortunately, this includes the vast majority of people) would hear better quality audio. But if the files are kept as MIDI then each person can install a SoundFont-based MIDI driver and pick out their favorite SoundFont to use, for instance, and since every person has different tastes, some people would like one SoundFont better and others would like a different one better, but this way everyone would be able to get the sound quality they like the best and it would sound even better than an OGG using what one person considers a good SoundFont, because it would match the personal tastes of the person listening to it.
So really the choice of an audio format is a complex cost-benefit analysis involving a variety of different factors and not all that simple or clear-cut. MP3 is an inferior choice to OGG because MP3 is patent-encumbered and has lower audio quality at the same bitrate than OGG, so really we should only consider MIDI, OGG, and FLAC. FLAC provides the highest quality, losslessly, and is excellent for providing a perfect reproduction of an original audio recording, at the cost of file size, since FLAC is much larger than MIDI, OGG, or MP3. But then there are the legal issues about music that can be used in a GNU GPL game and what is public domain, and the various Creative Commons licenses and the complexities involved with using music licensed under one of them. According to the Free Software Foundation, although Creative Commons licenses other than CC0 are incompatible with the GNU GPL, you can use Creative Commons licensed music, sounds, art, etc. in a game or other software project as long as none of it is source code and it is all art/music type stuff. But this increases the licensing complexity of the program and means some of the program is licensed under the GNU GPL while some music files distributed with it are under various Creative Commons licenses. Right now all of Liberal Crime Squad is under the GNU GPL and that is much simpler. Also MIDI music is legally just a composition and not a performance since it is akin to sheet music, while OGG, MP3, and FLAC are all basically recordings and are akin to performances rather than just compositions so there are potentially many more copyright holders involved according to copyright law. There has never been any litigation from the music industry over MIDI files but they litigate quite a bit over audio in those other formats that people download and share on the Internet in violation of copyright laws. So while OGG and FLAC are both legally safer than MP3 because they aren't patent encumbered, MIDI is even safer legally because it is merely a composition and not a performance so there are less potential copyright holders who could get involved in a dispute.
So my choice of MIDI was made based on a variety of factors: small file size, not needing additional libraries to link against besides SDL and SDL_mixer, being able to easily edit the music, people being able to choose the MIDI soft synthesizer or SoundFont of their choice that they like the sound quality of the best, and absolutely minimal legal risk. But OGG would also be a good choice too, because it would result in better sound quality for a typical player who doesn't have some fancy MIDI synthesizer installed on their computer, the file would sound exactly the same to everyone, the format is totally open and unencumbered by any patents, it is capable of reproducing sounds that MIDI can't reproduce, such as actual audio recordings, and the file size, while bigger than MIDI, is not THAT big, plus there is a wide variety of OGG music available either as public domain or typically under Creative Commons licenses that, according to the Free Software Foundation, can be used for music or artwork bundled with a GNU GPL game even though they are not compatible with the GNU GPL, plus OGG happens to be the most popular music format for open-source GNU GPL games. One of the main reasons I chose MIDI over OGG is that Liberal Crime Squad has always used a very small amount of disk space and I thought if I increased it too much, that would be too radical of a change and controversial with people who want something really small to download. Plus MIDI files, unlike OGG or MP3 or FLAC files, can be compressed further if you put then in ZIP or other compressed files for distribution... if you compress a MIDI file inside a ZIP file it takes almost no space at all, making it easy to distribute the game, even if it has a large number of MIDI files, as a very tiny download. And OGG has several additional dependencies, you need 3 more .DLL files on Windows, and 3 more libraries installed on UNIX-based platforms. So basically it's a cost-benefit analysis involving a wide variety of factors and I went with MIDI although OGG is also a decent choice too... I wouldn't seriously consider MP3 because of the patent issues and its inferiority to OGG in terms of sound quality at the same file size, and I wouldn't seriously consider FLAC either because its file size is excessive compared to OGG for very minimal increase in sound quality compared to high-bitrate OGG that is impossible for the vast majority of people to notice.
Maybe there should be another poll on MIDI vs. OGG and I would try and make it more balanced and list advantages and disadvantages for both, although the polls here limit the amount of characters you can use so I couldn't really give complete rundowns on the pluses and minuses of each of them, I'd just have to list the most important pluses and minuses, which I suppose are MIDI being smaller than OGG on disk, OGG having better sound quality than MIDI for most people, MIDI files being easier to edit than OGG, OGG being able to reproduce any sound while MIDI can only reproduce a standard set of instruments, and OGG files sounding the same on every computer while MIDI files sound different depending on what MIDI synthesizer you use.
But yeah as for KA101 wanting to be able to compile without SDL or music at all, that's an easy option, just uncomment 1 line of code in common.h and you're done. And for the people wanting to disable music while playing the game, that option is in 3 different places, quite easy to find, I already listed where they are, the first place is right on the main title screen when the program starts.