<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>music in allegro5</title>
		<link>http://www.allegro.cc/forums/view/601120</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 03 Aug 2009 15:54:33 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So i&#39;ve never done anything with music before... samples/voices/mixers... mean nothing to me I'm dumb!...</p><p>so by alot of reading the api and other things i came up with this</p><div class="source-code snippet"><div class="inner"><pre>al_install_audio<span class="k2">(</span>ALLEGRO_AUDIO_DRIVER_AUTODETECT<span class="k2">)</span><span class="k2">;</span>
ALLEGRO_SAMPLE <span class="k3">*</span>test <span class="k3">=</span> al_load_sample_wav<span class="k2">(</span><span class="s">"music/simple.wav"</span><span class="k2">)</span><span class="k2">;</span>
<span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>test<span class="k2">)</span>
    cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt load music"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="k1">else</span>
    al_play_sample<span class="k2">(</span>test,<span class="n">255</span>, <span class="n">128</span>, <span class="n">1000</span>, <span class="n">0</span>,NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

but it doesnt work... <br />1. it says undefined reference to al_install_audio. (i&#39;ve got allegro5/acodec.h included and liba5_acodec-4.9.12.dll.a linked... am i mission something?<br />2. al_play_sample gives me the same error... undefined reference...</p><p>i looked for other files to link to and include in the project but didnt find anything that looked like it would help.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sat, 01 Aug 2009 10:23:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;ll want to link to kcm_audio as well. acodec just provides audio decoders for popular formats. At some point I&#39;ll probably be renamed to better fit the current naming scheme.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 01 Aug 2009 10:28:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>perfect, now it compiles and i dont get any errors, but i dont hear anything <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" /></p><p>EDIT:</p><p>after more reading i&#39;ve changed it to this;
</p><div class="source-code snippet"><div class="inner"><pre>al_install_audio<span class="k2">(</span>ALLEGRO_AUDIO_DRIVER_AUTODETECT<span class="k2">)</span><span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_reserve_samples<span class="k2">(</span><span class="n">5</span><span class="k2">)</span><span class="k2">)</span>
        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt reserve samples"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>

    ALLEGRO_SAMPLE <span class="k3">*</span>test <span class="k3">=</span> al_load_sample<span class="k2">(</span><span class="s">"music/simple.wav"</span><span class="k2">)</span><span class="k2">;</span>
    ALLEGRO_SAMPLE_ID testid<span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>test<span class="k2">)</span>
        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt load music"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>

    al_play_sample<span class="k2">(</span>test,<span class="n">1</span>, ALLEGRO_AUDIO_PAN_NONE, <span class="n">1</span>, <span class="n">1</span>, <span class="k3">&amp;</span>testid<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
but still no sound...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sat, 01 Aug 2009 10:38:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_install_audio<span class="k2">(</span>ALLEGRO_AUDIO_DRIVER_AUTODETECT<span class="k2">)</span><span class="k2">)</span>
  cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"Apparently can't find a driver"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
</pre></div></div><p>
Maybe? I don&#39;t know about a5 error messages...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Sat, 01 Aug 2009 14:09:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Post a test case. What you have should work unless there&#39;s something else wrong in your code.</p><p>Secondly, you&#39;re better of streaming your music than loading it all into memory. A 1 minute sample is going to take huge amounts of memory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Sat, 01 Aug 2009 18:39:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use <span class="source-code">ALLEGRO_PLAYMODE_ONCE</span> or <span class="source-code">ALLEGRO_PLAYMODE_LOOP</span> for the fifth argument. I don&#39;t think either of them are defined to 1.</p><p>The last parameter can be NULL if you never need to explicitly stop it.</p><p>Also, some wav files won&#39;t load in 4.9.12 if they have extended information embedded in them. But most should work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sat, 01 Aug 2009 19:54:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok here is what i got now.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_install_audio<span class="k2">(</span>ALLEGRO_AUDIO_DRIVER_AUTODETECT<span class="k2">)</span><span class="k2">)</span>
        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt install audio"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_reserve_samples<span class="k2">(</span><span class="n">2048</span><span class="k2">)</span><span class="k2">)</span>
        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt reserve samples"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>

    ALLEGRO_SAMPLE <span class="k3">*</span>test <span class="k3">=</span> al_load_sample<span class="k2">(</span><span class="s">"music/simple.wav"</span><span class="k2">)</span><span class="k2">;</span>
    ALLEGRO_SAMPLE_ID testid<span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>test<span class="k2">)</span>
        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt load music"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>

    al_play_sample<span class="k2">(</span>test,<span class="n">1</span>.<span class="n">0</span>, ALLEGRO_AUDIO_PAN_NONE, <span class="n">1</span>.<span class="n">0</span>, ALLEGRO_PLAYMODE_ONCE , <span class="k3">&amp;</span>testid<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

and it works now!... kinda.  after adding ALLEGRO_PLAYMODE_ONCE... but it sounds really jacked up... then crashes haha.</p><p>how do i stream it instead of loading it all?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sun, 02 Aug 2009 07:39:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_stream_from_file
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Aug 2009 07:45:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>did that and now i dont get any noise, or any errors... bad .wav? it works in itunes...</p><p>btw: what do i put in al_reserve_samples() (or do i even need that anymore?)<br />and what should i put for the first two args to al_stream_from_file()?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sun, 02 Aug 2009 08:15:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did you attach the stream to a mixer? Check out ex_stream_file.c.</p><p>al_reserve_samples() sets up a default voice and mixer and is required for al_play_sample().</p><p>If you set up your own voice and mixer and don&#39;t use al_play_sample(), then you don&#39;t need it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Aug 2009 08:28:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>nope didnt attach the stream to a mixer... (stream, mixer, sample, voice, they all still mean very little to me, but they&#39;re starting to come together.)</p><p>EDIT: I now have this
</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="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_install_audio<span class="k2">(</span>ALLEGRO_AUDIO_DRIVER_AUTODETECT<span class="k2">)</span><span class="k2">)</span>
<span class="number">  2</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt install audio"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number">  3</span>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_reserve_samples<span class="k2">(</span><span class="n">2048</span><span class="k2">)</span><span class="k2">)</span>
<span class="number">  4</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt reserve samples"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number">  5</span>
<span class="number">  6</span>    ALLEGRO_VOICE<span class="k3">*</span> voice <span class="k3">=</span> al_create_voice<span class="k2">(</span><span class="n">44100</span>, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2<span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>voice<span class="k2">)</span>
<span class="number">  8</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt create voice"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number">  9</span>    ALLEGRO_MIXER<span class="k3">*</span> mixer <span class="k3">=</span> al_create_mixer<span class="k2">(</span><span class="n">44100</span>, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>mixer<span class="k2">)</span>
<span class="number"> 11</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt create mixer"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number"> 12</span>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_attach_mixer_to_voice<span class="k2">(</span>voice, mixer<span class="k2">)</span><span class="k2">)</span>
<span class="number"> 13</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt attach mixer to voice"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number"> 14</span>    ALLEGRO_STREAM <span class="k3">*</span>stream <span class="k3">=</span> al_stream_from_file<span class="k2">(</span><span class="n">4</span>,<span class="n">2048</span>,<span class="s">"music/simple.wav"</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>stream<span class="k2">)</span>
<span class="number"> 16</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"couldnt start the stream"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
<span class="number"> 17</span>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>al_attach_stream_to_mixer<span class="k2">(</span>mixer, stream<span class="k2">)</span><span class="k2">)</span>
<span class="number"> 18</span>        cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"Couldnt attach stream to mixer"</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
</div></div><p>

