<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Successful but silent audio playback</title>
		<link>http://www.allegro.cc/forums/view/615723</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 21 Sep 2015 04:51:39 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This code by itself works, and is directly copy pasted out of my program. But it doesn&#39;t work within my program. al_play_sample and al_play_sample_instance both return true, but there is no sound in my actual program where there is in this simple test program. It&#39;s kind of mysterious. Any ideas why this might be?</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>
<span class="number">  2</span><span class="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;allegro5/allegro_audio.h&gt;</span>
<span class="number">  4</span><span class="p">#include &lt;allegro5/allegro_acodec.h&gt;</span>
<span class="number">  5</span>
<span class="number">  6</span>
<span class="number">  7</span><span class="p">#include &lt;cstdio&gt;</span>
<span class="number">  8</span>
<span class="number">  9</span>
<span class="number"> 10</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc , <span class="k1">char</span><span class="k3">*</span><span class="k3">*</span> argv<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 11</span>
<span class="number"> 12</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">1</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 13</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_install_audio"><span class="a">al_install_audio</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">2</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 14</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init_acodec_addon"><span class="a">al_init_acodec_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">3</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 15</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_reserve_samples"><span class="a">al_reserve_samples</span></a><span class="k2">(</span><span class="n">1</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">4</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 16</span>
<span class="number"> 17</span>   <a href="http://www.allegro.cc/manual/ALLEGRO_SAMPLE"><span class="a">ALLEGRO_SAMPLE</span></a><span class="k3">*</span> idle_sound <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_load_sample"><span class="a">al_load_sample</span></a><span class="k2">(</span><span class="s">"Annoy1.ogg"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>
<span class="number"> 19</span>   <a href="http://www.allegro.cc/manual/ALLEGRO_SAMPLE_INSTANCE"><span class="a">ALLEGRO_SAMPLE_INSTANCE</span></a><span class="k3">*</span> sample_instance <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_sample_instance"><span class="a">al_create_sample_instance</span></a><span class="k2">(</span>idle_sound<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>
<span class="number"> 21</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>idle_sound <span class="k3">|</span><span class="k3">|</span> <span class="k3">!</span>sample_instance<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 22</span>      <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Setup error.\n"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>      <span class="k1">return</span> <span class="n">5</span><span class="k2">;</span>
<span class="number"> 24</span>   <span class="k2">}</span>
<span class="number"> 25</span>
<span class="number"> 26</span>   <a href="http://www.allegro.cc/manual/ALLEGRO_SAMPLE_ID"><span class="a">ALLEGRO_SAMPLE_ID</span></a> sample_id<span class="k2">;</span>
<span class="number"> 27</span>
<span class="number"> 28</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_play_sample"><span class="a">al_play_sample</span></a><span class="k2">(</span>idle_sound , <span class="n">1</span>.<span class="n">0</span> , <span class="n">0</span>.<span class="n">0</span> , <span class="n">1</span>.<span class="n">0</span> , ALLEGRO_PLAYMODE_ONCE , <span class="k3">&amp;</span>sample_id<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 29</span>      <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Failed to play sample.\n"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 30</span>   <span class="k2">}</span>
<span class="number"> 31</span>
<span class="number"> 32</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_play_sample_instance"><span class="a">al_play_sample_instance</span></a><span class="k2">(</span>sample_instance<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 33</span>      <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Failed to play sample instance.\n"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 34</span>   <span class="k2">}</span>
<span class="number"> 35</span>
<span class="number"> 36</span>   <a href="http://www.allegro.cc/manual/al_rest"><span class="a">al_rest</span></a><span class="k2">(</span><span class="n">5</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 37</span>
<span class="number"> 38</span>   <a href="http://www.allegro.cc/manual/al_destroy_sample_instance"><span class="a">al_destroy_sample_instance</span></a><span class="k2">(</span>sample_instance<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 39</span>   <a href="http://www.allegro.cc/manual/al_destroy_sample"><span class="a">al_destroy_sample</span></a><span class="k2">(</span>idle_sound<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 40</span>
<span class="number"> 41</span>   <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 42</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 08 Sep 2015 09:11:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just checked it out.</p><p><span class="source-code">Failed to play sample instance.</span></p><p>But I can hear the sound file playing.</p><p>Just thought I&#39;d let you know.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matias Persson)</author>
		<pubDate>Tue, 08 Sep 2015 09:20:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well then that&#39;s a third behavior. Like I said it works fine by itself but is totally silent within my actual program.</p><p>This is with Allegro 5.1.11 and MinGW 4.8.1 on Vista btw.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 08 Sep 2015 09:23:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tested the given code with Allegro 5.0.10.</p><p>May I ask, not to go off topic or anything, but how did you compile 5.1.11 for MinGW, I tried before and failed and I would like to try out some Android Programming with Allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matias Persson)</author>
		<pubDate>Tue, 08 Sep 2015 11:29:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Compiling A5.1.11 with MinGW worked fine for me. I just used CMake, and make like normal. If you need help, post a new thread with your errors, and I&#39;ll help you as best I can. The hardest part is getting the dependencies compiled.</p><p>Btw, MinGW is for windows, but to compile on Android you use gcc IIRC, which shouldn&#39;t be much different.</p><p>Still don&#39;t know why there is no sound. Ideas?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 09 Sep 2015 06:18:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope I have no idea why this could happen, everything seems to appear fine to me, except for the debugging output.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matias Persson)</author>
		<pubDate>Wed, 09 Sep 2015 20:20:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Anybody have any ideas how I might debug this? Could it be another addon interfering somehow? Because I have stripped out all the unnecessary code from my program to make the example (which works).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 16 Sep 2015 06:29:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s on my TODO list to look into this, sorry it&#39;s been a busy week <img src="http://www.allegro.cc/forums/smileys/embarassed.gif" alt=":-[" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 Sep 2015 07:55:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey, no problem. I appreciate all the help I can get. You can download a 7z of my project where the audio is silent from here (includes win32 binary and src) :</p><p><a href="http://members.allegro.cc/EdgarReynaldo/ks/StarProject.7z">http://members.allegro.cc/EdgarReynaldo/ks/StarProject.7z</a></p><p>Press space to start the experiment and then move the mouse around the inside of the star. Audio is supposed to play when the mouse is idle for more than about 3-5 seconds, but it is quiet. I don&#39;t believe I have any memory corruption or overruns, so I don&#39;t really know what would explain it.</p><p>Thanks for looking into this. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 16 Sep 2015 08:19:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, so the issue was that in your game you called <span class="source-code"><a href="http://www.allegro.cc/manual/al_restore_default_mixer"><span class="a">al_restore_default_mixer</span></a><span class="k2">(</span><span class="k2">)</span></span>. This actually returns a <span class="source-code"><span class="k1">bool</span></span>, which if you checked it, you&#39;d have seen it returned false. It turns out that there was a bug in Allegro when <span class="source-code"><a href="http://www.allegro.cc/manual/al_restore_default_mixer"><span class="a">al_restore_default_mixer</span></a><span class="k2">(</span><span class="k2">)</span></span> was called twice (it&#39;s called the first time when you call <span class="source-code"><a href="http://www.allegro.cc/manual/al_reserve_samples"><span class="a">al_reserve_samples</span></a></span>) which resulted in the default mixer getting destroyed, but not cleared (which let the <span class="source-code"><a href="http://www.allegro.cc/manual/al_play_sample"><span class="a">al_play_sample</span></a></span> calls succeed).</p><p>It&#39;s all fixed now in 5.1 HEAD.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 17 Sep 2015 09:42:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>SiegeLord,</p><p>That fixed one issue, and now al_play_sample works correctly, but al_play_sample_instance is still silent, even though it returns true. (Note: I am still using 5.1.11, as I haven&#39;t rebuilt A5 from Git yet)</p><p>I&#39;ve uploaded an updated 7z of the source and exe to :<br /><a href="http://members.allegro.cc/EdgarReynaldo/ks/StarProject.7z">http://members.allegro.cc/EdgarReynaldo/ks/StarProject.7z</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 20 Sep 2015 03:53:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s just because you haven&#39;t attached it to a mixer. I do wonder if maybe it should return false in that case...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 21 Sep 2015 04:22:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Er. what? I have to attach sample instances to a mixer before they will play?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 21 Sep 2015 04:29:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yep, that&#39;s right. This whole attaching things to the mixer is why the simpler api ( <span class="source-code"><a href="http://www.allegro.cc/manual/al_play_sample"><span class="a">al_play_sample</span></a></span> ) exists. This is in principle documented in the <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_SAMPLE_INSTANCE"><span class="a">ALLEGRO_SAMPLE_INSTANCE</span></a></span> entry, but perhaps there should note of this in <span class="source-code"><a href="http://www.allegro.cc/manual/al_play_sample_instance"><span class="a">al_play_sample_instance</span></a></span> &#39;s documentation as well?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 21 Sep 2015 04:35:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, that&#39;s pretty confusing. It should definitely be noted in <span class="source-code"><a href="http://www.allegro.cc/manual/al_play_sample_instance"><span class="a">al_play_sample_instance</span></a></span> that you have to attach a sample instance to a voice or mixer. I didn&#39;t think to look at the docs for <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_SAMPLE_INSTANCE"><span class="a">ALLEGRO_SAMPLE_INSTANCE</span></a></span>. It just didn&#39;t occur to me, as I figured everything I needed to know to play a sample instance would have been documented in the <span class="source-code"><a href="http://www.allegro.cc/manual/al_play_sample_instance"><span class="a">al_play_sample_instance</span></a></span> docs. In that section of the docs, it should reference <span class="source-code"><a href="http://www.allegro.cc/manual/al_attach_sample_instance_to_voice"><span class="a">al_attach_sample_instance_to_voice</span></a></span> as well as <span class="source-code"><a href="http://www.allegro.cc/manual/al_attach_sample_instance_to_mixer"><span class="a">al_attach_sample_instance_to_mixer</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 21 Sep 2015 04:51:39 +0000</pubDate>
	</item>
</rss>
