updated docs
[sdlgit/SDL-Site.git] / pages / SDL-Mixer-Samples.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#METHODS">METHODS</a>
8 <ul><li><a href="#get_num_chunk_decoders">get_num_chunk_decoders</a></li>
9 <li><a href="#get_chunk_decoder">get_chunk_decoder</a></li>
10 <li><a href="#load_WAV">load_WAV</a></li>
11 <li><a href="#load_WAV_RW">load_WAV_RW</a></li>
12 <li><a href="#quick_load_WAV">quick_load_WAV</a></li>
13 <li><a href="#quick_load_RAW">quick_load_RAW</a></li>
14 <li><a href="#volume_chunk">volume_chunk</a></li>
15 </ul>
16 </li>
17 <li><a href="#AUTHORS">AUTHORS</a>
18 </li>
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">
24 <p>SDL::Mixer::Samples - functions for loading sound samples</p>
25
26 </div>
27 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
28 <div id="CATEGORY_CONTENT">
29 <p>Mixer</p>
30
31 </div>
32 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
33 <div id="METHODS_CONTENT">
34
35 </div>
36 <h2 id="get_num_chunk_decoders">get_num_chunk_decoders</h2>
37 <div id="get_num_chunk_decoders_CONTENT">
38 <pre> my $num_decoders = SDL::Mixer::Samples::get_num_chunk_decoders();
39
40 </pre>
41 <p>Returns the number of available decoders.</p>
42
43 </div>
44 <h2 id="get_chunk_decoder">get_chunk_decoder</h2>
45 <div id="get_chunk_decoder_CONTENT">
46 <pre> my $decoder = SDL::Mixer::Samples::get_chunk_decoder( $num_decoder );
47
48 </pre>
49 <p>Returns the decoder for the given id.</p>
50
51 </div>
52 <h2 id="load_WAV">load_WAV</h2>
53 <div id="load_WAV_CONTENT">
54 <pre> my $mix_chunk = SDL::Mixer::Samples::load_WAV( $file );
55
56 </pre>
57 <p><code>load_WAV</code> reads a file and passes it to <a href="/SDL-Mixer-Samples.html#load_WAV_RW">SDL::Mixer::Samples::load_WAV_RW</a>. SO this is a quick way to load a file into a chunk.</p>
58 <p>Example:</p>
59 <pre> my $chunk = SDL::Mixer::Samples::load_WAV('sample.wav');
60
61  SDL::Mixer::Channels::play_channel(-1, $chunk, -1);
62  SDL::delay(2000);
63
64 </pre>
65
66 </div>
67 <h2 id="load_WAV_RW">load_WAV_RW</h2>
68 <div id="load_WAV_RW_CONTENT">
69 <pre> my $mix_chunk = SDL::Mixer::Samples::load_WAV_RW( $rwops, $free );
70
71 </pre>
72 <p><code>load_WAV_RW</code> is a macro that loads a sound sample from a a block of memory. It supports WAVE-, MOD-, MIDI-, OGG- and MP3 files (sometimes 
73 depends on compilation options). It accepts two arguments, the first being a RWops object from which to read and the second being a flag to 
74 free the source memory after loading is complete or not.</p>
75 <p>Returns a Mix_Chunk containing the whole sample on success, or <code>undef</code> on error.</p>
76 <p><strong>Note</strong>: Do not reuse the RWops-object for another call to this function!</p>
77 <p>Example:</p>
78 <pre> my $rwops = SDL::RWOps-&gt;new_file('sample.wav', 'r');
79
80  my $chunk = SDL::Mixer::Samples::load_WAV_RW($rwops, 0);
81
82  SDL::Mixer::Channels::play_channel(-1, $chunk, -1);
83  SDL::delay(2000);
84
85 </pre>
86
87 </div>
88 <h2 id="quick_load_WAV">quick_load_WAV</h2>
89 <div id="quick_load_WAV_CONTENT">
90 <pre> SDL::Mixer::Samples::quick_load_WAV( $buf );
91
92 </pre>
93 <p>to be documented.</p>
94
95 </div>
96 <h2 id="quick_load_RAW">quick_load_RAW</h2>
97 <div id="quick_load_RAW_CONTENT">
98 <pre> SDL::Mixer::Samples::quick_load_RAW( $buf, $len );
99
100 </pre>
101 <p>to be documented.</p>
102
103 </div>
104 <h2 id="volume_chunk">volume_chunk</h2>
105 <div id="volume_chunk_CONTENT">
106 <pre> my $volume_before = SDL::Mixer::Samples::volume_chunk( $chunk, $new_volume );
107
108 </pre>
109 <p><code>volume_chunk</code> let you set and get the volume of a chunk. When a chunk is created is volume is <code>MIX_MAX_VOLUME</code> (<code>128</code>).</p>
110 <p>If you pass <code>-1</code> as <code>$new_volume</code> you just get its volume without changing it.</p>
111
112 </div>
113 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
114 <div id="AUTHORS_CONTENT">
115 <p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p>
116
117 </div>
118 </div>