Google Summer of Code summary

Hello, the GSoC is at it’s end and it is time for me to summarize my work in the past 12 weeks. In case you only want to see the code, here are the pull requests: Mission SupernovaText to speechEncoding conversion.

Projects

Mission Supernova

As the first project, I worked on an engine for Mission Supernova 2. The project description can be found here

The engine for the first Mission Supernova game was already almost finished. At first, I decided to create a separate engine (supernova2) and I started with copying code, that is the same for both games from supernova to supernova2. After this I started adding the Mission Supernova 2 specific parts (interactions with objects, rooms, …), which thanks to having the original source codes wasn’t hard. When I had most of the game working, I had to work a bit on improving the translation. There was a tool from the first engine to create translations of game strings and images with only 2 colors. But unlike with the first game, we needed to translate colored images and we also needed to recreate the original image format, which contained multiple images, that got rendered on top of each other as layers. So I created a tool, which recreates the original image format from multiple bmp images and thus allows us to translate any image we want.  At the end I merged the supernova and supernova2 engines into one called “supernova” and created a pull request, which after some modifications suggested by the community got successfully merged.
A walkthrough of the Mission Supernova 2 can be found here.
Working on this project gave me the opportunity to get to know the ScummVM code base a bit. Thanks to this, I tried to create my own midi sound, which was pretty interesting and I also learned a tiny bit of German.
After the GSoC, there will be a public testing of the Mission Supernova games and I want to be around to fix the bugs that come up.

Text to speech

Because I finished the first project early, I chose to work on a text to speech project next. The task was to implement text to speech support for ScummVM for at least 2 platforms and then use this feature in the GUI for people with reduced sight or in the Mortevielle engine. The whole project description can be found here

I begun by identifying the best text to speech backend for each platform (Linux and Windows). For Windows, the choice was pretty clear. Microsoft’s SAPI is probably the best way to implement text to speech on Windows. For Linux the choice was a bit harder. There are several backends, that can be used: eSpeak, Festival, Flite, MaryTTS, speech-dispatcher and a lot of others. Unfortunately none of those could output speech in as high quality as SAPI on Windows, or NSSpeechSynthesizer on macOS. In the end I chose speech-dispatcher, because it is just a high-level API, which uses another backend for the speech, so it is up to the user to configure the speech-dispatcher to use the backend he likes the most. And by using the speech-dispatcher, it in the future allows the user to use some backend, that doesn’t yet exist and outputs speech in comparable or better quality than Windows or macOS.
I started with implementing simple text to speech manager for Linux and then I added the same on Windows. Implementing the manager for Windows was a little bit harder, because this was the first time I developed something windows specific, so some things were pretty new to me (Windows’s heavy use of wchar_t, Microsoft’s __uuidof operator and a lot more). I also had to rewrite some parts of SAPI’s headers to work with MinGW. After implementing some basic speech managers, I added text to speech to the GUI and then also to the Mortevielle engine. Then I spent a lot of time fixing bugs and adding more features to the managers, for example: Different actions, that should be done, when trying to speak while another speech is in progress. This lead to implementing my own queueing of speeches and making the managers multi-threaded. After there were no more features to add and all tests were passing, I created a pull request
Part of the pull request is also a text to speech manager for macOS, which was implemented by my GSoC mentor Criezy.
The text to speech can be seen in action here: Windows GUILinux GUIMacOS GUIWindows MortevielleLinux MortevielleMacOS Mortevielle
Thanks to this project I learned more about how different backends are handled in ScummVM and how to add optional features and optional libraries to ScummVM (the text to speech is an optional feature). I had an opportunity to work with multiple threads, which I don’t do that often and I wrote my first Windows specific code ever.
After the GSoC, once this project gets merged, I want to be there to fix any bug, that comes up (hopefully there aren’t many of them).

Encoding conversion

Because there was still a little bit of GSoC left, I started to look for another project to work on. While working on the text to speech project, I needed to convert between different character encodings (to UTF-8 on Linux, to UTF-16 on Windows). I implemented some conversion there, but it wasn’t perfect. On another pull request, that improved cloud support in ScummVM, there was also an issue with encodings and there was a short discussion about encoding conversion on the IRC. So I decided to add a way to convert encodings to ScummVM.

I started by adding an option to compile ScummVM with iconv and implementing conversions using the iconv library (if it is available). After that, I added another ways of converting encodings (SDL_iconv_string, ansiToUnicode and unicodeToAnsi on Windows and some already existing ways of conversion within the ScummVM). The resulting code tries to use as many ways of converting encodings as possible until it succeeds. First it tries iconv, then backend conversion algorithms (SDL, Win32, …) and then TransMan (translation class in ScummVM, which can be used for some encoding conversions). After this I added transliteration from Cyrillic to ASCII, which was needed by the cloud pull request. In the end I added tests and created a pull request
This project helped me to further explore ScummVM’s code base and I learned a few new things about character encodings.
After the GSoC, once this project gets merged, I want to be there to fix any bug, that comes up.

What the GSoC gave me?

In this GSoC, I had the opportunity to experiment with quite a lot of new things for me: text to speech synthesis, encoding conversions, creating MIDI sounds, multi-threading, reading through old C code (Kernighan and Ritchie function declarations, a lot of gotos, jumps, quite a bit of assembly), I got better at VIM, I learned more things with git and a lot more. I also had to familiarize myself with quite a bit of the ScummVM’s code base. I got used to program 8 hours per day, which will, along with the experience in programming I gained, surely help me with my school projects next semester. And the most important thing: I memorized like 30 hours of metal songs 😀

What’s next?

I would like to enjoy the rest of the holidays before the school begins again, so I won’t work as much, but I certainly want to fix anything not working in my code. After this I will probably have a lot of work with my school projects, but I certainly want to find at least a little bit of time throughout the school year to work on another project for ScummVM, maybe another engine, but I don’t know yet.

This is probably my last blog post for some time, because I am not a person, that would write a blog post, unless it is really interesting or important, so good bye readers.