Brightness and Sound output adjustment..?

Hi All! :slight_smile:

Right… got a couple of questions…

Firstly, what’s the best way to change the brightness (or gamma) of an SDL
app? I’d like to give my players the option to adjust the brightness via a
menu option. I’ve tried SDL_SetGamma()… but it gave really sTrAngE rEsuLtS.

Also… and I guess this might be one for Sam or some SDL Mixer Gurus… When
opening the mixer, there is a choice of 1 or 2 (third parameter in
Mix_OpenAudio) for either Mono or Stereo. Is it possible to change these at
run time…? I’d also like to give the players the ability to change between
Mono and Stereo output.

Cheers, guys,

Stevie :slight_smile:

I don’t know about SDL_Gamma, but for the sound problem can’t you keep
the current value somewhere, then just close and reopen the audio
stream?

Something a bit like

void toggleStereo()
{
static bool stereo = true;

Mix_CloseAudio(); //Or however you call it

if(stereo)
{
    stereo = false;
    Mix_OpenAudio(blah, blah, mono ... );
}
else
{
    stereo = true;
    Mix_OpenAudio(blah, blah, stereo ... ):
}

}

— Stephen Sweeney <stephen.sweeney at parallelrealities.co.uk> wrote: >
Hi All! :)>

Right… got a couple of questions…

Firstly, what’s the best way to change the brightness (or gamma) of
an SDL
app? I’d like to give my players the option to adjust the brightness
via a
menu option. I’ve tried SDL_SetGamma()… but it gave really sTrAngE
rEsuLtS.

Also… and I guess this might be one for Sam or some SDL Mixer
Gurus… When
opening the mixer, there is a choice of 1 or 2 (third parameter in
Mix_OpenAudio) for either Mono or Stereo. Is it possible to change
these at
run time…? I’d also like to give the players the ability to change
between
Mono and Stereo output.

Cheers, guys,

Stevie :slight_smile:


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


Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk

Also… and I guess this might be one for Sam or some SDL Mixer Gurus… When
opening the mixer, there is a choice of 1 or 2 (third parameter in
Mix_OpenAudio) for either Mono or Stereo. Is it possible to change these at
run time…? I’d also like to give the players the ability to change between
Mono and Stereo output.

Not without shutting down the mixer and restarting it (which shuts down
the audio device and restarts it in the new format).

–ryan.

Hi All! :slight_smile:

Right… got a couple of questions…

Firstly, what’s the best way to change the brightness (or gamma) of
an SDL app? I’d like to give my players the option to adjust the
brightness via a menu option. I’ve tried SDL_SetGamma()… but it
gave really sTrAngE rEsuLtS.

AFAIK, SDL_SetGamma() relies on h/w support, and has no effect unless
there actually is h/w gamma support.

Now, any reasonably modern RAMDAC supports gamma tables, and most
drivers on most platforms seem to implement the related features in
the common APIs. If anything at all happens, you probably have
working gamma support.

So, what does “sTrAngE rEsuLtS” mean, exactly?

Note that you should normally use the same value for all three
arguments. The separate R, G and B controls are meant for finetuning
the “dynamic” color balance. Probably not worth messing with unless
you’re working on a color calibration tool.

Also note that you can implement brightness/contrast controls and
other stuff using this feature as well. The “real” interface is
SDL_SetGammaRamp(), which allows you to program the translation
tables directly.

Also… and I guess this might be one for Sam or some SDL Mixer
Gurus… When opening the mixer, there is a choice of 1 or 2 (third
parameter in Mix_OpenAudio) for either Mono or Stereo. Is it
possible to change these at run time…? I’d also like to give the
players the ability to change between Mono and Stereo output.

Generally, you have to reopen the device to change this. Your average
sound card has a single CODEC and a single DMA channel for output,
and switching between mono/stereo means you have to reinitialize the
card. Some professional studio sound interfaces have N DAC channels
hardwired to N mono outputs, but only a few studio oriented driver
architectures let you open/close mono channels independently without
restrictions, so it doesn’t really make a difference to your average
user.

The point is that that sort of stuff is very non-portable and most
probably way beyond the scope of SDL and SDL_mixer.

Anyway, you shouldn’t really have to restart SDL_mixer and reload all
sounds and music etc - but that depends on the implementation. I
don’t know if SDL_mixer can reinit with different audio I/O
parameters, or if not, how hard it would be to add such a feature.

As to the sound card/driver side, a close/open cycle is generally very
fast. It might cause a click, and at worst, a short moment of
silence, but switching at run time is not a problem for normal
applications.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Thursday 16 October 2003 17.07, Stephen Sweeney wrote:

So, what does “sTrAngE rEsuLtS” mean, exactly?

Oh… I was setting Gamma in the region of 5 or something! It was causing all
the colors to bleed and blend into each other. I’ve been more cautious now
and allowed the user to adjust the gamma between values of 0.1 and 2.0. It
works perfectly now :slight_smile:

Generally, you have to reopen the device to change this. Your average
sound card has a single CODEC and a single DMA channel for output,
and switching between mono/stereo means you have to reinitialize the
card. Some professional studio sound interfaces have N DAC channels
hardwired to N mono outputs, but only a few studio oriented driver
architectures let you open/close mono channels independently without
restrictions, so it doesn’t really make a difference to your average
user.

The point is that that sort of stuff is very non-portable and most
probably way beyond the scope of SDL and SDL_mixer.

Hmmm, might give this a miss then… Or let the player know they will have to
just restart the game in order to make the change take effect on the first
Init… :slight_smile:

Thanks very much :slight_smile:

Stevie :)On Friday 17 Oct 2003 10:05, David Olofson wrote:

So, what does “sTrAngE rEsuLtS” mean, exactly?

Oh… I was setting Gamma in the region of 5 or something! It was
causing all the colors to bleed and blend into each other.

hehe I kinda’ suspected that. :slight_smile:

I’ve
been more cautious now and allowed the user to adjust the gamma
between values of 0.1 and 2.0. It works perfectly now :slight_smile:

Great. :slight_smile:

[…sound reinit…]

Hmmm, might give this a miss then… Or let the player know they
will have to just restart the game in order to make the change take
effect on the first Init… :slight_smile:

Well, if you have the game init/loading code reasonably well
organized, what keeps you from just reinitializing the sound as
needed? If certain parameters have been changed, just close and
unload everything, and then run your audio init + loading code again.

I even do that in Kobo Deluxe, despite having written both the
graphics and audio engines myself. It’s easier to get it robust and
reliable that way, though being smarter about some parts of it could
speed up the user configuration/tweaking process a bit.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Saturday 18 October 2003 18.17, Stephen Sweeney wrote:

On Friday 17 Oct 2003 10:05, David Olofson wrote: