1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
<!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 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 List</span></a></li>
</ul>
</div>
<h1>SoundStream.hpp</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="l00025"></a>00025 <span class="preprocessor">#ifndef SFML_SOUNDSTREAM_HPP</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define SFML_SOUNDSTREAM_HPP</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="comment">// Headers</span>
<a name="l00031"></a>00031 <span class="comment"></span><span class="preprocessor">#include <SFML/Audio/Sound.hpp></span>
<a name="l00032"></a>00032 <span class="preprocessor">#include <SFML/System/Thread.hpp></span>
<a name="l00033"></a>00033 <span class="preprocessor">#include <cstdlib></span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="keyword">namespace </span>sf
<a name="l00037"></a>00037 {
<a name="l00044"></a><a class="code" href="classsf_1_1SoundStream.htm">00044</a> <span class="keyword">class </span>SFML_API <a class="code" href="classsf_1_1SoundStream.htm" title="SoundStream is a streamed sound, ie samples are acquired while the sound is playing...">SoundStream</a> : <span class="keyword">private</span> <a class="code" href="classsf_1_1Thread.htm" title="Thread defines an easy way to manipulate a thread.">Thread</a>, <span class="keyword">private</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>
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 <span class="keyword">public</span> :
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b9622195" title="Enumeration of the sound states.">Sound::Status</a>;
<a name="l00049"></a>00049 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b962219539fd53aa83db9189ca2fff82e0553cf9" title="Sound is not playing.">Sound::Stopped</a>;
<a name="l00050"></a>00050 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b9622195c9fedbd48103548431e7851d16be5f4f" title="Sound is paused.">Sound::Paused</a>;
<a name="l00051"></a>00051 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b962219516657b221888cf11e2a076f5b2783288" title="Sound is playing.">Sound::Playing</a>;
<a name="l00052"></a>00052 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#6a712910ac1340f32e3ec3a04295ebd3" title="Pause the sound.">Sound::Pause</a>;
<a name="l00053"></a>00053 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#f93301feb88770789ba7cd993c9dd3a0" title="Set the sound pitch.">Sound::SetPitch</a>;
<a name="l00054"></a>00054 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#1536095045923a2332dd9eed6bf8e96a" title="Set the sound volume.">Sound::SetVolume</a>;
<a name="l00055"></a>00055 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#b445e8738218525d8dd067628bc70c78" title="Set the sound position (take 3 values).">Sound::SetPosition</a>;
<a name="l00056"></a>00056 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#7604f576d184ba8031789beee96d04d3" title="Make the sound&#39;s position relative to the listener&#39;s position, or absolute...">Sound::SetRelativeToListener</a>;
<a name="l00057"></a>00057 <span class="keyword">using</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>;
<a name="l00058"></a>00058 <span class="keyword">using</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>;
<a name="l00059"></a>00059 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#42333202ed0586f434d852cc35b9d4ef" title="Get the pitch.">Sound::GetPitch</a>;
<a name="l00060"></a>00060 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#018e78cd6c50d653fffff1005a350782" title="Get the volume.">Sound::GetVolume</a>;
<a name="l00061"></a>00061 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#b1adb173ee12a86f261fb765be050643" title="Get the sound position.">Sound::GetPosition</a>;
<a name="l00062"></a>00062 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#f0278152abf6e3f195353ce3c270f34e" title="Tell if the sound&#39;s position is relative to the listener&#39;s position, or if...">Sound::IsRelativeToListener</a>;
<a name="l00063"></a>00063 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#07f37119f7b3b00f274ac0263a4bc58b" title="Get the minimum distance.">Sound::GetMinDistance</a>;
<a name="l00064"></a>00064 <span class="keyword">using</span> <a class="code" href="classsf_1_1Sound.htm#f594211c35d6ac7a9df083c226749c42" title="Get the attenuation factor.">Sound::GetAttenuation</a>;
<a name="l00065"></a>00065
<a name="l00069"></a><a class="code" href="structsf_1_1SoundStream_1_1Chunk.htm">00069</a> <span class="keyword">struct </span><a class="code" href="structsf_1_1SoundStream_1_1Chunk.htm" title="Structure defining a chunk of audio data to stream.">Chunk</a>
<a name="l00070"></a>00070 {
<a name="l00071"></a><a class="code" href="structsf_1_1SoundStream_1_1Chunk.htm#b550ca7bec7530d5dba1faabb1810449">00071</a> <span class="keyword">const</span> Int16* Samples;
<a name="l00072"></a><a class="code" href="structsf_1_1SoundStream_1_1Chunk.htm#4748a66b0fee43045db65556354b2abf">00072</a> std::size_t NbSamples;
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074
<a name="l00079"></a>00079 <span class="keyword">virtual</span> ~<a class="code" href="classsf_1_1SoundStream.htm" title="SoundStream is a streamed sound, ie samples are acquired while the sound is playing...">SoundStream</a>();
<a name="l00080"></a>00080
<a name="l00085"></a>00085 <span class="keywordtype">void</span> Play();
<a name="l00086"></a>00086
<a name="l00091"></a>00091 <span class="keywordtype">void</span> Stop();
<a name="l00092"></a>00092
<a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetChannelsCount() <span class="keyword">const</span>;
<a name="l00100"></a>00100
<a name="l00107"></a>00107 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetSampleRate() <span class="keyword">const</span>;
<a name="l00108"></a>00108
<a name="l00115"></a>00115 <a class="code" href="classsf_1_1Sound.htm#28ad2186cde78fed2c79c867b9622195" title="Enumeration of the sound states.">Status</a> GetStatus() <span class="keyword">const</span>;
<a name="l00116"></a>00116
<a name="l00123"></a>00123 <span class="keywordtype">float</span> GetPlayingOffset() <span class="keyword">const</span>;
<a name="l00124"></a>00124
<a name="l00132"></a>00132 <span class="keywordtype">void</span> SetLoop(<span class="keywordtype">bool</span> Loop);
<a name="l00133"></a>00133
<a name="l00140"></a>00140 <span class="keywordtype">bool</span> GetLoop() <span class="keyword">const</span>;
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keyword">protected</span> :
<a name="l00143"></a>00143
<a name="l00148"></a>00148 <a class="code" href="classsf_1_1SoundStream.htm" title="SoundStream is a streamed sound, ie samples are acquired while the sound is playing...">SoundStream</a>();
<a name="l00149"></a>00149
<a name="l00157"></a>00157 <span class="keywordtype">void</span> Initialize(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ChannelsCount, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SampleRate);
<a name="l00158"></a>00158
<a name="l00159"></a>00159 <span class="keyword">private</span> :
<a name="l00160"></a>00160
<a name="l00165"></a>00165 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Run();
<a name="l00166"></a>00166
<a name="l00173"></a>00173 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnStart();
<a name="l00174"></a>00174
<a name="l00183"></a>00183 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnGetData(<a class="code" href="structsf_1_1SoundStream_1_1Chunk.htm" title="Structure defining a chunk of audio data to stream.">Chunk</a>& Data) = 0;
<a name="l00184"></a>00184
<a name="l00194"></a>00194 <span class="keywordtype">bool</span> FillAndPushBuffer(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> BufferNum);
<a name="l00195"></a>00195
<a name="l00202"></a>00202 <span class="keywordtype">bool</span> FillQueue();
<a name="l00203"></a>00203
<a name="l00208"></a>00208 <span class="keywordtype">void</span> ClearQueue();
<a name="l00209"></a>00209
<a name="l00210"></a>00210 <span class="keyword">enum</span> {BuffersCount = 3};
<a name="l00211"></a>00211
<a name="l00213"></a>00213 <span class="comment">// Member data</span>
<a name="l00215"></a>00215 <span class="comment"></span> <span class="keywordtype">bool</span> myIsStreaming;
<a name="l00216"></a>00216 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> myBuffers[BuffersCount];
<a name="l00217"></a>00217 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> myChannelsCount;
<a name="l00218"></a>00218 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mySampleRate;
<a name="l00219"></a>00219 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> myFormat;
<a name="l00220"></a>00220 <span class="keywordtype">bool</span> myLoop;
<a name="l00221"></a>00221 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mySamplesProcessed;
<a name="l00222"></a>00222 <span class="keywordtype">bool</span> myEndBuffers[BuffersCount];
<a name="l00223"></a>00223 };
<a name="l00224"></a>00224
<a name="l00225"></a>00225 } <span class="comment">// namespace sf</span>
<a name="l00226"></a>00226
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="preprocessor">#endif // SFML_SOUNDSTREAM_HPP</span>
</pre></div></div>
<p id="footer">
:: Copyright © 2007-2008 Laurent Gomila, all rights reserved ::
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> ::
</p>
</body>
</html>
|