Wiki Page Content

Differences between revisions 8 and 9
Revision 8 as of 2009-11-24 21:28:33
Size: 1781
Editor: SheenaSmith
Comment: add categories
Revision 9 as of 2010-08-21 23:50:41
Size: 2362
Editor: SheenaSmith
Comment: update content (old wiki)
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
Line 27: Line 28:
<<Color2(green,There is a reference to the following in the old wiki. Do any of these examples belong in the new wiki?)>>
http://www.libsdl.org/cgi/docwiki.cgi/Audio_Examples
Line 39: Line 42:
*<<BR>><<Color2(green,The following example is in the old wiki between "in the audio-callback." and "While you can do that". Should it be included here or is it unnecessary?)>>
{{{
void audio_callback(void *udata, Uint8 *stream, int len)
{
    SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
}
}}}<<BR>>*
Line 41: Line 52:
 .[[SDL_OpenAudio]] *

DRAFT

SDL_MixAudio

Use this function to mix audio data.

Syntax

void SDL_MixAudio(Uint8*       dst, 
                  const Uint8* src,
                  Uint32       len, 
                  int          volume)

Function Parameters

dst

points to the destination for the mixed audio

src

points to the source audio buffer to be mixed

len

defines the length of the audio buffer in bytes

volume

ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME for full audio volume

Code Examples

You can add your code example here

green

http://www.libsdl.org/cgi/docwiki.cgi/Audio_Examples

Remarks

This takes an audio buffer src of len bytes in the playing audio format and mixes it into dst, performing addition, volume adjustment, and overflow clipping.

Note that this does not change hardware volume.

This is provided for convenience -- you can mix your own audio data.

Do not use this function for mixing together more than two streams of sample data. The output from repeated application of this function may be distorted by clipping, because there is no accumulator with greater range than the input (not to mention this being an inefficient way of doing it). Use mixing functions from SDL_mixer, OpenAL, or write your own mixer instead.

It is a common misconception that this function is required to write audio data to an output stream in the audio-callback. While you can do that, SDL_MixAudio() is really only needed when you're mixing a single audio stream with a volume adjustment.

*
green

void audio_callback(void *udata, Uint8 *stream, int len)
{
    SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
}


*


CategoryAPI, CategoryAudio

None: SDL_MixAudio (last edited 2015-01-02 21:46:19 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit