Compiling sounds into binaries

does anone have any simple methods of compiling sound files into binary
files similar to compiling xpm’s into the binarys?

remember i am stupid and lazy.–

Nice.


This message was sent using IMP, the Internet Messaging Program.

does anone have any simple 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):

#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()On Sat, 24 Jun 2006, Neil White wrote:

does anone have any simple 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.binOn Sat, 2006-06-24 at 15:44 +0200, Mattias Karlsson wrote:
On Sat, 24 Jun 2006, Neil White wrote: