Merge branch 'master' of git.shadowcat.co.uk:SDL-Site
[sdlgit/SDL-Site.git] / pages / SDL-AudioSpec.html-inc
CommitLineData
b82df135 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
8758037a 6<li><a href="#CATEGORY">CATEGORY</a></li>
7<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8<li><a href="#DESCIPTION">DESCIPTION</a></li>
9<li><a href="#METHODS">METHODS</a>
10<ul><li><a href="#freq">freq</a></li>
11<li><a href="#format">format</a></li>
12<li><a href="#channels">channels</a></li>
09d3d3ce 13<li><a href="#samples">samples</a></li>
c7e8d3c6 14<li><a href="#callback">callback</a></li>
8758037a 15</ul>
b82df135 16</li>
c7e8d3c6 17<li><a href="#AUTHORS">AUTHORS</a>
18</li>
b82df135 19</ul><hr />
20<!-- INDEX END -->
21
22<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
23<div id="NAME_CONTENT">
8758037a 24<p>SDL::AudioSpec -- SDL Bindings for structure SDL::AudioSpec</p>
b82df135 25
26</div>
27<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
28<div id="CATEGORY_CONTENT">
8758037a 29<p>Core, Audio, Structure</p>
30
31</div>
32<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
33<div id="SYNOPSIS_CONTENT">
34<pre> use SDL;
35 use SDL::AudioSpec;
36
37 SDL::init(SDL_INIT_AUDIO);
38
39 my $audio_spec = SDL::AudioSpec-&gt;new();
40
09d3d3ce 41 $audio_spec-&gt;freq(22050); # 22050Hz - FM Radio quality
42 $audio_spec-&gt;format(AUDIO_S16SYS); # 16-bit signed audio
43 $audio_spec-&gt;samples(8192); # Large audio buffer reduces risk of dropouts but increases response time
44 $audio_spec-&gt;channels(1); # Mono
45 $audio_spec-&gt;callback('main::callback');
46
47 sub callback
48 {
49 # do something here
50 }
8758037a 51
52</pre>
53
54</div>
55<h1 id="DESCIPTION">DESCIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
56<div id="DESCIPTION_CONTENT">
57<p>The <code>SDL::AudioSpec</code> structure is used to describe the format of some audio data. This structure is used by <code>SDL::Audio::open_audio</code>
58and <code>SDL::Audio::load_wav</code>.
59While all fields are used by <code>SDL::Audio::open_audio</code>, only <code>freq</code>, <code>format</code>, <code>samples</code> and <code>channels</code> are used by <code>SDL::Audio::load_wav</code>.
60We will detail these common members here.</p>
61
62</div>
63<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
64<div id="METHODS_CONTENT">
65
66</div>
67<h2 id="freq">freq</h2>
68<div id="freq_CONTENT">
69<p>The number of samples sent to the sound device every second. Common values are 11025, 22050 and 44100. The higher the better.</p>
70
71</div>
72<h2 id="format">format</h2>
73<div id="format_CONTENT">
74<p>Specifies the size and type of each sample element. Values it can take are:</p>
75<dl>
76 <dt>AUDIO_U8</dt>
77 <dd>
78 <p>Unsigned 8-bit samples.</p>
79 </dd>
80 <dt>AUDIO_S8</dt>
81 <dd>
82 <p>Signed 8-bit samples.</p>
83 </dd>
84 <dt>AUDIO_U16 or AUDIO_U16LSB</dt>
85 <dd>
86 <p>not supported by all hardware (unsigned 16-bit little-endian)</p>
87 </dd>
88 <dt>AUDIO_S16 or AUDIO_S16LSB</dt>
89 <dd>
90 <p>not supported by all hardware (signed 16-bit little-endian)</p>
91 </dd>
92 <dt>AUDIO_U16MSB</dt>
93 <dd>
94 <p>not supported by all hardware (unsigned 16-bit big-endian)</p>
95 </dd>
96 <dt>AUDIO_S16MSB</dt>
97 <dd>
98 <p>not supported by all hardware (signed 16-bit big-endian)</p>
99 </dd>
100 <dt>AUDIO_U16SYS</dt>
101 <dd>
102 <p>Either AUDIO_U16LSB or AUDIO_U16MSB depending on hardware CPU endianness</p>
103 </dd>
104 <dt>AUDIO_S16SYS</dt>
105 <dd>
106 <p>Either AUDIO_S16LSB or AUDIO_S16MSB depending on hardware CPU endianness</p>
107 </dd>
108</dl>
109
110</div>
111<h2 id="channels">channels</h2>
112<div id="channels_CONTENT">
113<p>The number of separate sound channels. 1 is mono (single channel), 2 is stereo (dual channel).</p>
114
115</div>
116<h2 id="samples">samples</h2>
117<div id="samples_CONTENT">
118<p>When used with <code>SDL::Audio::open_audio</code> this refers to the size of the audio buffer in samples. A sample is a chunk of audio data of the
119size specified in format multiplied by the number of channels. When the <code>SDL::AudioSpec</code> is used with <code>SDL::Audio::load_wav</code> samples is
120set to 4096.</p>
b82df135 121
122</div>
09d3d3ce 123<h2 id="callback">callback</h2>
124<div id="callback_CONTENT">
125<p>To be documented.</p>
126
127</div>
c7e8d3c6 128<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
129<div id="AUTHORS_CONTENT">
1dbe1697 130<p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
c7e8d3c6 131
132
133
134
135
136</div>
b82df135 137</div>