Sine waves and C array with SDL

Hi everybody !

It probably a very basic question but I am a beginner.

I wonder if it is possible to play a sound with SDL (SDL_Mixer) from a
sine wave stored in C array ?

On the web I found a lot of results on reading a .wav file, but I want
to create the sine wave and play it on the fly…

Do you have some idea to help me ? Perhaps SDL is not the right
library to do that ?

Many thanks !

Assuming you’ve formatted it to the correct playback parameters, you can
use Mix_QuickLoad_RAW() for it.

If you’re also wanting to dynamically update the buffer of what is being
played, you’ll need to look into Mix_RegisterEffect().

The combination of the above gives you effectively the same functionality as
the regular (more bare bones) SDL audio interface but with the advantage of
being mixed into the other channels SDL_mixer is working with.

-WillOn Thu, Mar 3, 2011 at 2:34 PM, Nicolas wrote:

Hi everybody !

It probably a very basic question but I am a beginner.

I wonder if it is possible to play a sound with SDL (SDL_Mixer) from a
sine wave stored in C array ?

On the web I found a lot of results on reading a .wav file, but I want
to create the sine wave and play it on the fly…

Do you have some idea to help me ? Perhaps SDL is not the right
library to do that ?

Many thanks !