1<HTML 2><HEAD 3><TITLE 4>SDL_AudioSpec</TITLE 5><META 6NAME="GENERATOR" 7CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ 8"><LINK 9REL="HOME" 10TITLE="SDL Library Documentation" 11HREF="index.html"><LINK 12REL="UP" 13TITLE="Audio" 14HREF="audio.html"><LINK 15REL="PREVIOUS" 16TITLE="Audio" 17HREF="audio.html"><LINK 18REL="NEXT" 19TITLE="SDL_OpenAudio" 20HREF="sdlopenaudio.html"></HEAD 21><BODY 22CLASS="REFENTRY" 23BGCOLOR="#FFF8DC" 24TEXT="#000000" 25LINK="#0000ee" 26VLINK="#551a8b" 27ALINK="#ff0000" 28><DIV 29CLASS="NAVHEADER" 30><TABLE 31SUMMARY="Header navigation table" 32WIDTH="100%" 33BORDER="0" 34CELLPADDING="0" 35CELLSPACING="0" 36><TR 37><TH 38COLSPAN="3" 39ALIGN="center" 40>SDL Library Documentation</TH 41></TR 42><TR 43><TD 44WIDTH="10%" 45ALIGN="left" 46VALIGN="bottom" 47><A 48HREF="audio.html" 49ACCESSKEY="P" 50>Prev</A 51></TD 52><TD 53WIDTH="80%" 54ALIGN="center" 55VALIGN="bottom" 56></TD 57><TD 58WIDTH="10%" 59ALIGN="right" 60VALIGN="bottom" 61><A 62HREF="sdlopenaudio.html" 63ACCESSKEY="N" 64>Next</A 65></TD 66></TR 67></TABLE 68><HR 69ALIGN="LEFT" 70WIDTH="100%"></DIV 71><H1 72><A 73NAME="SDLAUDIOSPEC" 74></A 75>SDL_AudioSpec</H1 76><DIV 77CLASS="REFNAMEDIV" 78><A 79NAME="AEN6507" 80></A 81><H2 82>Name</H2 83>SDL_AudioSpec -- Audio Specification Structure</DIV 84><DIV 85CLASS="REFSECT1" 86><A 87NAME="AEN6510" 88></A 89><H2 90>Structure Definition</H2 91><PRE 92CLASS="PROGRAMLISTING" 93>typedef struct{ 94 int freq; 95 Uint16 format; 96 Uint8 channels; 97 Uint8 silence; 98 Uint16 samples; 99 Uint32 size; 100 void (*callback)(void *userdata, Uint8 *stream, int len); 101 void *userdata; 102} SDL_AudioSpec;</PRE 103></DIV 104><DIV 105CLASS="REFSECT1" 106><A 107NAME="AEN6513" 108></A 109><H2 110>Structure Data</H2 111><DIV 112CLASS="INFORMALTABLE" 113><A 114NAME="AEN6515" 115></A 116><P 117></P 118><TABLE 119BORDER="0" 120CLASS="CALSTABLE" 121><TBODY 122><TR 123><TD 124ALIGN="LEFT" 125VALIGN="TOP" 126><TT 127CLASS="STRUCTFIELD" 128><I 129>freq</I 130></TT 131></TD 132><TD 133ALIGN="LEFT" 134VALIGN="TOP" 135>Audio frequency in samples per second</TD 136></TR 137><TR 138><TD 139ALIGN="LEFT" 140VALIGN="TOP" 141><TT 142CLASS="STRUCTFIELD" 143><I 144>format</I 145></TT 146></TD 147><TD 148ALIGN="LEFT" 149VALIGN="TOP" 150>Audio data format</TD 151></TR 152><TR 153><TD 154ALIGN="LEFT" 155VALIGN="TOP" 156><TT 157CLASS="STRUCTFIELD" 158><I 159>channels</I 160></TT 161></TD 162><TD 163ALIGN="LEFT" 164VALIGN="TOP" 165>Number of channels: 1 mono, 2 stereo</TD 166></TR 167><TR 168><TD 169ALIGN="LEFT" 170VALIGN="TOP" 171><TT 172CLASS="STRUCTFIELD" 173><I 174>silence</I 175></TT 176></TD 177><TD 178ALIGN="LEFT" 179VALIGN="TOP" 180>Audio buffer silence value (calculated)</TD 181></TR 182><TR 183><TD 184ALIGN="LEFT" 185VALIGN="TOP" 186><TT 187CLASS="STRUCTFIELD" 188><I 189>samples</I 190></TT 191></TD 192><TD 193ALIGN="LEFT" 194VALIGN="TOP" 195>Audio buffer size in samples</TD 196></TR 197><TR 198><TD 199ALIGN="LEFT" 200VALIGN="TOP" 201><TT 202CLASS="STRUCTFIELD" 203><I 204>size</I 205></TT 206></TD 207><TD 208ALIGN="LEFT" 209VALIGN="TOP" 210>Audio buffer size in bytes (calculated)</TD 211></TR 212><TR 213><TD 214ALIGN="LEFT" 215VALIGN="TOP" 216><TT 217CLASS="STRUCTFIELD" 218><I 219>callback(..)</I 220></TT 221></TD 222><TD 223ALIGN="LEFT" 224VALIGN="TOP" 225>Callback function for filling the audio buffer</TD 226></TR 227><TR 228><TD 229ALIGN="LEFT" 230VALIGN="TOP" 231><TT 232CLASS="STRUCTFIELD" 233><I 234>userdata</I 235></TT 236></TD 237><TD 238ALIGN="LEFT" 239VALIGN="TOP" 240>Pointer the user data which is passed to the callback function</TD 241></TR 242></TBODY 243></TABLE 244><P 245></P 246></DIV 247></DIV 248><DIV 249CLASS="REFSECT1" 250><A 251NAME="AEN6550" 252></A 253><H2 254>Description</H2 255><P 256>The <SPAN 257CLASS="STRUCTNAME" 258>SDL_AudioSpec</SPAN 259> structure is used to describe the format of some audio data. This structure is used by <A 260HREF="sdlopenaudio.html" 261><TT 262CLASS="FUNCTION" 263>SDL_OpenAudio</TT 264></A 265> and <A 266HREF="sdlloadwav.html" 267><TT 268CLASS="FUNCTION" 269>SDL_LoadWAV</TT 270></A 271>. While all fields are used by <TT 272CLASS="FUNCTION" 273>SDL_OpenAudio</TT 274> only <TT 275CLASS="STRUCTFIELD" 276><I 277>freq</I 278></TT 279>, <TT 280CLASS="STRUCTFIELD" 281><I 282>format</I 283></TT 284>, <TT 285CLASS="STRUCTFIELD" 286><I 287>samples</I 288></TT 289> and <TT 290CLASS="STRUCTFIELD" 291><I 292>channels</I 293></TT 294> are used by <TT 295CLASS="FUNCTION" 296>SDL_LoadWAV</TT 297>. We will detail these common members here.</P 298><DIV 299CLASS="INFORMALTABLE" 300><A 301NAME="AEN6564" 302></A 303><P 304></P 305><TABLE 306BORDER="0" 307CLASS="CALSTABLE" 308><TBODY 309><TR 310><TD 311ALIGN="LEFT" 312VALIGN="TOP" 313><TT 314CLASS="STRUCTFIELD" 315><I 316>freq</I 317></TT 318></TD 319><TD 320ALIGN="LEFT" 321VALIGN="TOP" 322><P 323>The number of samples sent to the sound device every second. Common values are 11025, 22050 and 44100. The higher the better.</P 324></TD 325></TR 326><TR 327><TD 328ALIGN="LEFT" 329VALIGN="TOP" 330><TT 331CLASS="STRUCTFIELD" 332><I 333>format</I 334></TT 335></TD 336><TD 337ALIGN="LEFT" 338VALIGN="TOP" 339><P 340>Specifies the size and type of each sample element 341<P 342></P 343><DIV 344CLASS="VARIABLELIST" 345><DL 346><DT 347><TT 348CLASS="LITERAL" 349>AUDIO_U8</TT 350></DT 351><DD 352><P 353>Unsigned 8-bit samples</P 354></DD 355><DT 356><TT 357CLASS="LITERAL" 358>AUDIO_S8</TT 359></DT 360><DD 361><P 362>Signed 8-bit samples</P 363></DD 364><DT 365><TT 366CLASS="LITERAL" 367>AUDIO_U16</TT 368> or <TT 369CLASS="LITERAL" 370>AUDIO_U16LSB</TT 371></DT 372><DD 373><P 374>Unsigned 16-bit little-endian samples</P 375></DD 376><DT 377><TT 378CLASS="LITERAL" 379>AUDIO_S16</TT 380> or <TT 381CLASS="LITERAL" 382>AUDIO_S16LSB</TT 383></DT 384><DD 385><P 386>Signed 16-bit little-endian samples</P 387></DD 388><DT 389><TT 390CLASS="LITERAL" 391>AUDIO_U16MSB</TT 392></DT 393><DD 394><P 395>Unsigned 16-bit big-endian samples</P 396></DD 397><DT 398><TT 399CLASS="LITERAL" 400>AUDIO_S16MSB</TT 401></DT 402><DD 403><P 404>Signed 16-bit big-endian samples</P 405></DD 406><DT 407><TT 408CLASS="LITERAL" 409>AUDIO_U16SYS</TT 410></DT 411><DD 412><P 413>Either <TT 414CLASS="LITERAL" 415>AUDIO_U16LSB</TT 416> or <TT 417CLASS="LITERAL" 418>AUDIO_U16MSB</TT 419> depending on you systems endianness</P 420></DD 421><DT 422><TT 423CLASS="LITERAL" 424>AUDIO_S16SYS</TT 425></DT 426><DD 427><P 428>Either <TT 429CLASS="LITERAL" 430>AUDIO_S16LSB</TT 431> or <TT 432CLASS="LITERAL" 433>AUDIO_S16MSB</TT 434> depending on you systems endianness</P 435></DD 436></DL 437></DIV 438></P 439></TD 440></TR 441><TR 442><TD 443ALIGN="LEFT" 444VALIGN="TOP" 445><TT 446CLASS="STRUCTFIELD" 447><I 448>channels</I 449></TT 450></TD 451><TD 452ALIGN="LEFT" 453VALIGN="TOP" 454>The number of seperate sound channels. 1 is mono (single channel), 2 is stereo (dual channel).</TD 455></TR 456><TR 457><TD 458ALIGN="LEFT" 459VALIGN="TOP" 460><TT 461CLASS="STRUCTFIELD" 462><I 463>samples</I 464></TT 465></TD 466><TD 467ALIGN="LEFT" 468VALIGN="TOP" 469>When used with <A 470HREF="sdlopenaudio.html" 471><TT 472CLASS="FUNCTION" 473>SDL_OpenAudio</TT 474></A 475> this refers to the size of the audio buffer in samples. A sample a chunk of audio data of the size specified in <TT 476CLASS="PARAMETER" 477><I 478>format</I 479></TT 480> mulitplied by the number of channels. When the <SPAN 481CLASS="STRUCTNAME" 482>SDL_AudioSpec</SPAN 483> is used with <A 484HREF="sdlloadwav.html" 485><TT 486CLASS="FUNCTION" 487>SDL_LoadWAV</TT 488></A 489> <TT 490CLASS="STRUCTFIELD" 491><I 492>samples</I 493></TT 494> is set to 4096.</TD 495></TR 496></TBODY 497></TABLE 498><P 499></P 500></DIV 501></DIV 502><DIV 503CLASS="REFSECT1" 504><A 505NAME="AEN6639" 506></A 507><H2 508>See Also</H2 509><P 510><A 511HREF="sdlopenaudio.html" 512><TT 513CLASS="FUNCTION" 514>SDL_OpenAudio</TT 515></A 516>, 517<A 518HREF="sdlloadwav.html" 519><TT 520CLASS="FUNCTION" 521>SDL_LoadWAV</TT 522></A 523></P 524></DIV 525><DIV 526CLASS="NAVFOOTER" 527><HR 528ALIGN="LEFT" 529WIDTH="100%"><TABLE 530SUMMARY="Footer navigation table" 531WIDTH="100%" 532BORDER="0" 533CELLPADDING="0" 534CELLSPACING="0" 535><TR 536><TD 537WIDTH="33%" 538ALIGN="left" 539VALIGN="top" 540><A 541HREF="audio.html" 542ACCESSKEY="P" 543>Prev</A 544></TD 545><TD 546WIDTH="34%" 547ALIGN="center" 548VALIGN="top" 549><A 550HREF="index.html" 551ACCESSKEY="H" 552>Home</A 553></TD 554><TD 555WIDTH="33%" 556ALIGN="right" 557VALIGN="top" 558><A 559HREF="sdlopenaudio.html" 560ACCESSKEY="N" 561>Next</A 562></TD 563></TR 564><TR 565><TD 566WIDTH="33%" 567ALIGN="left" 568VALIGN="top" 569>Audio</TD 570><TD 571WIDTH="34%" 572ALIGN="center" 573VALIGN="top" 574><A 575HREF="audio.html" 576ACCESSKEY="U" 577>Up</A 578></TD 579><TD 580WIDTH="33%" 581ALIGN="right" 582VALIGN="top" 583>SDL_OpenAudio</TD 584></TR 585></TABLE 586></DIV 587></BODY 588></HTML 589>