SDL_Mixer: I want/need to use .mp3 files for sound effects, not M$ format. How?

Currently, it seems that I can load .mp3 files only for music. But
since M$ patented their silly .asf file format (and stopped
VirtualDub from legally using it), I feel compelled to stay away from
anything M$. Plus .mp3 files are smaller, and don’t need custom
codecs.

Anyhoo, it seems that you M$ arse licking lot (only joking! :-)))
only allow loading of Mix_Chunk files from .wav files. So, how can I
(using the smpeg library) load .mp3 files for sound effects? I
assume this involves converting them to raw PCM format at run-time
(obviously at the beginning of a level or at compile time) and then
loading/ playing them as Mix_Chunks.

Thanks.

p.s. A thought has just occured to me… mpg123 can convert an mp3
file to raw PCM data (even Xing variable bit-rate mp3s, my
preference). Could I possibly use this (if it is available) at
runtime to convert mp3s to raw PCM data to feed to SDL? Or have M$
payed you off to only use .wav files? (only joking again!!! :-))))__________________________________________________
Do You Yahoo!?
Everything you’ll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Currently, it seems that I can load .mp3 files only for music. But
since M$ patented their silly .asf file format (and stopped
VirtualDub from legally using it), I feel compelled to stay away from
anything M$.

That might be a good idea for a lot of reasons. Most of it has caused me nothing but trouble, with no means or legal possibilities for me to fix anything... :-/

Plus .mp3 files are smaller, and don’t need custom codecs.

Don’t know about “custom”… Anything you have to adapt to a particular
situation could be called “custom”, even if it’s based on widely used
standard stuff. :slight_smile:

Anyhoo, it seems that you M$ arse licking lot (only joking! :-)))

Hey! I don’t even know if Kobo Deluxe compiles on Windoze anymore. :wink:
(Although that’s only because the last upgrade broke my cross
compiler…)

only allow loading of Mix_Chunk files from .wav files. So, how can I
(using the smpeg library) load .mp3 files for sound effects? I

Check out Ryan Gordon’s SDL_sound; I think it will do what you want:

http://icculus.org/SDL_sound/

assume this involves converting them to raw PCM format at run-time
(obviously at the beginning of a level or at compile time) and then
loading/ playing them as Mix_Chunks.

Yeah, something like that…

Might be a good idea to do it while loading (or at compile time) anyway,
as playing multiple channels of mp3, Ogg Vorbis and the like might still
be a bit too heavy for the average CPU, at least if it’s supposed to run
a full screen animated game at the same time. :wink:

Note that it might not be all that nice to handle background music the
same way. (Will take “ages” on slow machines!) Preferably use something
that can be decompressed/rendered/ in real time instead. One
mp3 or Ogg stream is probably OK, at least if it can be turned off, or
the game requires enough CPU anyway, that the music will only burn a few
% of the power.

Thanks.

p.s. A thought has just occured to me… mpg123 can convert an mp3
file to raw PCM data (even Xing variable bit-rate mp3s, my
preference). Could I possibly use this (if it is available) at
runtime to convert mp3s to raw PCM data to feed to SDL?

Yeah, that would be possible, but it won’t be terribly efficient, unless
you can have mpg123 output into a shared memory buffer or something…

(Perhaps no big deal if you’re not going to stream real time, though.)

Or have M$
payed you off to only use .wav files? (only joking again!!! :-))))

Dunno - I didn’t write a single line of that code! :slight_smile:

Either way, it doesn’t really apply, as SDL, not SDL_mixer does real time
streaming from “external sources”, AFAIK. That is, to do anything like
that, you have to set it up yourself, and implement it all the way down
to the raw audio stream fed to SDL or SDL_mixer.

Note that this is another thing that may change if/when SDL_sound becomes
the “codec backend” for SDL_mixer. Separating the decoding from the
mixing opens up a lot of possibilities.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Monday 19 November 2001 01:59, F ker wrote:

And why arnt we using vorbis oggs? Vorbis oggs can be played anywhere.On 19-Nov-2001, F ker wrote:

Currently, it seems that I can load .mp3 files only for music. But
since M$ patented their silly .asf file format (and stopped
VirtualDub from legally using it), I feel compelled to stay away from
anything M$. Plus .mp3 files are smaller, and don’t need custom
codecs.

Anyhoo, it seems that you M$ arse licking lot (only joking! :-)))
only allow loading of Mix_Chunk files from .wav files. So, how can I
(using the smpeg library) load .mp3 files for sound effects? I
assume this involves converting them to raw PCM format at run-time
(obviously at the beginning of a level or at compile time) and then
loading/ playing them as Mix_Chunks.

Thanks.

p.s. A thought has just occured to me… mpg123 can convert an mp3
file to raw PCM data (even Xing variable bit-rate mp3s, my
preference). Could I possibly use this (if it is available) at
runtime to convert mp3s to raw PCM data to feed to SDL? Or have M$
payed you off to only use .wav files? (only joking again!!! :-))))


Do You Yahoo!?
Everything you’ll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


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


Patrick “Diablo-D3” McFarland || unknown at panax.com

p.s. A thought has just occured to me… mpg123 can convert an mp3
file to raw PCM data (even Xing variable bit-rate mp3s, my
preference).

If you are using Xing to encode variable bit-rate mp3’s, you should
definately have a look at r3mix.net. A page more or less dedicated to
explaining why the open source Lame encoder is far superior to anything
else. Xing is known to distort, clip and introduce terrible artifacts.

Regards
Rickard Andersson

— Patrick McFarland wrote:

And why arnt we using vorbis oggs? Vorbis oggs can be played
anywhere.

Cos SDL_Mixer doesn’t allow them to be played as sound effects
either, just background music. Anyway, I’ll use SDL_Sound now, which
allows whatever.

p.s. Am I right in assuming that only the Creative SBLive allows 32
simultaneous sound channels through /dev/dsp?__________________________________________________
Do You Yahoo!?
Everything you’ll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

If you are using Xing to encode variable bit-rate mp3’s, you should
definately have a look at r3mix.net. A page more or less dedicated
to
explaining why the open source Lame encoder is far superior to
anything
else. Xing is known to distort, clip and introduce terrible
artifacts.

hmm… thanks.

But, I’ll be using SDL_Sound and oggvorbis for sound effects and
music now.

Still, I could re-encode all my CD ripped mp3s on my hd with
Lame…

Thanks
F__________________________________________________
Do You Yahoo!?
Everything you’ll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

[…]

p.s. Am I right in assuming that only the Creative SBLive allows 32
simultaneous sound channels through /dev/dsp?

Unless you’re going to bypass SDL for the sound I/O, the card’s hardware
mixing capabilities can’t be used. (Unless you start multiple instances
of the application, of course!) You need to use multiple open on OSS, or
ALSA to make use of hardware mixing whithin an application.

AFIK, SDL_mixer uses SDL’s audio API only, and always does it’s own
software mixing.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Monday 19 November 2001 18:42, F ker wrote:

But, I’ll be using SDL_Sound and oggvorbis for sound effects and
music now

Note that mp3 has a rather serious limitation that a signal has to be an
integer number of mp3 frames in size, which means when a wav is encoded,
the encoder has to pad the start and end by some amount of silence, or
perhaps cut the sound off a little (evil encoder).

Using mp3 for sound effects can mess up timing, and also means you can’t
cleanly loop sounds without some tweaking. Beware.

Repeatedly encoding/decoding mp3 will gradually add more padding…

I have no idea if ogg/vorbis has the same limitation.

But, I’ll be using SDL_Sound and oggvorbis for sound effects and
music now.

Still, I could re-encode all my CD ripped mp3s on my hd with
Lame…

(While we’re advertising my software… :slight_smile:

Check out http://icculus.org/mp3check/ for a convenient way to reencode
batches of MP3s with LAME. Could be handy for people managing game assets.

More on topic, please let me know what sort of successes and failures you
have with SDL_sound; it’s still being proven, especially with multiple
streams being decoded at once.

–ryan.