Merge branch 'master' of git.shadowcat.co.uk:SDL-Site
[sdlgit/SDL-Site.git] / pages / SDLx-Sound.html-inc
CommitLineData
285d0cd2 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
3afd3fb0 6<li><a href="#CATEGORY">CATEGORY</a></li>
285d0cd2 7<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9<li><a href="#METHODS">METHODS</a>
10<ul><li><a href="#new">new</a></li>
11<li><a href="#load">load</a></li>
12<li><a href="#play">play</a></li>
3afd3fb0 13<li><a href="#pause">pause</a></li>
14<li><a href="#resume">resume</a></li>
285d0cd2 15<li><a href="#stop">stop</a></li>
16</ul>
17</li>
3afd3fb0 18<li><a href="#AUTHORS">AUTHORS</a></li>
19<li><a href="#COPYRIGHT_amp_LICENSE">COPYRIGHT &amp; LICENSE</a>
285d0cd2 20</li>
21</ul><hr />
22<!-- INDEX END -->
23
24<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
25<div id="NAME_CONTENT">
26<p>SDLx::Sound</p>
27
28</div>
3afd3fb0 29<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
30<div id="CATEGORY_CONTENT">
31<p>Extension</p>
285d0cd2 32
33</div>
34<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
35<div id="SYNOPSIS_CONTENT">
36<pre> use SDLx::Sound;
37
38 my $snd = SDLx::Sound-&gt;new();
39
40 # loads and plays a single sound now
41 $snd-&gt;play('myfile.wav');
42
43 # load a single file
44 $snd-&gt;load('theSound.aif');
45
46 # plays it or all loaded files
47 $snd-&gt;play();
48
49 # more sounds
50 my %files = (
51 chanell_01 =&gt; &quot;/my_sound1.wav&quot;,
52 chanell_02 =&gt; &quot;/my_sound2.ogg&quot;
53 );
54
55 # times sounds bangs
56 my %times = (
57 chanell_01 =&gt; 0, # start
58 chanell_01 =&gt; 1256, # miliseconds
59 chanell_02 =&gt; 2345
60 );
61
62 # Load files in channels for realtime play
63 $snd-&gt;load(%files);
64
65 # sets sound channel_01 loudness
66 $snd-&gt;loud('channel_01', 80); # loud at 80%
67 $snd-&gt;play(%times); # play loaded files at times
68 $snd-&gt;play; # play again
69
70 # plays sound channel_01 at 578 miliseconds from now
71 $snd-&gt;play('channel_01', 578);
72
73 # fades sound
74 $snd-&gt;fade('channel_02', 2345, 3456, -20);
75
76 # in a single act do the wole Sound
77 my $snd = SDLx::Sound-&gt;new(
78 files =&gt; (
79 chanell_01 =&gt; &quot;/my_sound1.wav&quot;,
80 chanell_02 =&gt; &quot;/my_sound2.ogg&quot;
81
82 ),
83 loud =&gt; (
84 channel_01 =&gt; 80,
85 channel_02 =&gt; 75
86 ),
87 times =&gt; (
88 chanell_01 =&gt; 0, # start
89 chanell_01 =&gt; 1256, # miliseconds
90 chanell_02 =&gt; 2345
91 ),
92 fade =&gt; (
93 chanell_02 =&gt; [2345, 3456, -20]
94 )
95 )-&gt;play();
96
97</pre>
98
99</div>
100<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
101<div id="DESCRIPTION_CONTENT">
102
103
104
105
106<p>You can think about the SDLx::Sound at 2 aproaches. </p>
107<dl>
108 <dt>* A simple sound or </dt>
109 <dt>* The sound of your game or app. </dt>
110</dl>
111<p>Your application will say what the best aproach.</p>
112<p>In a taste that resembles to perl and to SDL, our SDLx:Sound hooks at SDL::Audio and SDL::Mixer with a gracefull and simple interface that can offer to monks a modern perlish way to manage sounds.</p>
113<p>An SDLx::Sound object can load sounds from filesystem, play it, adjust this loudness level or stops the sound. </p>
114<p>Each sound will play in the next available channel, so it can be handled isolately.</p>
115
116</div>
117<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
118<div id="METHODS_CONTENT">
119
120</div>
121<h2 id="new">new</h2>
122<div id="new_CONTENT">
123<p>Returns a new instance of SDLx::Sound</p>
124
125</div>
126<h2 id="load">load</h2>
127<div id="load_CONTENT">
128
285d0cd2 129
285d0cd2 130
285d0cd2 131
285d0cd2 132
133</div>
3afd3fb0 134<h2 id="play">play</h2>
135<div id="play_CONTENT">
136<pre> $sdlx_sound-&gt;play('file.wav');
285d0cd2 137
3afd3fb0 138</pre>
139<p>Play a file</p>
285d0cd2 140
141</div>
3afd3fb0 142<h2 id="pause">pause</h2>
143<div id="pause_CONTENT">
285d0cd2 144
3afd3fb0 145</div>
146<h2 id="resume">resume</h2>
147<div id="resume_CONTENT">
285d0cd2 148
3afd3fb0 149</div>
150<h2 id="stop">stop</h2>
151<div id="stop_CONTENT">
285d0cd2 152
153
154
155
156
157</div>
3afd3fb0 158<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
159<div id="AUTHORS_CONTENT">
1dbe1697 160<p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
285d0cd2 161
162</div>
3afd3fb0 163<h1 id="COPYRIGHT_amp_LICENSE">COPYRIGHT &amp; LICENSE</h1><p><a href="#TOP" class="toplink">Top</a></p>
164<div id="COPYRIGHT_amp_LICENSE_CONTENT">
285d0cd2 165<p>This program is free software; you can redistribute it and/or modify it
3afd3fb0 166under the same terms as Perl itself.</p>
285d0cd2 167
168
169
170
171
172</div>
173</div>