<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to get (milli)seconds from al_get_sample_length()?</title>
		<link>http://www.allegro.cc/forums/view/608628</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 21 Oct 2011 21:30:19 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How do I get seconds or milliseconds from al_get_sample_length()? My ~1s sample return ~6600. I guess the value needs to be divided...or?</p><p>A5 examples or demos does not cover this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Thu, 20 Oct 2011 18:20:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My guess would be to obtain the sample frequency (al_get_sample_instance_frequency) and the number of channels (al_get_channel_count).  The frequency is the number of samples per second per channel, so you should be able to find the length in milliseconds with:</p><p><span class="source-code">length <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_sample_length"><span class="a">al_get_sample_length</span></a><span class="k2">(</span>sample<span class="k2">)</span> <span class="k3">/</span> al_get_channel_count<span class="k2">(</span>sample<span class="k2">)</span> <span class="k3">/</span> <a href="http://www.allegro.cc/manual/al_get_sample_instance_frequency"><span class="a">al_get_sample_instance_frequency</span></a><span class="k2">(</span>sample<span class="k2">)</span><span class="k2">;</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raynebc)</author>
		<pubDate>Thu, 20 Oct 2011 19:38:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That might also need to take into account stereo samples, you would then need to divide by two.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 20 Oct 2011 19:54:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;ll give you the length in seconds, multiply by 1000 to get milliseconds. The channel count is the stereo part, it&#39;ll be 2 for a stereo sample.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 20 Oct 2011 21:26:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_get_channel_count() or  does not take a ALLEGRO_SOUND as parameter. Did you mean that function or al_get_sample_channels()?</p><p>al_get_sample_length(sound) = 5641<br />al_get_sample_channels(sound) = 16<br />al_get_sample_frequency(sound) = 11025</p><p>length / channels / frequency = 0,032</p><p>Actual sound length is according to Window Movie Maker 0,5s.</p><p>length / frequency = 0,51
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Thu, 20 Oct 2011 23:34:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/608628/934705#target">TeaRDoWN</a> said:</div><div class="quote"><p>
al_get_sample_channels(sound) = 16
</p></div></div><p>
The value returned by al_get_sample_channels is not the number of channels directly, but one of these constants:
</p><div class="source-code snippet"><div class="inner"><pre>ALLEGRO_CHANNEL_CONF_1
ALLEGRO_CHANNEL_CONF_2
ALLEGRO_CHANNEL_CONF_3
ALLEGRO_CHANNEL_CONF_4
ALLEGRO_CHANNEL_CONF_5_1
ALLEGRO_CHANNEL_CONF_6_1
ALLEGRO_CHANNEL_CONF_7_1
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Oscar Giner)</author>
		<pubDate>Fri, 21 Oct 2011 03:37:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, but I just tried to figure out which function raynebc wanted me to use when he wrote <span class="source-code">al_get_channel_count<span class="k2">(</span>sample<span class="k2">)</span></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Fri, 21 Oct 2011 10:04:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Off the top of my head, I don&#39;t know which function you should use, but whichever one directly returns the number of channels instead of a macro defined value.  I did forget to mention dividing by 1000.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raynebc)</author>
		<pubDate>Fri, 21 Oct 2011 21:30:19 +0000</pubDate>
	</item>
</rss>
