[SDL] compiling sounds into binaries
Kevin Baragona
kevinmb500 at gawab.com
Sat Jun 24 11:53:18 PDT 2006
On Sat, 2006-06-24 at 15:44 +0200, Mattias Karlsson wrote:
> On Sat, 24 Jun 2006, Neil White wrote:
>
> > does anone have any <i>simple</i> methods of compiling sound files into binary
> > files similar to compiling xpm's into the binarys?
> >
> > remember i am stupid and lazy.
>
> I would write myself a bin->c converter similar to (untested):
There is a well-tested perl program that does the same: bin2hex. I
attached the script.
>
> #include <stdio.h>
> int main(int argc, char *argv[])
> {
> FILE *in,*out;
> int value;
>
> in=fopen(argv[1],"rb");
> out=fopen(argv[2],"w");
> fprintf(out, "static unsigned char NAME_HERE[] = {\n");
> while(EOF != (value = fgetc(in))
> fprintf(out, " %d,\n", value);
> fprintf(out, "};\n");
> }
>
>
> Run it like: "bin2c file.wav file.c"
>
> Edit file.c and give the array a better name, and include it in your
> project.
>
> Finaly, use SDL_RWFromMem() instead of SDL_RWFromFile()
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin2hex.pl
Type: application/x-perl
Size: 2015 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060624/570ba98f/attachment.pl
More information about the SDL
mailing list