Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4260

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Crystal Space 1.2.1: 4.17.2 Playing a Sound</title>

<meta name="description" content="Crystal Space 1.2.1: 4.17.2 Playing a Sound">
<meta name="keywords" content="Crystal Space 1.2.1: 4.17.2 Playing a Sound">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Playing-Sound"></a>
<a name="0"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Sound-Drivers.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Scripting-Languages.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Sound-System.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr size="1">
<h3 class="subsection"> 4.17.2 Playing a Sound </h3>

<a name="1"></a>
<h4 class="subsubheading"> Playing a Sound Once </h4>

<p>You can create more than one source to have the same sound played
multiple times at the same time. For instance if you have a shooting
sound and you want your players to shoot at the same time and have the
correct number of shooting sounds.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#include &quot;isndsys/ss_source.h&quot;
#include &quot;isndsys/ss_loader.h&quot;
#include &quot;isndsys/ss_renderer.h&quot;
#include &quot;isndsys/ss_manager.h&quot;
#include &quot;imap/loader.h&quot;

...

if (!csInitializer::RequestPlugins(object_reg,
...
  CS_REQUEST_PLUGIN(&quot;crystalspace.sndsys.renderer.software&quot;,
    iSndSysRenderer),
  CS_REQUEST_LEVELLOADER),
  CS_REQUEST_END))
...

  csRef&lt;iLoader&gt; loader = csQueryRegistry&lt;iLoader&gt; (GetObjectRegistry());
  if (!loader) ReportError(&quot;Failed to locate Loader!&quot;);

  csRef&lt;iSndSysRenderer&gt; sndrenderer = csQueryRegistry&lt;iSndSysRenderer&gt; (GetObjectRegistry());
  if (!sndrenderer) ReportError(&quot;Failed to locate Sound renderer!&quot;); 
  
  csRef&lt;iSndSysWrapper&gt; w_boom = loader-&gt;LoadSoundWrapper(&quot;buzz&quot;,&quot;/lib/std/loopbzzt.wav&quot;);
  if(!w_boom) ReportError(&quot;No Wrapper&quot;);

  csRef&lt;iSndSysData&gt; snddata = w_boom-&gt;GetData();
  if(!snddata) ReportError(&quot;No Sound Data&quot;);

  csRef&lt;iSndSysStream&gt; sndstream = sndrenderer-&gt;CreateStream (snddata, CS_SND3D_ABSOLUTE);
  if(!sndstream) ReportError(&quot;No Stream&quot;);
  
  sndstream-&gt;SetLoopState (CS_SNDSYS_STREAM_DONTLOOP);
  sndstream-&gt;Unpause ();
  
  csRef&lt;iSndSysSource&gt; sndsrc = sndrenderer-&gt;CreateSource (sndstream);
  if(!sndsrc)ReportError(&quot;No Source&quot;);

  sndsrc-&gt;SetVolume( 1.0 );

</pre></td></tr></table>
<a name="2"></a>
<h4 class="subsubheading"> Looping Background Music </h4>

<p>Here is how you can specify a looping sound:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">  sndstream-&gt;SetLoopState (CS_SNDSYS_STREAM_DONTLOOP);
  sndstream-&gt;Unpause ();
</pre></td></tr></table>


<hr size="1">
<p>
 <font size="-1">
  This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>