[SDL] SDL useful for sound synthesis?

Waltzer George george.waltzer at gmail.com
Thu Sep 21 10:12:08 PDT 2006


I think that's the clasic problem trying to stream anything, regardless if
audio or video.

Have you tried to make yourself a "circular" buffer for audio?

Play in one half your precalculated 1second audio sequence for example.
Durring this, calculate/prepare your second sequence in the 2nd half buffer.

How to do this without clicks and ugly stuff? Use the treading posibility of
SDL,
create a thread(there are tutorials about this). You should play from within
that tread.
By using a locking mechanism for the buffer (a mutex), you may see from your
main
program when a half-buffer becomes empty. Pass to the tread the other
half-buffer and
start again your calculation in the "empty" buffer.

Try to use small bufers, (2- or 8 seconds long play duration?) and use
"sleep" between
your sequences of calculations.

I don't know, I just hope you could catch the ideea (I don't think it is
mine at all :) ),

I didn't tried yet but I'll have to do too something similar in future for
myself.




On 9/21/06, Louis Desjardins <lost_bits1110 at hotmail.com> wrote:
>
> Hi there,
>
> I've been browsing through the SDL site and the examples to try to figure
> whether SDL is appropriate for my application.
>
> I'm basically synthesizing my own sound using an "additive synthesis"
> technique, i.e. adding individual continuous sinusoids that each have
> their
> own phase, frequency, and amplitude.
>
> I am able to compute 10 seconds of sound and then output this to the audio
> device simply via OSS. However, I need to be able to do this in an
> "on-the-fly" manner, i.e. I cant be precalculating 10 seconds of sound,
> but
> rather, I will be calculating a few milliseconds of sound samples at a
> time
> and playing these as soon as they get processed.
>
> I just have to make sure that everything is real-time and sounds
> continuous
> and that there are no clicks or anything between samples.
>
> I am totally new to audio programming so if someone could help direct me
> as
> to whether SDL or SDL_mixer (or maybe another library) would be best
> suited
> for my needs (and why?) that woudl be great!
>
> Thanks again,
>
> LD
>
> _________________________________________________________________
> Find a local pizza place, music store, museum and more…then map the best
> route!  http://local.live.com
>
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
>
>


-- 
george
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060921/46d70f5a/attachment-0008.htm>


More information about the SDL mailing list