Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > ed1483a4d9709d82850bb84cf25535e7 > files > 135

sfml-1.5-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="tabs.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="logo">
            <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" />
        </div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.htm"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.htm"><span>Namespaces</span></a></li>
      <li><a href="annotated.htm"><span>Classes</span></a></li>
      <li class="current"><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.htm"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>Sound.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// SFML - Simple and Fast Multimedia Library</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span>
<a name="l00007"></a>00007 <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00010"></a>00010 <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span>
<a name="l00011"></a>00011 <span class="comment">// subject to the following restrictions:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// 1. The origin of this software must not be misrepresented;</span>
<a name="l00014"></a>00014 <span class="comment">//    you must not claim that you wrote the original software.</span>
<a name="l00015"></a>00015 <span class="comment">//    If you use this software in a product, an acknowledgment</span>
<a name="l00016"></a>00016 <span class="comment">//    in the product documentation would be appreciated but is not required.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// 2. Altered source versions must be plainly marked as such,</span>
<a name="l00019"></a>00019 <span class="comment">//    and must not be misrepresented as being the original software.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00022"></a>00022 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">// Headers</span>
<a name="l00028"></a>00028 <span class="comment"></span><span class="preprocessor">#include &lt;SFML/Audio/Sound.hpp&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;SFML/Audio/SoundBuffer.hpp&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;SFML/Audio/OpenAL.hpp&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>sf
<a name="l00034"></a>00034 {
<a name="l00038"></a><a class="code" href="classsf_1_1Sound.htm#36ab74beaaa953d9879c933ddd246282">00038</a> <a class="code" href="classsf_1_1Sound.htm#36ab74beaaa953d9879c933ddd246282" title="Default constructor.">Sound::Sound</a>()
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040     ALCheck(alGenSources(1, &amp;mySource));
<a name="l00041"></a>00041     ALCheck(alSourcei(mySource, AL_BUFFER, 0));
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 
<a name="l00048"></a><a class="code" href="classsf_1_1Sound.htm#45aff03dc5bf87647eba6bed7c1ced29">00048</a> <a class="code" href="classsf_1_1Sound.htm#36ab74beaaa953d9879c933ddd246282" title="Default constructor.">Sound::Sound</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1SoundBuffer.htm" title="SoundBuffer is the low-level for loading and manipulating sound buffers.">SoundBuffer</a>&amp; Buffer, <span class="keywordtype">bool</span> Loop, <span class="keywordtype">float</span> Pitch, <span class="keywordtype">float</span> Volume, <span class="keyword">const</span> <a class="code" href="classsf_1_1Vector3.htm" title="Vector3 is an utility class for manipulating 3 dimensional vectors.">Vector3f</a>&amp; Position) :
<a name="l00049"></a>00049 myBuffer(&amp;Buffer)
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051     ALCheck(alGenSources(1, &amp;mySource));
<a name="l00052"></a>00052 
<a name="l00053"></a>00053     ALCheck(alSourcei (mySource, AL_BUFFER,   Buffer.<a class="code" href="classsf_1_1SoundBuffer.htm#b9d31c90ee4febbd075b9c64c3072a65" title="OpenAL buffer identifier.">myBuffer</a>));
<a name="l00054"></a>00054     ALCheck(alSourcei (mySource, AL_LOOPING,  Loop));
<a name="l00055"></a>00055     ALCheck(alSourcef (mySource, AL_PITCH,    Pitch));
<a name="l00056"></a>00056     ALCheck(alSourcef (mySource, AL_GAIN,     Volume * 0.01f));
<a name="l00057"></a>00057     ALCheck(alSource3f(mySource, AL_POSITION, Position.<a class="code" href="classsf_1_1Vector3.htm#3cb0c769390bc37c346bb1a69e510d16" title="X coordinate of the vector.">x</a>, Position.<a class="code" href="classsf_1_1Vector3.htm#6590d50ccb862c5efc5512e974e9b794" title="Y coordinate of the vector.">y</a>, Position.<a class="code" href="classsf_1_1Vector3.htm#2f36ab4b552c028e3a9734c1ad4df7d1" title="Z coordinate of the vector.">z</a>));
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 
<a name="l00064"></a><a class="code" href="classsf_1_1Sound.htm#a930dcf53775f501ce43d44bf54c0ce4">00064</a> <a class="code" href="classsf_1_1Sound.htm#36ab74beaaa953d9879c933ddd246282" title="Default constructor.">Sound::Sound</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Sound.htm" title="Sound defines the properties of a sound such as position, volume, pitch, etc.">Sound</a>&amp; Copy) :
<a name="l00065"></a>00065 <a class="code" href="classsf_1_1AudioResource.htm" title="Abstract base class for every class that owns a device-dependant resource -- allow...">AudioResource</a>(Copy),
<a name="l00066"></a>00066 myBuffer     (Copy.myBuffer)
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068     ALCheck(alGenSources(1, &amp;mySource));
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     ALCheck(alSourcei (mySource, AL_BUFFER,   myBuffer ? myBuffer-&gt;myBuffer : 0));
<a name="l00071"></a>00071     ALCheck(alSourcei (mySource, AL_LOOPING,  Copy.<a class="code" href="classsf_1_1Sound.htm#5cdc44ade7bda8db2d0431701d72495e" title="Tell whether or not the sound is looping.">GetLoop</a>()));
<a name="l00072"></a>00072     ALCheck(alSourcef (mySource, AL_PITCH,    Copy.<a class="code" href="classsf_1_1Sound.htm#42333202ed0586f434d852cc35b9d4ef" title="Get the pitch.">GetPitch</a>()));
<a name="l00073"></a>00073     ALCheck(alSourcef (mySource, AL_GAIN,     Copy.<a class="code" href="classsf_1_1Sound.htm#018e78cd6c50d653fffff1005a350782" title="Get the volume.">GetVolume</a>() * 0.01f));
<a name="l00074"></a>00074     ALCheck(alSource3f(mySource, AL_POSITION, Copy.<a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643" title="Get the sound position.">GetPosition</a>().<a class="code" href="classsf_1_1Vector3.htm#3cb0c769390bc37c346bb1a69e510d16" title="X coordinate of the vector.">x</a>, Copy.<a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643" title="Get the sound position.">GetPosition</a>().<a class="code" href="classsf_1_1Vector3.htm#6590d50ccb862c5efc5512e974e9b794" title="Y coordinate of the vector.">y</a>, Copy.<a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643" title="Get the sound position.">GetPosition</a>().<a class="code" href="classsf_1_1Vector3.htm#2f36ab4b552c028e3a9734c1ad4df7d1" title="Z coordinate of the vector.">z</a>));
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 
<a name="l00081"></a><a class="code" href="classsf_1_1Sound.htm#d0792c35310eba2dffd8489c80fad076">00081</a> <a class="code" href="classsf_1_1Sound.htm#d0792c35310eba2dffd8489c80fad076" title="Destructor.">Sound::~Sound</a>()
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083     <span class="keywordflow">if</span> (mySource)
<a name="l00084"></a>00084     {
<a name="l00085"></a>00085         <span class="keywordflow">if</span> (myBuffer)
<a name="l00086"></a>00086         {
<a name="l00087"></a>00087             <a class="code" href="classsf_1_1Sound.htm#b1f5f103f737c52ceb0b1a067b4d0630" title="Stop the sound.">Stop</a>();
<a name="l00088"></a>00088             ALCheck(alSourcei(mySource, AL_BUFFER, 0));
<a name="l00089"></a>00089         }
<a name="l00090"></a>00090         ALCheck(alDeleteSources(1, &amp;mySource));
<a name="l00091"></a>00091     }
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 
<a name="l00098"></a><a class="code" href="classsf_1_1Sound.htm#fdafa7970587f04d3833b4095c2de1db">00098</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#fdafa7970587f04d3833b4095c2de1db" title="Play the sound.">Sound::Play</a>()
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100     ALCheck(alSourcePlay(mySource));
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00103"></a>00103 
<a name="l00107"></a><a class="code" href="classsf_1_1Sound.htm#6a712910ac1340f32e3ec3a04295ebd3">00107</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#6a712910ac1340f32e3ec3a04295ebd3" title="Pause the sound.">Sound::Pause</a>()
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109     ALCheck(alSourcePause(mySource));
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 
<a name="l00116"></a><a class="code" href="classsf_1_1Sound.htm#b1f5f103f737c52ceb0b1a067b4d0630">00116</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#b1f5f103f737c52ceb0b1a067b4d0630" title="Stop the sound.">Sound::Stop</a>()
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118     ALCheck(alSourceStop(mySource));
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 
<a name="l00125"></a><a class="code" href="classsf_1_1Sound.htm#9dbc27c54f0ee633c831a0b6e24ecc55">00125</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#9dbc27c54f0ee633c831a0b6e24ecc55" title="Set the source buffer.">Sound::SetBuffer</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1SoundBuffer.htm" title="SoundBuffer is the low-level for loading and manipulating sound buffers.">SoundBuffer</a>&amp; Buffer)
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127     myBuffer = &amp;Buffer;
<a name="l00128"></a>00128     ALCheck(alSourcei(mySource, AL_BUFFER, myBuffer ? myBuffer-&gt;myBuffer : 0));
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
<a name="l00135"></a><a class="code" href="classsf_1_1Sound.htm#4eb9966b7289c69623a39cc0125012f4">00135</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#4eb9966b7289c69623a39cc0125012f4" title="Set the sound loop state.">Sound::SetLoop</a>(<span class="keywordtype">bool</span> Loop)
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137     ALCheck(alSourcei(mySource, AL_LOOPING, Loop));
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 
<a name="l00144"></a><a class="code" href="classsf_1_1Sound.htm#f93301feb88770789ba7cd993c9dd3a0">00144</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#f93301feb88770789ba7cd993c9dd3a0" title="Set the sound pitch.">Sound::SetPitch</a>(<span class="keywordtype">float</span> Pitch)
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146     ALCheck(alSourcef(mySource, AL_PITCH, Pitch));
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149 
<a name="l00153"></a><a class="code" href="classsf_1_1Sound.htm#1536095045923a2332dd9eed6bf8e96a">00153</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#1536095045923a2332dd9eed6bf8e96a" title="Set the sound volume.">Sound::SetVolume</a>(<span class="keywordtype">float</span> Volume)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     ALCheck(alSourcef(mySource, AL_GAIN, Volume * 0.01f));
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 
<a name="l00162"></a><a class="code" href="classsf_1_1Sound.htm#b445e8738218525d8dd067628bc70c78">00162</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#b445e8738218525d8dd067628bc70c78" title="Set the sound position (take 3 values).">Sound::SetPosition</a>(<span class="keywordtype">float</span> X, <span class="keywordtype">float</span> Y, <span class="keywordtype">float</span> Z)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164     ALCheck(alSource3f(mySource, AL_POSITION, X, Y, Z));
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167 
<a name="l00172"></a><a class="code" href="classsf_1_1Sound.htm#0d8c6f11281a574b781c53d62a4af776">00172</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#b445e8738218525d8dd067628bc70c78" title="Set the sound position (take 3 values).">Sound::SetPosition</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Vector3.htm" title="Vector3 is an utility class for manipulating 3 dimensional vectors.">Vector3f</a>&amp; Position)
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174     <a class="code" href="classsf_1_1Sound.htm#b445e8738218525d8dd067628bc70c78" title="Set the sound position (take 3 values).">SetPosition</a>(Position.<a class="code" href="classsf_1_1Vector3.htm#3cb0c769390bc37c346bb1a69e510d16" title="X coordinate of the vector.">x</a>, Position.<a class="code" href="classsf_1_1Vector3.htm#6590d50ccb862c5efc5512e974e9b794" title="Y coordinate of the vector.">y</a>, Position.<a class="code" href="classsf_1_1Vector3.htm#2f36ab4b552c028e3a9734c1ad4df7d1" title="Z coordinate of the vector.">z</a>);
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 
<a name="l00183"></a><a class="code" href="classsf_1_1Sound.htm#7604f576d184ba8031789beee96d04d3">00183</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#7604f576d184ba8031789beee96d04d3" title="Make the sound&amp;#39;s position relative to the listener&amp;#39;s position, or absolute...">Sound::SetRelativeToListener</a>(<span class="keywordtype">bool</span> Relative)
<a name="l00184"></a>00184 {
<a name="l00185"></a>00185     ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, Relative));
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 
<a name="l00194"></a><a class="code" href="classsf_1_1Sound.htm#0a545d8dca68d85a03390f6da7c446a9">00194</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#0a545d8dca68d85a03390f6da7c446a9" title="Set the minimum distance - closer than this distance, the listener will hear the...">Sound::SetMinDistance</a>(<span class="keywordtype">float</span> MinDistance)
<a name="l00195"></a>00195 {
<a name="l00196"></a>00196     ALCheck(alSourcef(mySource, AL_REFERENCE_DISTANCE, MinDistance));
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 
<a name="l00205"></a><a class="code" href="classsf_1_1Sound.htm#c3743f1fb53bf9818fbab6e9220bd7b9">00205</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#c3743f1fb53bf9818fbab6e9220bd7b9" title="Set the attenuation factor - the higher the attenuation, the more the sound will...">Sound::SetAttenuation</a>(<span class="keywordtype">float</span> Attenuation)
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207     ALCheck(alSourcef(mySource, AL_ROLLOFF_FACTOR, Attenuation));
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 
<a name="l00214"></a><a class="code" href="classsf_1_1Sound.htm#e779b4fa3d8d98a1490334dbd32e8d62">00214</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Sound.htm#e779b4fa3d8d98a1490334dbd32e8d62" title="Set the current playing position of the sound.">Sound::SetPlayingOffset</a>(<span class="keywordtype">float</span> TimeOffset)
<a name="l00215"></a>00215 {
<a name="l00216"></a>00216     ALCheck(alSourcef(mySource, AL_SEC_OFFSET, TimeOffset));
<a name="l00217"></a>00217 }
<a name="l00218"></a>00218 
<a name="l00219"></a>00219 
<a name="l00223"></a><a class="code" href="classsf_1_1Sound.htm#bb46557ecfb32c4538fedad28cc59d9e">00223</a> <span class="keyword">const</span> <a class="code" href="classsf_1_1SoundBuffer.htm" title="SoundBuffer is the low-level for loading and manipulating sound buffers.">SoundBuffer</a>* <a class="code" href="classsf_1_1Sound.htm#bb46557ecfb32c4538fedad28cc59d9e" title="Get the source buffer.">Sound::GetBuffer</a>()<span class="keyword"> const</span>
<a name="l00224"></a>00224 <span class="keyword"></span>{
<a name="l00225"></a>00225     <span class="keywordflow">return</span> myBuffer;
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227 
<a name="l00228"></a>00228 
<a name="l00232"></a><a class="code" href="classsf_1_1Sound.htm#5cdc44ade7bda8db2d0431701d72495e">00232</a> <span class="keywordtype">bool</span> <a class="code" href="classsf_1_1Sound.htm#5cdc44ade7bda8db2d0431701d72495e" title="Tell whether or not the sound is looping.">Sound::GetLoop</a>()<span class="keyword"> const</span>
<a name="l00233"></a>00233 <span class="keyword"></span>{
<a name="l00234"></a>00234     ALint Loop;
<a name="l00235"></a>00235     ALCheck(alGetSourcei(mySource, AL_LOOPING, &amp;Loop));
<a name="l00236"></a>00236 
<a name="l00237"></a>00237     <span class="keywordflow">return</span> Loop != 0;
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 
<a name="l00244"></a><a class="code" href="classsf_1_1Sound.htm#42333202ed0586f434d852cc35b9d4ef">00244</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Sound.htm#42333202ed0586f434d852cc35b9d4ef" title="Get the pitch.">Sound::GetPitch</a>()<span class="keyword"> const</span>
<a name="l00245"></a>00245 <span class="keyword"></span>{
<a name="l00246"></a>00246     ALfloat Pitch;
<a name="l00247"></a>00247     ALCheck(alGetSourcef(mySource, AL_PITCH, &amp;Pitch));
<a name="l00248"></a>00248 
<a name="l00249"></a>00249     <span class="keywordflow">return</span> Pitch;
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 
<a name="l00256"></a><a class="code" href="classsf_1_1Sound.htm#018e78cd6c50d653fffff1005a350782">00256</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Sound.htm#018e78cd6c50d653fffff1005a350782" title="Get the volume.">Sound::GetVolume</a>()<span class="keyword"> const</span>
<a name="l00257"></a>00257 <span class="keyword"></span>{
<a name="l00258"></a>00258     ALfloat Gain;
<a name="l00259"></a>00259     ALCheck(alGetSourcef(mySource, AL_GAIN, &amp;Gain));
<a name="l00260"></a>00260 
<a name="l00261"></a>00261     <span class="keywordflow">return</span> Gain * 100.f;
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263 
<a name="l00264"></a>00264 
<a name="l00268"></a><a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643">00268</a> <a class="code" href="classsf_1_1Vector3.htm" title="Vector3 is an utility class for manipulating 3 dimensional vectors.">Vector3f</a> <a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643" title="Get the sound position.">Sound::GetPosition</a>()<span class="keyword"> const</span>
<a name="l00269"></a>00269 <span class="keyword"></span>{
<a name="l00270"></a>00270     <a class="code" href="classsf_1_1Vector3.htm" title="Vector3 is an utility class for manipulating 3 dimensional vectors.">Vector3f</a> Position;
<a name="l00271"></a>00271     ALCheck(alGetSource3f(mySource, AL_POSITION, &amp;Position.<a class="code" href="classsf_1_1Vector3.htm#3cb0c769390bc37c346bb1a69e510d16" title="X coordinate of the vector.">x</a>, &amp;Position.<a class="code" href="classsf_1_1Vector3.htm#6590d50ccb862c5efc5512e974e9b794" title="Y coordinate of the vector.">y</a>, &amp;Position.<a class="code" href="classsf_1_1Vector3.htm#2f36ab4b552c028e3a9734c1ad4df7d1" title="Z coordinate of the vector.">z</a>));
<a name="l00272"></a>00272 
<a name="l00273"></a>00273     <span class="keywordflow">return</span> Position;
<a name="l00274"></a>00274 }
<a name="l00275"></a>00275 
<a name="l00276"></a>00276 
<a name="l00281"></a><a class="code" href="classsf_1_1Sound.htm#f0278152abf6e3f195353ce3c270f34e">00281</a> <span class="keywordtype">bool</span> <a class="code" href="classsf_1_1Sound.htm#f0278152abf6e3f195353ce3c270f34e" title="Tell if the sound&amp;#39;s position is relative to the listener&amp;#39;s position, or if...">Sound::IsRelativeToListener</a>()<span class="keyword"> const</span>
<a name="l00282"></a>00282 <span class="keyword"></span>{
<a name="l00283"></a>00283     ALint Relative;
<a name="l00284"></a>00284     ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &amp;Relative));
<a name="l00285"></a>00285 
<a name="l00286"></a>00286     <span class="keywordflow">return</span> Relative != 0;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 
<a name="l00293"></a><a class="code" href="classsf_1_1Sound.htm#07f37119f7b3b00f274ac0263a4bc58b">00293</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Sound.htm#07f37119f7b3b00f274ac0263a4bc58b" title="Get the minimum distance.">Sound::GetMinDistance</a>()<span class="keyword"> const</span>
<a name="l00294"></a>00294 <span class="keyword"></span>{
<a name="l00295"></a>00295     ALfloat MinDistance;
<a name="l00296"></a>00296     ALCheck(alGetSourcef(mySource, AL_REFERENCE_DISTANCE, &amp;MinDistance));
<a name="l00297"></a>00297 
<a name="l00298"></a>00298     <span class="keywordflow">return</span> MinDistance;
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 
<a name="l00305"></a><a class="code" href="classsf_1_1Sound.htm#f594211c35d6ac7a9df083c226749c42">00305</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Sound.htm#f594211c35d6ac7a9df083c226749c42" title="Get the attenuation factor.">Sound::GetAttenuation</a>()<span class="keyword"> const</span>
<a name="l00306"></a>00306 <span class="keyword"></span>{
<a name="l00307"></a>00307     ALfloat Attenuation;
<a name="l00308"></a>00308     ALCheck(alGetSourcef(mySource, AL_ROLLOFF_FACTOR, &amp;Attenuation));
<a name="l00309"></a>00309 
<a name="l00310"></a>00310     <span class="keywordflow">return</span> Attenuation;
<a name="l00311"></a>00311 }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313 
<a name="l00317"></a><a class="code" href="classsf_1_1Sound.htm#0e80c736a6865123be0c19e99f36467f">00317</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Sound.htm#0e80c736a6865123be0c19e99f36467f" title="Get the current playing position of the sound.">Sound::GetPlayingOffset</a>()<span class="keyword"> const</span>
<a name="l00318"></a>00318 <span class="keyword"></span>{
<a name="l00319"></a>00319     ALfloat Seconds = 0.f;
<a name="l00320"></a>00320     ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &amp;Seconds));
<a name="l00321"></a>00321 
<a name="l00322"></a>00322     <span class="keywordflow">return</span> Seconds;
<a name="l00323"></a>00323 }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325 
<a name="l00329"></a><a class="code" href="classsf_1_1Sound.htm#76c97fca3a5092db606eb66461f063af">00329</a> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b9622195" title="Enumeration of the sound states.">Sound::Status</a> <a class="code" href="classsf_1_1Sound.htm#76c97fca3a5092db606eb66461f063af" title="Get the status of the sound (stopped, paused, playing).">Sound::GetStatus</a>()<span class="keyword"> const</span>
<a name="l00330"></a>00330 <span class="keyword"></span>{
<a name="l00331"></a>00331     ALint State;
<a name="l00332"></a>00332     ALCheck(alGetSourcei(mySource, AL_SOURCE_STATE, &amp;State));
<a name="l00333"></a>00333 
<a name="l00334"></a>00334     <span class="keywordflow">switch</span> (State)
<a name="l00335"></a>00335     {
<a name="l00336"></a>00336         <span class="keywordflow">case</span> AL_INITIAL :
<a name="l00337"></a>00337         <span class="keywordflow">case</span> AL_STOPPED : <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b962219539fd53aa83db9189ca2fff82e0553cf9" title="Sound is not playing.">Stopped</a>;
<a name="l00338"></a>00338         <span class="keywordflow">case</span> AL_PAUSED :  <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b9622195c9fedbd48103548431e7851d16be5f4f" title="Sound is paused.">Paused</a>;
<a name="l00339"></a>00339         <span class="keywordflow">case</span> AL_PLAYING : <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b962219516657b221888cf11e2a076f5b2783288" title="Sound is playing.">Playing</a>;
<a name="l00340"></a>00340     }
<a name="l00341"></a>00341 
<a name="l00342"></a>00342     <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b962219539fd53aa83db9189ca2fff82e0553cf9" title="Sound is not playing.">Stopped</a>;
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345 
<a name="l00349"></a><a class="code" href="classsf_1_1Sound.htm#b794404f8facdad9578c31eff25110a7">00349</a> <a class="code" href="classsf_1_1Sound.htm" title="Sound defines the properties of a sound such as position, volume, pitch, etc.">Sound</a>&amp; <a class="code" href="classsf_1_1Sound.htm#b794404f8facdad9578c31eff25110a7" title="Assignment operator.">Sound::operator =</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Sound.htm" title="Sound defines the properties of a sound such as position, volume, pitch, etc.">Sound</a>&amp; Other)
<a name="l00350"></a>00350 {
<a name="l00351"></a>00351     <a class="code" href="classsf_1_1Sound.htm" title="Sound defines the properties of a sound such as position, volume, pitch, etc.">Sound</a> Temp(Other);
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     std::swap(mySource, Temp.<a class="code" href="classsf_1_1Sound.htm#80f6e656438d81f62dbd1e08e44ce60b" title="OpenAL source identifier.">mySource</a>);
<a name="l00354"></a>00354     std::swap(myBuffer, Temp.<a class="code" href="classsf_1_1Sound.htm#853812e73ff1cfdd04fe562431bd5a16" title="Sound buffer bound to the source.">myBuffer</a>);
<a name="l00355"></a>00355 
<a name="l00356"></a>00356     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358 
<a name="l00359"></a>00359 } <span class="comment">// namespace sf</span>
</pre></div></div>

        <p id="footer">
            &nbsp;::&nbsp; Copyright &copy; 2007-2008 Laurent Gomila, all rights reserved &nbsp;::&nbsp;
            Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> &nbsp;::&nbsp;
        </p>

    </body>
</html>