[sdlsound] Volume control with SDL_sound

Kevin Nowaczyk beakerboy99 at yahoo.com
Fri Mar 23 13:54:54 EDT 2007

I finally got around to looking at the playsound source code.  Unfortunately it looks like it doesn't work on my computer.  When the volume multiplier is 1.0 everything works fine.  If it's anything different there is static mixed in with the audio signal.  The larger and smaller the multiplier, the louder the static and the quiter the real signal.

I think I'll have to try try looking at SDL_mixer, or pull out some code from aumix.

Kevin Nowaczyk

----- Original Message ----
From: Ryan C. Gordon <icculus at icculus.org>
To: sdlsound at icculus.org
Sent: Thursday, February 8, 2007 7:28:38 AM
Subject: Re: [sdlsound] Volume control with SDL_sound

> Is there a way to control volume level with the
> SDL_sound library?  I would like my jukebox
> application to be able to increase and decrease volume
> via buttons on the front of the jukebox.  The
> SDL_sound code I'm currently using works great as far
> as playing the files, but I don't see anything in the
> documentation for volume control.

SDL_sound only decodes audio files, it doesn't do any mixing at this 
time...whatever ends up doing the actual playback of the audio usually 
has a way to change the volume.

If you're just feeding an SDL audio callback directly with data you 
decoded through SDL_sound, you can look at playsound/playsound.c in the 
SDL_sound sources...the memcpy_with_volume() function handles this by 
modulating each sample before copying it to the output buffer that SDL 
will then send to the audio device.


Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.

More information about the sdlsound mailing list