Mortville Manor TTS

Hello, in the past week, I worked some more on the TTS project. First I finished the GUI TTS, I needed to make sure, that everything behaves the same way on Windows and on Linux and I had to make sure I free everything I allocate. I even had to implement reference counting for a class, which wasn’t that hard, but it still was pretty interesting, because I have never needed to do this. I also had to implement conversion of the text being said to UTF-8. On Windows this involved adding a table to the code, which would allow looking up codepage identifier by its name. On Linux I just used SDL_iconv_string, which can convert from most of the GUI encodings, but unfortunately it seems, it cannot convert from CP850, which is apparently quite often used by game engines (it is used by the Mortevielle engine and also by the supernova engine). So right now I just convert the strings like if they were in ASCII (most of the encodings are just ASCII extensions, so I hope to successfully convert at least some strings). I am thinking about using the iconv library for handling the conversion, but that would mean another dependency needed for compiling the code.

After I was happy with the state the TTS was in and everything worked for the GUI, I moved to implementing TTS to the mortevielle engine. It took me some time to get oriented enough in the engine (partly because some functions have their original french names). But once I located the correct spot, the implementation was pretty easy.
The engine uses a table of character voice pitch (number > 5 is a female voice, < 5 is a male voice):

const int haut[9] = { 0, 0, 1, -3, 6, -2, 2, 7, -1 };

At first, I wanted to map each number to a different voice, which would be alright on Linux, because there are 4 voices for each gender (some characters would still be mapped to the same voice, but I think the result would be good enough). But unfortunately it’s quite unlikely, that on the other platforms the user is going to have that many different voices. So I ended up using only one voice for every character and just changing the pitch a little bit to make them at least a little bit different. If there is ever a situation, that there is no voice for a gender, I try to simulate that genders voice by taking a voice, that is available and changing its pitch a lot (higher for female, lower for male). It sounds quite comically, but with a little bit of fantasy it works.

Here are some results of the Mortevielle TTS, I wanted to show, that switching TTS states really works (that the TTS works as it should when switching between GUI and game).

Linux:

Windows: