Porblem with opening mp3 files

Hello,

i would like to open an mp3 file with the api SDL_LoadWAVRW(SDL_RWops
*src, int freesrc)

but when i try it, i got the error : Unrecognized sound file type

here is my code :

SDL_RWops* rw;
FILE* file;
file = fopen(adress,“r”);

if(!file) printf(“Error loadin file”);
rw = SDL_RWFromFP(file,1);
stream = Mix_LoadWAV_RW(rw,0) ;
SDL_FreeRW(rw);
fclose(file);

if(stream == NULL) printf(“Mix_LoadWAV_RW: %s\n”, Mix_GetError());

If i try to open a wave file, it works well.

What is wrong ?

bye.

Punx120 wrote:

i would like to open an mp3 file with the api SDL_LoadWAVRW(SDL_RWops
*src, int freesrc)

you’r kidding, aren’t you?

SDL_LoadWAVRW()
^^^

why do you think SDL has an built in mp3 decoder?

best regards …
clemens

Clemens Kirchgatterer wrote:

Punx120 <@Christiane_ARCHENAUL> wrote:

i would like to open an mp3 file with the api SDL_LoadWAVRW(SDL_RWops
*src, int freesrc)

you’r kidding, aren’t you?

SDL_LoadWAVRW()
^^^

why do you think SDL has an built in mp3 decoder?

best regards …
clemens


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Well from the documentation i read this :

|Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)|

src
The source SDL_RWops as a pointer. The sample is loaded from this.
freesrc
A non-zero value mean is will automatically close/free the src for you.

Load src for use as a sample._ This can load WAVE, AIFF, RIFF, OGG, and
VOC formats._
Using |SDL_RWops| is not covered here, but they enable
you to load from almost any source.
Returns: a pointer to the sample as a |Mix_Chunk|. NULL is returned
on errors.

So i think it’s possible to play mp3 !!!

bye

Punx120 wrote:

i would like to open an mp3 file with the api
SDL_LoadWAVRW(SDL_RWops>*src, int freesrc)

so actually you are using SDL_Mixer instead of pure SDL, but you have
written SDL_LoadWAV.

|Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)|

you could try:

Mix_Music *Mix_LoadMUS(const char *file);

instead.

So i think it’s possible to play mp3 !!!

using SDL_mixer, this is very likely. though i don’t know, if SDL_mixer
depends on a external mp3 decoder library.

hope this helps …
clemens

yeah actually i use SDL_Mixer. sorry for the mistake.
In fact, first i use Mix_LoadMUS() and it works well. but i don’t know
how to get the total length of a mp3, ont op of that, after reading the
documentation, it seems that it’s more convenient to use “channels” api,
because they provide more function essentially thanks to the structure
Mix_Chunk. so i decide to try it with those apis…

bye.

Clemens Kirchgatterer wrote:>>>>i would like to open an mp3 file with the api

SDL_LoadWAVRW(SDL_RWops>*src, int freesrc)

so actually you are using SDL_Mixer instead of pure SDL, but you have
written SDL_LoadWAV.

|Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)|

you could try:

Mix_Music *Mix_LoadMUS(const char *file);

instead.

So i think it’s possible to play mp3 !!!

using SDL_mixer, this is very likely. though i don’t know, if SDL_mixer
depends on a external mp3 decoder library.

hope this helps …
clemens


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello,

I would like to know how i can change the volume of a cd ?

thanks

bye.