MixAudio, Icons, Logos, and linking

  1. The online documentation says we should not use SDL_MixAudio for mixing
    together more than two streams of sample data, and we should better use
    functions
    from SDL_mixer. Yet SDM_mixer (in mixer.c) does rely on SDL_MixAudio for
    mixing together all channels … so, what shall we do?

  2. I’d like to statically link SDL. From a license point of view, can I do
    it? From
    a technical point of view, how do I do it on Linux? And under Cygwin? (note
    that
    if I’m asking, it’s because I have tried, and failed).

  3. Is there an “official” SDL logo that can be displayed on applications
    splash
    screens, (e.g. “SDL inside” or “powered by SDL”)?

  4. I’d like to associate an icon to my application, under Windows.
    SDL_WM_SetIcon
    works fine on Linux, but on Windows the taskbar still displays the Windows
    icon, not
    my icon. Is there any way to change this?

Cheers,
Stephen (http://www.bigorno.net/rick/)

  1. The online documentation says we should not use SDL_MixAudio for mixing
    together more than two streams of sample data, and we should better use
    functions
    from SDL_mixer. Yet SDM_mixer (in mixer.c) does rely on SDL_MixAudio for
    mixing together all channels … so, what shall we do?

You can use MixAudio, SDL_Mixer generally just makes your life easier.

  1. I’d like to statically link SDL. From a license point of view, can I do
    it? From
    a technical point of view, how do I do it on Linux? And under Cygwin? (note
    that
    if I’m asking, it’s because I have tried, and failed).

I can’t speak for CygWin, but under Linux, generally you just need to add
it to your GCC command line:

gcc -o myprogram mysource.c /usr/local/lib/libSDL.a

(or whatever).

The license for SDL is the LGPL, which means you CAN give out a program
with SDL statically linked, so long as there is a means for the end user
to link their own version of SDL in if they want. What this means to you
is that using SDL means either releasing both a static and dynamic version
of your code (Loki does this with their games) or just release the source
so that users can rebuild with whatever version of SDL they like.

Loki releases their dynamic binaries as “unsupported”, and this is
acceptable use under the license. After all, they can’t control the sort
of crazy SDL configurations and hacks every user might be using, although
some of those users have definitely benefitted from being able to use a
custom SDL with the games (reference the ones using SDL’s null video
driver with Descent3’s dedicated server on a box with no video display).

Note that CygWin’s C runtime library is GPL’d (not LGPL’d), which means
that if you release a binary built with CygWin, you’ve “infected” your
code. The way around that is to use MingW32, but that’s beyond the scope
of this email to explain.

–ryan.

  1. The online documentation says we should not use SDL_MixAudio for mixing
    together more than two streams of sample data, and we should better use
    functions
    from SDL_mixer. Yet SDM_mixer (in mixer.c) does rely on SDL_MixAudio for
    mixing together all channels … so, what shall we do?

The comment in the docs say so because SDL_MixAudio is badly designed and
only kept for compatibility.
If SDL_mixer uses it, it should be changed not to

  1. I’d like to statically link SDL. From a license point of view, can I do
    it?

yes as long as you also provide a dynamically linked binary, or source code,
or the object files. the user must be able to use a modified sdl with your
program.

From
a technical point of view, how do I do it on Linux?

replace -lSDL with /my/directory/libSDL.a

Has anyone managed to build and use SDL_image on Windows
without using Visual Studio, Cygwin for example?

I can’t build SDL_image with mingw nor cygwin, because
libraries which are required to build SDL_image don’t
know how to build themselves on cygwin / mingw target
as shared libraries. Any ideas?

– Timo Suoranta – @Timo_K_Suoranta

  • “Mattias Engdeg?rd” :

The comment in the docs say so because SDL_MixAudio is badly designed and
only kept for compatibility. If SDL_mixer uses it, it should be changed
not to.

What should be used in place of SDL_MixAudio (can’t find anything in
SDL documentation) to stream data to the audio device?

Cheers,
Stephen

What’s wrong with raw, brutal and streamlined custom code? :slight_smile:

//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.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Monday 30 July 2001 14:50, Stephen wrote:

  • “Mattias Engdeg?rd” :

The comment in the docs say so because SDL_MixAudio is badly designed
and only kept for compatibility. If SDL_mixer uses it, it should be
changed

not to.

What should be used in place of SDL_MixAudio (can’t find anything in
SDL documentation) to stream data to the audio device?

What should be used in place of SDL_MixAudio (can’t find anything in
SDL documentation) to stream data to the audio device?

write your own mixer, or use a working one (maybe OpenAL)

  • “Mattias Engdeg?rd” :

The comment in the docs say so because SDL_MixAudio is badly designed and
only kept for compatibility. If SDL_mixer uses it, it should be changed
not to.

Excuse me? What’s wrong with SDL_MixAudio()?
(Okay, I can think of a couple of improvements, but it’s not BAD code)

See ya,
-Sam Lantinga, Lead Programmer, Loki Software, Inc.

  1. Is there an “official” SDL logo that can be displayed on applications
    splash
    screens, (e.g. “SDL inside” or “powered by SDL”)?

Nope, feel free to create your own. :slight_smile:

  1. I’d like to associate an icon to my application, under Windows.
    SDL_WM_SetIcon
    works fine on Linux, but on Windows the taskbar still displays the Windows
    icon, not
    my icon. Is there any way to change this?

“It works for me.” ™

Take a look at the testwm.c code in the test subdirectory of the SDL
source archive. I just built it under Windows to double-check and the
window manager icon works just fine.

See ya!
-Sam Lantinga, Lead Programmer, Loki Software, Inc.

Excuse me? What’s wrong with SDL_MixAudio()?
(Okay, I can think of a couple of improvements, but it’s not BAD code)

it’s bad design and that’s why I added the comment in the docs
discouraging use of it. Any function that adds two sample buffers with
clamping cannot be used for adding more than two buffers, since there
is no accumulator with the greater range necessary.

Consider adding the 16-bit samples { 19000, 22000, -15000 }.
The first call to MixAudio will do 19000 + 22000 = 41000 => clamp => 32767.
The second call, adding (-15000), yields 17767.
The correct answer is of course 19000 + 22000 + (-15000) = 26000.

Even disregarding this bug, doing it this way is inefficient since you
clamp N times (taking 1 or 2 branches each time) for each output
sample (N being the number of channels), instead of just adding all
channels and then clamp the result

A more useful mixer would accept a vector of channels to mix, each with
a given scale factor (volume), and perhaps a post-mixing volume or shift
value. It is too late to change MixAudio now but we can give it a thought
when we can change the API

[…]

A more useful mixer would accept a vector of channels to mix, each with
a given scale factor (volume), and perhaps a post-mixing volume or
shift value. It is too late to change MixAudio now but we can give it a
thought when we can change the API

Here’s one idea for a new “simple direct mixing” API:

Basic stuff:

/*
 * Set mixing volume. For mono formats, the actual
 * volume will be the average of "left" and "right".
 */
void SDL_MixVolume(int left, int right);

/*
 * Mix "len" bytes of audio from "src" into the
 * internal 32 bit buffer, starting at src[start].
 */
void SDL_MixAudio(Uint8 *src, Uint32 len, Uint32 start);


Optional features:

/*
 * Scale and clamp the current contents of the mix
 * buffer according to the mixer settings, and then
 * clear the buffer.On Monday 30 July 2001 20:59, Mattias Engdeg?rd wrote:
 *
 * (This could be one automatically, but that would
 * mean that the application can't see the final
 * output. Then again, if an application want's to
 * bypass this API, it probably shouldn't use it
 * in the first place!)
 */
void SDL_Mixdown();

/*
 * Set source format for SDL_Mix* funcs.
 * Reset to the selected format by SDL_OpenAudio().
 *
 * (Could be forced to the current audio format,
 * just as for the old SDL_MixAudio().)
 */
void SDL_MixFormat(Uint16 format, Uint8 channels);

/*
 * Master mixer scaling to apply before clamping.
 *
 * (This could be hardcoded at 1:1 input:output.)
 */
void SDL_MixMasterVolume(int left, int right);

/*
 * Select master mixing clamping method.
 *
 * (Could be hardcoded to clamping or fast AGC.)
 */
void SDL_MixMasterLimit(Uint16 mode);
#define	AUDIO_LIMIT_NONE	/* wrap... */
#define	AUDIO_LIMIT_SLOW	/* AGC + compressor */
#define	AUDIO_LIMIT_FAST	/* compressor + limiter */
#define	AUDIO_LIMIT_CLAMP	/* brutal clamping */

Then again, maybe SDL 1.3 should drop SDL_MixAudio() altogether? A split
of SDL_mixer into SDL_audio and SDL_music would probably result in a much
more powerful solution (in SDL_audio) than the above, albeit slightly
harder to use.

//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.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -’

“Sam Lantinga” :

  1. I’d like to associate an icon to my application, under Windows.
    SDL_WM_SetIcon
    works fine on Linux, but on Windows the taskbar still displays the
    Windows

icon, not
my icon. Is there any way to change this?

“It works for me.” ™

Mmm. But testwm.c has a comment that says that the icon dimensions
must be multiples of 8. And there is now a note in the documentation
(added on July 25th) that says that on Win32 the icon has to be 32*32.

Mine was 40x40. Switched to 32*32 and it works fine.

Stephen