Sign in to follow this  
Yamian

SMPEG, SDL_mixer, and MP3s

Recommended Posts

Yamian    100
okay, I'm trying to get SDL_mixer to play MP3s. I got smpeg and built it and added it's lib to my linker and included "smpeg.h". SI teher anything more I need to do to play MP3s on SDL_mixer? Plus, in the SDL_mixer header, there is a MIX_LoadMUS_RW() but for soem reason I'm having problems usign it. CAN I GET HELP!!!

Share this post


Link to post
Share on other sites
Drew_Benton    1861
If you want to use MP3's you will have to use SDL_Sound. If you still want to use SDL_Mixer, you must use OGG Voribs files. It's just a matter of re-encoding the files to go from mp3->ogg. Using OGG files are as simple as looking at Lesson 6 from Cone3D and replacing:

// Load in the music
music = Mix_LoadMUS("data/sound/(sblu)moon6.xm");

// With //

// Load in the music
music = Mix_LoadMUS("Your file.OGG");

As for SMPEG, to the best of my knowldege, I do not know anyone that has gotten it to work correctly on the Windows platform. As for SDL_SOund, I've never used it before, but I'd say go with OGG + SDL_Mixer. OGG files are license free, compared to MP3s and are of the the same quality if not better than them. They just have not caught on yet since MP3 has been around for so long.

Share this post


Link to post
Share on other sites
Yamian    100
someone said rebuld SDL_mixer and go to
the project settings and add MP3_MUSIC to the defines and add smpeg.lib to
the libraries. I don't knwo how to add defines though in vc7. I think this is a similar problem with Mix_LoadMUS_RW because around that function it says
#ifdef USE_RWOPS /* This hasn't been hooked into music.c yet */
and for the MP3 syuff, it:
#ifdef MP3_MUSIC
#include "smpeg.h"

static SDL_AudioSpec used_mixer;
#endif

so how do I add these defines?

Share this post


Link to post
Share on other sites
Yamian    100
has anyone built SMPEG and SDL_Mixer with MP3 and Mix_LoadMUS_RW support? It'd be great if you just sent me your premade stuff.

Share this post


Link to post
Share on other sites
Drew_Benton    1861
Quote:
Original post by Yamian
I don't knwo how to add defines though in vc7. So how do I add these defines?


I don't have my VS7 right now, but I think it's Project->Settings->C/C++ Tab->Preprocessor then in the Preprocessor Definitions box add in the define you need to add, so it might end up looking like: WIN32;_DEBUG;_CONSOLE;MP3_MUSIC

Share this post


Link to post
Share on other sites
Yamian    100
yes you were correct, thx Drew.

Adding it to the project's defines did nothing, but adding it to music.c is making all sorts of things happen. If I just add smpeg.lib to the project libraries and MP3_MUSIC, then I can play MP3s with SDL_mixer!! But Now I have to get SDL_LoadMUS_RW to work here si what I have so far that is diffrent from default.

All the defaults of VisualC in SDL_mixer 1.2.6
-Added mikmod.lib, native_midi.lib, timidity.lib, ogg_static.lib, vorbis_static.lib, vorbisfile_static.lib, and smpeg.lib.
-added MP3_MUSIC, USE_RWOPS, and LIBMIKMOD_MUSIC to the defines
and I'm getting


------ Build started: Project: SDL_mixer, Configuration: Release Win32 ------

Linking...
mikmod.lib(mplayer.obj) : error LNK2005: _Player_SetSynchroValue already defined in music.obj
mikmod.lib(mplayer.obj) : error LNK2005: _Player_GetSynchroValue already defined in music.obj
mikmod.lib(mplayer.obj) : warning LNK4006: _Player_SetSynchroValue already defined in music.obj; second definition ignored
mikmod.lib(mplayer.obj) : warning LNK4006: _Player_GetSynchroValue already defined in music.obj; second definition ignored
Creating library .\Release/SDL_mixer.lib and object .\Release/SDL_mixer.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
.\Release/SDL_mixer.dll : fatal error LNK1169: one or more multiply defined symbols found

Build log was saved at "file://c:\Documents and Settings\Joe\My Documents\SDL_mixer-1.2.6\VisualC\Release\BuildLog.htm"
SDL_mixer - 3 error(s), 3 warning(s)


---------------------- Done ----------------------



anyone want to try this themselves? I'll try to put in a link to my project.

Share this post


