🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL Audio

Started by
5 comments, last by miles vignol 22 years, 12 months ago
Can anybody point me to a good audio tut for SDL? I just don''t seem to understand it''s audio system...
Advertisement
Is this the same thing? http://www.libsdl.org
Yeah, it''s just a little light on the tutorial side of things...

I think I''ve sorta figured it out.

To my surprise, the technique employed is to call the mixing functions yourself via callback functions and a couple built-in utilities. Seemed more daunting than it turned out to be.

Just can''t seem to get the conversion routines to work now...

where''s an expert when you need one?

Any specifics on the problem you''re having with the conversion?
What format are you trying to convert from?

I''ve got a fair bit of SDL audio experience and could potentially help you out here.

The callback mixing IS a bit confusing at first. In the end it gives you a lot of freedom and power that would otherwise be very hard to abstract to the different low level audio libs like DirectSound, but SDL could really use some simple built-in LoadWavClip(), PlayAudio() type functions for getting simple audio up and playing when you don''t need that much flexibility.

Well, the problem I''m having seems to be that resampling from 8000 (my file freq) to 22050 (my playback freq) doesn''t do anything -- it just plays faster.

I''ve heard there''s a potential problem if you don''t go by a factor of 2 up or down (like 22050 will work if sampling up from 11025, for example).

I''ve never used SDL, but in general resampling should prove no problems other than a minor amount of degredation of quality to the signal. It sounds like you are playing the wavetable at a higher rate instead of resampling it. Resampling should take the signal and interpolate it so that it matches the original signal at a different rate. It is the error of the interpolation that results in a loss of quality. Changing just the sample rate will make the audio file play faster; for example, if a file with 8000 samples takes a second at 8000Hz, at 22050 it will take only 300ms-ish.

A possible solution would be to resample the files in an external program, such as GoldWave or SoundForge, and then use this with SDL. This would result in audio files about three times larger, but would solve the resampling problem.

If SDL permits it, maybe it would be easier to write your own audio routines. The canonical wave format is simple, and DirectSound provides a nice API.

Never used SDL, so sorry I can''t be of more help.
I''m learning that SDL seems to only go as far as doing factors of two scales. For example, my 8Khz file when sampled up to 22Khz only makes it to 16Khz. Something about copyrighted sampling techinques or something. I''m obviously a little vague.

I think I''ll go ahead and resample everything to a common rate externally. So much for small size...

Maybe I''ll upsample my 22Khz file to 32Khz externally and that''ll let the SDL resampling work...

This topic is closed to new replies.

Advertisement