📜 ⬆️ ⬇️

Music from keygens. How it works?

A long time ago, many people were interested in one question: “This program takes only 100 kb, what kind of music does it play? How it works?"

So, this miracle is called Tracker music. And most importantly - it takes up very little space, unlike .mp3 or .wav. In today's popular OS, tracker files (MOD, XM, S3M, IT, etc.) are played by most media players, for example, Winamp, VLC, Amarok, Audacious and others.

You can download such music, for example from here - keygenmusic.net , or from here www.modarchive.org . These are not the only resources, one has only to turn to the search.
In order to play such music in our program, we need minimal knowledge of C ++, as well as minifmod, available in the source code. According to the developers, minifmod will add only 50 kb to your exe-file (without compression).

So, the brief theory is over, we start programming. For our tests, we download everything we need from here www2.zippyshare.com/v/26128618/file.html (in the archive the source of the test project, minifmod itself, one music file, converter, etc.)

Step 1. We need to get a composition in the format * .xm or * .mod (if you have a file in the format * .mod - you need to convert it to the format .xm using the mod2xm converter)

Step 2. Then open the Table extractor, File - Load menu and specify our * .xm file. The settings will be as follows:

After clicking on the Go! , in the folder with the .xm file, the Result.txt file appears. Rename it to music.h and replace the file \ loadmusic \ music.h. In this file, our music track, which we will play.

Step 3. Create a new project, and connect to it everything that lies in the lib and loadmusic. We will look like this:

Stage 4. Since in the project, the files are in the old style “C”, then the studio requires that the Precompiled Header be disabled, for this purpose we disable them in the project properties (in Visual Studio -> properties of the project -> C / C ++ - Precompiled Headers - Not Using Precompiled Headers)

Stage 5. The most important thing - it remains only to turn on the music and let it play))) I got the following entry point source file:
#include <iostream>

#include "loadmusic\loadmusic.h"
#include "lib\minifmod.h"

#define WIN32_LEAN_AND_MEAN // this will assume smaller exe

FMUSIC_MODULE *mod; // fmod music handler

using namespace std;

int main()
cout << "Press 'p' to play music " << endl << "'s' to stop" << endl << "'e' to exit" << endl;

char i( 'p' );
switch (i)
case 'p' :
if (mod == NULL) // mod handle is free? (thouh it will work fine with other loaded audio devices)
// We defined our music file to be loaded in LoadMusic.cpp //
loadmusic(); // Call & set ready memory to load the music
if (!FSOUND_Init(44100, 0)) // intialize memory for sound
return 1;

mod = FMUSIC_LoadSong(NULL, NULL); // handle = LoadSong()
FMUSIC_PlaySong(mod); // Play it (from memory)

break ;
case 's' :
if (mod != NULL) // handle is loaded (playing)?
FMUSIC_FreeSong(mod); // Free memory (handle)
FSOUND_Close(); // Close it (stop it from playing)
mod=NULL; // make handle to be Free again
break ;

cin >> i;
while (i != 'e' );

if (mod != NULL) // music is on?
FMUSIC_FreeSong(mod); // Free it from memory (the handle - "mod")
FSOUND_Close(); // Close Music

return 0;

* This source code was highlighted with Source Code Highlighter .

By default, the music starts playing immediately. If you enter 's' - then it stops, 'e' - exit the program.

What is the file size?
Testing conducted on VS 2010 Express Edition. I installed the use of static linking, after which I got an exe of 166 kb in size. In order to reduce the size - compress it using upx, with a maximum compression ratio of -9. After compressing the file, the output is an 84 kb file, which is pretty good!

UPD: maybe someone will not have a studio on hand to compile. Here is a ready-made exe, 84 kb in size download

Source: https://habr.com/ru/post/105475/

All Articles