Link to post
Share on other sites
Roots    1625
Quote:
Original post by Drew_Benton
If you want to use MP3's you will have to use SDL_Sound. If you still want to use SDL_Mixer, you must use OGG Voribs files.



I'm sorry but this is absolutely not true. From the Official SDL_mixer documentation:

Quote:

SDL_mixer supports playing music and sound samples from the following formats:
- WAVE/RIFF (.wav)
- AIFF (.aiff)
- VOC (.voc)
- MOD (.mod .xm .s3m .669 .it .med and more) using included mikmod
- MIDI (.mid) using timidity or native midi hardware
- OggVorbis (.ogg) requiring ogg/vorbis libraries on system
- MP3 (.mp3) requiring SMPEG library on system
- also any command-line player, which is not mixed by SDL_mixer...


I have personally played both .ogg and .mp3 files in my game with the audio engine I wrote using SDL_mixer and there were absolutely no problems playing either. If you'd like I can help (although I haven't touched audio code in a while), or if you want to see how my audio engine is constructed you can view the source here and the header here. It's a bit much if you are only trying to write simple "load & play" demo code, but (I think) it's a good example.

Share this post


Link to post
Share on other sites
Yamian    100
Okay I'm not sure but I think the problem is Player_SetSynchroValue is defined in mikmod but is beign redefined in SDL_mixer. Here ar the two definitions in mikmod

void Player_SetSynchroValue(int i)
{
_pl_synchro_value = i;
}

and here it is in SDL_mixer:

void Player_SetSynchroValue(int i)
{
fprintf(stderr,"SDL_mixer: Player_SetSynchroValue is not supported.\n");
_pl_synchro_value = i;
}

what should I do? remove it from SDL_mixer or is teher a way to have it override the first one without an error?

Share this post


Link to post
Share on other sites
Yamian    100
OMG I GOT IT!!! There was a Player_GetSynchroValue(with GET) and a Player_SetSynchroValue(with a SET) and I just remove dtheir definition from SDL_mxier and IT WORKS!!! I CAN NOW LOAD MP3s FROM ARCHIVES!!!

Share this post


Link to post
Share on other sites
Roots    1625
You shouldn't have to modify the SDL_Mixer sourcecode for MP3 playback to work, but I'm glad you figured it out. [smile] Maybe you should tell the writer of SDL_Mixer about your troubles? He's usually in irc.freenode.net on the channel #SDL. His alias is LIM.


From the sounds of it though, I get the impression that the problem isn't with SDL_Mixer itself, but the way you installed it and/or it's dependent libraries. Can you detail exactly what you did from the start, including what platform you tried to install this on (Windows, Linux, etc?). I guess I'm a little spoiled, because I run Debian Linux and all I have to type is `apt-get install sdl-mixer1.2 sdl-mixer1.2-dev` and it installs and configures everything for me, including any dependencies that I need. [grin]

Share this post


Link to post
Share on other sites
Yamian    100
Okay, this is what I had to do. I'm using VC7 on Windows. First I got smpeg and compiled the release version of it. Then, in SDL_mixer, I used the VC6 project and imported it to VC7. I set it to release, linked smpeg.lib to it, and added MP3_MUSIC to the preprocessors. This enabled MP3 playback, but not Mix_LoadMUS_RW. What I had to do for that was add USE_RWOPS to the prepossers, which then generated an error becasue a function that it needed wasn't on, so I found that function's code and it needed MIKMODLIB_MUSIC in the prepossessors, but then there was another error. Some functions(I forgot what they were) were being redefined and were originally in mikmod, so I removed them from SDL_mixer. THen I was all excited becacuse it compiled fine and stuff. Then I made a test project and an error said SDL_LoadMUS_RW wasn'r defined, and in the SDL_mixer header, SDL_LoadMUS_RW is only used if USE_RWOPS is defined in your project. Again, super excited becasue this compiled but when I ran it there was no sound. I know I set up MP3 playback though becasue I used normal Mix_LoadMUS on it. This is very frustrating and I sent e-mails to all three authors.

Share this post


Link to post
Share on other sites
Yamian    100
I feel so silly, y didn't I do thsi before. SMPEG has a SMPEG_new_rwops meaning I don't even need SDL_mixer, just SMPEG. COMPLEETLY SKIPEPPED SDL_Mixer. I'm never going to use SL_mixer again, it makes me so mad. I CAN LAOD MP3S FROM MY CUSTOM FILE!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this