Jump to content
  • Advertisement
Sign in to follow this  
Yamian

SMPEG, SDL_mixer, and MP3s

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!