but still no sound or errors... i copied ex_stream_file.c as best i could.</p><p>EDIT: EDIT: is there someway to change the volume or something?? and for al_stream_from_file, how do i know what to put for the first two arguments?</p><p>EDIT: EDIT: EDIT: Just found out the wav file was junk <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sun, 02 Aug 2009 08:40:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><ul><li><p>voice =&gt; a direct line to hardware</p><br /></li><li><p>mixer =&gt; takes multiple audio sources, mixes them together, and sends it to a voice</p><br /></li><li><p>stream =&gt; produces audio via a small memory buffer that must be filled in real time</p><br /></li><li><p>sample =&gt; an audio clip that can be played directly via <span class="source-code">al_play_sample<span class="k2">(</span><span class="k2">)</span></span></p><br /></li><li><p>sample instance =&gt; a &quot;copy&quot; of a sample that can be controlled and played back with more flexibility</p><br /></li><li><p><a href="http://alleg.sourceforge.net/a5docs/refman/kcm_audio.html#al_set_stream_gain">http://alleg.sourceforge.net/a5docs/refman/kcm_audio.html#al_set_stream_gain</a>, etc</p><br /></li><li><p>When you call <span class="source-code">al_reserve_samples<span class="k2">(</span><span class="k2">)</span></span>, a stereo (2 channel) voice and mixer are created for you. You can use <span class="source-code">al_get_default_mixer<span class="k2">(</span><span class="k2">)</span></span> to retrieve it. </p><br /></li><li><p>4.9.13 has better support for loading wav files.
</p></li></ul></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Aug 2009 22:55:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>perfect thanks!  Just what i needed to know!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Sun, 02 Aug 2009 23:12:20 +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/601120/823996#target">Matthew Leverton</a> said:</div><div class="quote"><p>4.9.13 has better support for loading wav files.</p></div></div><p>Technically its worse. While Elias added support for skipping unknown data in the wav, Peter decided it was ok to remove support for libsndfile, which is what supported encoded wav files (ADPCM etc). So now all we&#39;re going to get is plain old un encoded wav support (back to how it was in A4).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Aug 2009 08:19:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I won&#39;t be including libsndfile in any Allegro.cc binary distributions, so I don&#39;t care either way.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 03 Aug 2009 08:36:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t think we need an official sndfile addon.  ADPCM wave files would be the strongest reason, but in a game you can pick which file formats you want to use, and I can&#39;t see why you&#39;d use ADPCM wave files over FLAC or Ogg Vorbis, if you are concerned about the size of uncompressed PCM. The sizes of the FLAC and sndfile libraries are nearly the same, and Ogg Vorbis is smaller than either:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
-rwxr-xr-x 1 root root 328704 2008-09-11 09:28 libFLAC.so.8.2.0<br />-rwxr-xr-x 1 root root  16404 2007-02-16 17:19 libogg.so.0.5.3<br />-rwxr-xr-x 1 root root 369228 2009-03-19 14:17 libsndfile.so.1.0.18<br />-rwxr-xr-x 1 root root 165380 2007-09-24 05:04 libvorbis.so.0.4.0<br />-rwxr-xr-x 1 root root  30600 2007-09-24 05:04 libvorbisfile.so.3.2.0
</p></div></div><p>

Not to mention ADPCM sounds crap.<br />(edit: in my experience, which might be due to the implementations, plus it&#39;s been a long time)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Mon, 03 Aug 2009 10:09:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I can&#39;t say why someone would pick ADPCM or other encoded wav formats over plain old Ogg, flac, or mp3 for that matter. And heck, one of these days someone should add a Speex loader as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Aug 2009 15:54:33 +0000</pubDate>
	</item>
</rss>
