Update 01/03/07: Avant toute chose, je tiens à vous dire que minifmod c'est du passé, place à... ufmod!! Par ici: http://ufmod.sourceforge.net. Ca supporte tout plein de langages (dont Delphi) et cette lib peut même être utilisée sous Linux, le pied quand même non?
Sinon ce que j'ai updaté dans ce package se trouve dans le dossier UPDATE:
- mario et lmachine, 2 appli qui utilisent pas VCL (c'est pour ça que les .exe font 30ko sans besoin de DLLs ou je ne sais quoi). Y'a un XM qui est joué avec un peu de graphique en utilisant l'api Win. C'est sympa, jettez un oeil ;) Mais bon pour jouer le XM c'est encore minifmod qui est utilisé (c'est des vieux trucs...).
- minifmod2, c'est minifmod1.7 pour Delphi que j'avais un peu updaté, le .obj complet faisant 17.8ko au lieu de 18.8ko... Mais de toutes façons c'est dépassé -> UFMOD UFMOD UFMOD!
Update 27/06/04: some bugs fixed.
[explications en français, pas inclu dans le zip]
Les fichiers au format .XM (FastTracker) sont un peu comme les fichiers .MID (Midi), à savoir qu'ils contiennent des informations pour jouer de la musique synthétique en à peine quelques kilo-octets. Un autre format très répandu est le .MOD (ProTracker), qui a d'abord été introduit sur les ordinateurs Amiga. On l'utilise encore de nos jours pour ajouter de la musique à une demoscene, à savoir des programmes offrant quelques minutes de "demo" (un paysage en rotation etc.) et dont la taille reste bien souvent inférieure à 64 kilo-octets. Le .XM est en gros une évolution du .MOD; en effet il est possible de convertir un .MOD en .XM (mais pas l'inverse), et également un .MID en .XM, et certainement d'autres formats de musique synthétique peuvent être convertis en .XM.
Le but de cette source est de montrer comment on peut lire des fichiers .XM depuis une ressource, ou depuis un fichier du disque dur, en quelques kilo-octets de code, et sans .DLL externe, à part celles du système. Vous pouvez imaginer comme il est très compliqué de programmer une librairie pour parvenir à un tel but, et il est donc intéressant de voir ce que nous propose l'Internet (d'autant qu'on ne sait rien sur ce format en tant que fichier). La meilleure librairie, la plus répandue, et donc certainement la plus utilisée est MiniFMOD, une librairie écrite en C que nous offre Fairlight Technologies (http://www.fmod.org) et qui permet de jouer des .XM en utilisant les APIs waveOut. Le problème c'est qu'elle ne va pas nous être très utile en Delphi, sauf si on peut (non pas tout transcrire, 4000 lignes de code...) le réadapter pour l'utiliser sous Delphi, et même sous n'importe quel autre language. J'avais récemment fait une source qui montre qu'on peut compiler une librairie en .C en fichier .OBJ qui peut être réutilisé en Delphi grâce à la ligne {$LINK monobj.OBJ}. C'est ce que j'ai fait avec MiniFMOD 1.7, la dernière librairie de Fairlight Technologies. Et donc voici ce que ça donne...
Vous avez dans ce 'package' 3 programmes:
- LightXMOBJ: permet de créer une version alégée de MiniFMOD.obj (qui fait au maximum 18,8 ko); en effet il existe des 'mixing effects' pour les .XM, or un .XM ne contient généralement pas tous les effets donc il n'est pas indispensable d'inclure le code pour tous ces effets de mixage. Ceci est dans le cas où vous voulez faire une demoscene avec un seul .XM, par contre pour faire un player il faut bien entendu la version complète, c'est à dire de 18,8 ko de MiniFMOD.obj.
- XMDemo: un player de .XM écrit en pure API mais bien sûr vous pouvez rééxploiter le code en utilisant la VCL.
- XMDemoscene: l'unité qui importe les fonctions du .OBJ est allégée par rapport à celle de XMDemo, elle ne contient que XMPlayFromRes et XMFree, spcéialement concu pour les demoscene, il ne vous reste plus qu'à compiler une version allegée de MiniFMOD.obj avec LightXMOBJ et s'en sera fini pour le son de votre demoscene.
également présent: MOD2XM, un programme qui permet de convertir les .MOD en .XM; si vous avez d'autres formats, regardez via un moteur de recherche sur Internet, il existe sûrement des converteurs.
Readme, l'explication du package en anglais.
Voilà! je vous laisse maintenant découvrir le .ZIP...
[explanations in english, also included in the zip]
MiniFMOD 1.7 for Delphi
for licenses and stuff (your rights to use it etc.), see the files
from the original MiniFMOD package @ http://www.fmod.org
I. Introduction
II. Compiling into .OBJ
III. The Delhi part
IV. More
I. Introduction
~~~~~~~~~~~~~~~
MiniFMOD is a free, open source, C library made by Fairlight
Technologies (http://www.fmod.org) which allows you to play .XM
files for only some kilobytes of code. What are .XM files? they
are small files (something like 20 kb) of synthetic music (a bit
like .MID, midi files). An other very well known format is the
.MOD. It was first used on Amiga computers! Nowadays, we still
use them to make our demoscenes or any program more appealing.
Sources on the Internet for playing such files are very rare, and
the best and certainly the most used library for this is MinifMOD.
The problem is, that, like I said before, the source code is in C,
so for the one who do not program in C or C++, it won't be very
useful, except if...
II. Compiling into .OBJ
~~~~~~~~~~~~~~~~~~~~~~~
.OBJ files are already compiled pieces of code, generated by
most of the common compilers. For instance, you can choose to compile
one of your C library into an .OBJ file. And what's great with it
is that you can use it with other compilers, in other languages!
Wonderful, isn'it? Exactly what we were looking for. So know we have
our library in C, we know how to put it into a .OBJ, what about making
a XM player in Delphi?
III. The Delphi part
~~~~~~~~~~~~~~~~~~~~
This is what I did, and you have in this package the result of
my work on it. Let's have a look closer:
XMDemo - This is a little player for .XM which uses all the
functions from MiniFMOD. have a look at MiniFMOD.pas
to see how the functions are imported, and at XMDemo.dpr
to see how to use them. Of course, everything is coded
in API to get a very small exe, but of course it works
as perfectly with the VCL. By the way, 43 kb the size of
the player, 21 kb when UPX'd, rather cool, no? ;-)
XMDemoscene - This is the beginning of a demoscene, your job to
finish it;-) I symplified as much as possible the
calls to the functions and eliminated some stuff we
don't need to play a .XM from a resource. You Just
need to copy MiniFMOD.pas, generates MiniFMOD.obj
(see below) and there you go with the sound of your
demoscene.
LightXMOBJ - This is the most important. Read carefully. In this
package, you've seen there are 2 files MiniFMOD.obj
which are both 18,8 kb large. The thing is, that
.XM files has channels and stuff, and there are also
mixing effects. In general, not all the mixing effects
are at the same time in one .XM, so you don't need
all the mixing effects code! the files of 18,8 kb
you've seen contains all the mixing effets (necessary
for making a player). So if you need to make a
demoscene with only one .XM in resource, you can shrink
the size of MiniFMOD.obj (and so of your final exe), by
using LightXMOBJ. You tell him where your .XM is and
he'll do automatically the stuff for you, that's
to say recompile the C code (using the exe in files\ dir),
put it into assembly, and finally output your .OBJ.
Have a look at the source code if you're more interested,
otherwise just run it, get your .OBJ and there you go!
IV. More
~~~~~~~~
I've told you about .MOD in the introduction. .XM is a kind of an
evolution of it, so you can convert .MOD files into .XM files with
mod2xm (also present in this package). I just tell this you in case you
have a .MOD and wanna play it in your code;-) I even found convertors
from mid 2 xm, and other formats, well look up on the Internet maybe
you'll find other utilities. By the way, do you know where you can get
.XM files? Of course you can do them by yourself using whatever tool,
but you can also download some from the Internet, some websites are
full of them. I've heard of a website called chiptunes where ther are
thousands of xm to download...
Maybe you don't know, but you can shrink your final exe with a tool
called UPX (type it into google), very useful I promiss. It is the most
powerful shrinker (or packer) so just try it, you won't be decieved!
Well, this is all for this package, maybe there will be future versions
of it, I don't yet... in case there are bugs (I didn't find any) and
also, what would be great is to adapt it to other languages, if you
can do it, my email is just below:D Have fun!
author: Twis
email: guigui_guigui@hotmail.com
MiniFMOD 1.7 for Delphi