<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Confused by Allegro 5&#39;s sound routines</title>
		<link>http://www.allegro.cc/forums/view/615621</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 02 Aug 2015 18:53:01 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi Everyone,</p><p>This is my first post here but I&#39;ve been using Allegro5 for a while and usually do okay, but today I have I dilemma.</p><p>I&#39;m porting an old project I did in allegro 4 which had radial sound effects, for simplicity there was a location (512,384) where a looped sound effect &#39;was&#39;, and there was a sprite who moved around the screen. The volume of the effect was based on his distance to the effect:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 1</span>dX <span class="k3">=</span> spriteX <span class="k3">-</span> <span class="n">512</span><span class="k2">;</span>
<span class="number"> 2</span>dY <span class="k3">=</span> spriteY <span class="k3">-</span> <span class="n">384</span><span class="k2">;</span>
<span class="number"> 3</span>distance <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_738.html" target="_blank">sqrt</a><span class="k2">(</span><span class="k2">(</span>dX <span class="k3">*</span> dX<span class="k2">)</span> <span class="k3">+</span> <span class="k2">(</span>dY <span class="k3">*</span> dY<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 4</span>volume <span class="k3">=</span> <span class="n">255</span> <span class="k3">-</span> distance<span class="k2">;</span>
<span class="number"> 5</span><span class="k1">if</span><span class="k2">(</span>volume <span class="k3">&lt;</span> <span class="n">0</span><span class="k2">)</span>
<span class="number"> 6</span><span class="k2">{</span>
<span class="number"> 7</span>volume <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 8</span><span class="k2">}</span>
</div></div><p>

Then if I remember correctly I simply set the volume of the looping sample to this volume. </p><p>The problem is I can&#39;t workout how to set the volume of an already playing sample  in Allegro 5. Please can someone advise me as to how I can make this work, I thought it might be to do with Mixers <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />, but I couldn&#39;t work it out from the docs.</p><p>Thank you,</p><p>Stan
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (StanEd)</author>
		<pubDate>Sun, 02 Aug 2015 12:21:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use sample instances instead, you can create them from samples. It allows you to play samples but also modify them in real-time. You don&#39;t have to manually set up a mixer and voice to make them work.</p><p>To change the volume you&#39;d have to use <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_sample_instance_gain"><span class="a">al_set_sample_instance_gain</span></a></span> which as far as I know should be between 0.0 and 1.0 to avoid hard clipping.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Sun, 02 Aug 2015 15:20:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks Taron</p><p>That&#39;s good to know.</p><p><img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (StanEd)</author>
		<pubDate>Sun, 02 Aug 2015 18:53:01 +0000</pubDate>
	</item>
</rss>
