|
Size: 2259
Comment: minor change
|
Size: 5195
Comment: update content (old wiki)
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 7: | Line 7: |
| A structure that describes the audio output format. It contains a callback that is called when the audio device needs more data. | A structure that ^contains^ ,,describes,, the audio output format. It ^also^ contains a callback that is called when the audio device needs more data. |
| Line 12: | Line 12: |
| <<Color2(green,added '''padding''' value - seems to be new; should SDL_Audio``Callback not be a link because there won't be a page?)>> ||int||'''freq'''||DSP frequency (samples per second)|| ||[[SDL_AudioFormat]]||'''format'''||audio data format|| ||Uint8||'''channels'''||number of channels: 1 mono, 2 stereo|| |
<<Color2(green,Should SDL_Audio``Callback not be a link because there won't be a page? Can '''channels''' only be 1 or 2 or can it handle more? Old wiki lists 4 for surround and 6 for surround w/ center and lfe (sub?). Should it be 1=mono instead of just 1 mono etc.?)>> ||int||'''freq'''||DSP frequency (samples per second); see [[#Remarks|Remarks]] for details|| ||[[SDL_AudioFormat]]||'''format'''||audio data format; see [[#Remarks|Remarks]] for details|| ||Uint8||'''channels'''||number of channels: 1 mono, 2 stereo; see [[#Remarks|Remarks]] for details|| |
| Line 17: | Line 17: |
| ||Uint16||'''samples'''||audio buffer size in samples (power of 2)|| | ||Uint16||'''samples'''||audio buffer size in samples (power of 2); see [[#Remarks|Remarks]] for details|| |
| Line 29: | Line 29: |
| The calculated values '''silence''' and '''size''' are calculated by [[SDL_OpenAudio]](). | <<Color2(green,Should the functions [[SDL_LoadWAV_RW]] and [[SDL_OpenAudioDevice]] be added into this remark? Do they behave like their similarly named counterparts with respect to this struct?)>> *<<BR>>The [[SDL_AudioSpec]] structure is used to describe the format of some audio data. This structure is used by [[SDL_OpenAudio]]() and [[SDL_LoadWAV]](). While all fields are used by [[SDL_OpenAudio]](), only '''freq''', '''format''', '''channels''', and '''samples''' are used by [[SDL_LoadWAV]](). ,,We will detail these common members here:,, '''freq''' ^specifies^ the number of samples sent to the sound device ,,every,, ^per^ second. Common values are 11025, 22050 and 44100. The higher the better. <<Color2(green,I think this info could be moved to Params above and this paragraph removed.)>><<Color2(green,I think "The higher the better." implies that the programmer has a choice and should choose the higher number. I suspect that the value is actually dictated by the audio data. Perhaps rewording to say "Higher values produce higher quality sounds/audio output" might be preferable?)>> '''format''' specifies the size and type of each sample element. ,,Values it can take are:,, ^It may be one of the following values:^ ||AUDIO_U8||unsigned 8-bit samples.|| ||AUDIO_S8||signed 8-bit samples.|| ||AUDIO_U16 or AUDIO_U16LSB||not supported by all hardware (unsigned 16-bit little-endian)|| ||AUDIO_S16 or AUDIO_S16LSB||not supported by all hardware (signed 16-bit little-endian)|| ||AUDIO_U16MSB||not supported by all hardware (unsigned 16-bit big-endian)|| ||AUDIO_S16MSB||not supported by all hardware (signed 16-bit big-endian)|| ||AUDIO_U16SYS||either AUDIO_U16LSB or AUDIO_U16MSB depending on hardware CPU endianness|| ||AUDIO_S16SYS||either AUDIO_S16LSB or AUDIO_S16MSB depending on hardware CPU endianness|| '''channels''' ^specifies^ the number of separate sound channels. 1 is mono (single channel), 2 is stereo (dual channel). <<Color2(green,I think this paragraph is redundant with Params above and can be removed.)>> '''samples''' ^specifies a unit of audio data.^ When used with [[SDL_OpenAudio]]() this refers to the size of the audio buffer in samples. A sample is a chunk of audio data of the size specified in '''format''' multiplied by the number of channels. When the [[SDL_AudioSpec]] is used with [[SDL_LoadWAV]]() '''samples''' is set to 4096. <<Color2(green,Params above specifies that this is a "power of 2". Would it be appropriate to show how to determine/calculate this value here?)>> <<BR>>* The ,,calculated,, values '''silence''' and '''size''' are calculated by [[SDL_OpenAudio]](). |
| Line 45: | Line 66: |
| ||'''userdata'''||an application-specific parameter saved in the [[SDL_AudioSpec]] structure|| ||'''stream'''||a pointer to the audio data buffer to be filled in by the callback|| ||'''len'''||the length of that buffer in bytes|| |
^with the following parameters:^ ||'''userdata'''||an application-specific parameter saved in the [[SDL_AudioSpec]] structure|| ||'''stream'''||a pointer to the audio data buffer to be filled in by the callback|| ||'''len'''||the length of that buffer in bytes|| |
| Line 52: | Line 74: |
| .[[SDL_LoadWAV]] * |
DRAFT |
SDL_AudioSpec
A structure that contains describes the audio output format. It also contains a callback that is called when the audio device needs more data.
Data Fields
<<Color2: execution failed [No argument named "Should SDL_Audio``Callback not be a link because there won't be a page? Can '''channels''' only be 1 or 2 or can it handle more? Old wiki lists 4 for surround and 6 for surround w/ center and lfe (sub?). Should it be 1"] (see also the log)>>
int |
freq |
DSP frequency (samples per second); see Remarks for details |
format |
audio data format; see Remarks for details |
|
Uint8 |
channels |
number of channels: 1 mono, 2 stereo; see Remarks for details |
Uint8 |
silence |
audio buffer silence value (calculated) |
Uint16 |
samples |
audio buffer size in samples (power of 2); see Remarks for details |
Uint16 |
padding |
necessary for some compile environments |
Uint32 |
size |
audio buffer size in bytes (calculated) |
callback |
a function that is called when the audio device needs more data; see Remarks for details |
|
void* |
userdata |
a pointer that is passed as the first parameter to callback |
Code Examples
You can add your code example here
Remarks
green
*
The SDL_AudioSpec structure is used to describe the format of some audio data. This structure is used by SDL_OpenAudio() and SDL_LoadWAV(). While all fields are used by SDL_OpenAudio(), only freq, format, channels, and samples are used by SDL_LoadWAV(). We will detail these common members here:
freq specifies the number of samples sent to the sound device every per second. Common values are 11025, 22050 and 44100. The higher the better. green
green
format specifies the size and type of each sample element. Values it can take are: It may be one of the following values:
AUDIO_U8 |
unsigned 8-bit samples. |
AUDIO_S8 |
signed 8-bit samples. |
AUDIO_U16 or AUDIO_U16LSB |
not supported by all hardware (unsigned 16-bit little-endian) |
AUDIO_S16 or AUDIO_S16LSB |
not supported by all hardware (signed 16-bit little-endian) |
AUDIO_U16MSB |
not supported by all hardware (unsigned 16-bit big-endian) |
AUDIO_S16MSB |
not supported by all hardware (signed 16-bit big-endian) |
AUDIO_U16SYS |
either AUDIO_U16LSB or AUDIO_U16MSB depending on hardware CPU endianness |
AUDIO_S16SYS |
either AUDIO_S16LSB or AUDIO_S16MSB depending on hardware CPU endianness |
channels specifies the number of separate sound channels. 1 is mono (single channel), 2 is stereo (dual channel). green
samples specifies a unit of audio data. When used with SDL_OpenAudio() this refers to the size of the audio buffer in samples. A sample is a chunk of audio data of the size specified in format multiplied by the number of channels. When the SDL_AudioSpec is used with SDL_LoadWAV() samples is set to 4096. green
*
The calculated values silence and size are calculated by SDL_OpenAudio().
Stereo samples are stored in a LRLRLR ordering.
green
callback is of the form:
##alt 1st line from header rev 5387?
typedef void (SDLCALL * SDL_AudioCallback)(void* userdata,
##w/ wiki formatting adjustments?
void* SDL_AudioCallback(void* userdata,
##original content below
void callback(void* userdata,
Uint8* stream,
int len);
with the following parameters:
userdata
an application-specific parameter saved in the SDL_AudioSpec structure
stream
a pointer to the audio data buffer to be filled in by the callback
len
the length of that buffer in bytes
Once the callback returns, the buffer will no longer be valid.
