3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
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>
13 <li><a href="#samples">samples</a>
20 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
21 <div id="NAME_CONTENT">
22 <p>SDL::AudioSpec -- SDL Bindings for structure SDL::AudioSpec</p>
25 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
26 <div id="CATEGORY_CONTENT">
27 <p>Core, Audio, Structure</p>
30 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
31 <div id="SYNOPSIS_CONTENT">
35 SDL::init(SDL_INIT_AUDIO);
37 my $audio_spec = SDL::AudioSpec->new();
39 $audio_spec->freq(22050); # 22050Hz - FM Radio quality
40 $audio_spec->format(AUDIO_S16SYS); # 16-bit signed audio
41 $audio_spec->samples(8192); # Large audio buffer reduces risk of dropouts but increases response time
42 $audio_spec->channels(1); # Mono
47 <h1 id="DESCIPTION">DESCIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
48 <div id="DESCIPTION_CONTENT">
49 <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>
50 and <code>SDL::Audio::load_wav</code>.
51 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>.
52 We will detail these common members here.</p>
55 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
56 <div id="METHODS_CONTENT">
59 <h2 id="freq">freq</h2>
60 <div id="freq_CONTENT">
61 <p>The number of samples sent to the sound device every second. Common values are 11025, 22050 and 44100. The higher the better.</p>
64 <h2 id="format">format</h2>
65 <div id="format_CONTENT">
66 <p>Specifies the size and type of each sample element. Values it can take are:</p>
70 <p>Unsigned 8-bit samples.</p>
74 <p>Signed 8-bit samples.</p>
76 <dt>AUDIO_U16 or AUDIO_U16LSB</dt>
78 <p>not supported by all hardware (unsigned 16-bit little-endian)</p>
80 <dt>AUDIO_S16 or AUDIO_S16LSB</dt>
82 <p>not supported by all hardware (signed 16-bit little-endian)</p>
86 <p>not supported by all hardware (unsigned 16-bit big-endian)</p>
90 <p>not supported by all hardware (signed 16-bit big-endian)</p>
94 <p>Either AUDIO_U16LSB or AUDIO_U16MSB depending on hardware CPU endianness</p>
98 <p>Either AUDIO_S16LSB or AUDIO_S16MSB depending on hardware CPU endianness</p>
103 <h2 id="channels">channels</h2>
104 <div id="channels_CONTENT">
105 <p>The number of separate sound channels. 1 is mono (single channel), 2 is stereo (dual channel).</p>
108 <h2 id="samples">samples</h2>
109 <div id="samples_CONTENT">
110 <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
111 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