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