Wiki Page Content

Differences between revisions 15 and 16
Revision 15 as of 2013-08-08 01:17:44
Size: 1391
Editor: RyanGordon
Comment: Removed DRAFT
Revision 16 as of 2015-01-02 21:44:42
Size: 1389
Comment: Changed function name so it matches examples on other pages.
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
void SDL_MixAudio(Uint8* dst,  void SDL_MixAudio(Uint8* dst,
Line 13: Line 13:
                  Uint32 len,                    Uint32 len,
Line 25: Line 25:
void myAudioCallback(void *udata, Uint8 *stream, int len) void MyAudioCallback(void *udata, Uint8 *stream, int len)

SDL_MixAudio

This function is a legacy means of mixing audio. New programs might want to use SDL_MixAudioFormat() instead.

Syntax

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

Function Parameters

dst

the destination for the mixed audio

src

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

void MyAudioCallback(void *udata, Uint8 *stream, int len)
{
    extern const Uint8 *mixData;
    SDL_memset(stream, 0, len);  // make sure this is silence.
    // mix our audio against the silence, at 50% volume.
    SDL_MixAudio(stream, mixData, len, SDL_MIX_MAXVOLUME / 2);
}

Remarks

This function is equivalent to calling

SDL_MixAudioFormat(dst, src, format, len, volume);

where format is the obtained format of the audio device from the legacy SDL_OpenAudio() function.


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