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.
Anyhoo, it seems that you M$ arse licking lot (only joking! :-)))
Hey! I don’t even know if Kobo Deluxe compiles on Windoze anymore.
(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.
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!
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: