<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>AllegroMP3 == chaos in my mind.</title>
		<link>http://www.allegro.cc/forums/view/591367</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 14 May 2007 16:16:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have never seen something more confusing than the AllegroMP3 example file.. yes, i don&#39;t have enough knowledge but still, an example file should only include the things necessary and related to the subject, in this case to play an mp3 file.<br />And it should be commented.</p><p>This might sound a little lazy but.. could someone please post a piece of code of AllegroMP3 that only includes the very minimum required code to play an mp3 file?.</p><p>thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sat, 12 May 2007 20:30:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s been a long time since I used it, but I thought it was something like ALMP3_load(), ALMP3_play()... I&#39;ll go check it out, though.</p><p>Heh, okay... maybe not.
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Server not found
</p></div></div><p>
<img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sat, 12 May 2007 20:42:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You have to open a file, seek to the end of it, find the offset of that position, seek to the beginning, create a buffer of the same size as the file, read the file into the buffer, than pass that to AlMP3, IIRC.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sat, 12 May 2007 20:57:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
create a buffer of the same size as the file
</p></div></div><p>
Does &#39;seeking&#39; actually give you purely PCM data (as it has VBR and probably metadata in each frame)?</p><p>OP: Basically, MP3 and all other codecs should decode to a common format (like .wav files - which is why they&#39;re so big), but each codec does it differently.</p><p>Unless you want to stream it, you&#39;ll need to create a normal SAMPLE and then uncompress the PCM data of the MP3 file into the <b>data</b> attribute, as well as give it the metadata (bits[rate], stereo, freq[uency], len[gth]) so the SAMPLE knows how much data <b>data</b> describes. Then you should be able to just play it like you play a normal .wav file.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Sat, 12 May 2007 21:09:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Unless you want to stream it, you&#39;ll need to create a normal SAMPLE and then uncompress the PCM data of the MP3 file into the data attribute, as well as give it the metadata (bits[rate], stereo, freq[uency], len[gth]) so the SAMPLE knows how much data data describes. Then you should be able to just play it like you play a normal .wav file.
</p></div></div><p>And why would anyone use AlMP3 if they had to do this? <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Does &#39;seeking&#39; actually give you purely PCM data (as it has VBR and probably metadata in each frame)?
</p></div></div><p>No, it gives you the size of the MP3 file. AlMP3 doesn&#39;t know how to read files, so you can for instance pass in an MP3 stored in a datafile.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sat, 12 May 2007 21:41:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK.. maybe all that &#39;crap&#39; wasn&#39;t unnecessary.. thanks for your help!!<br />Unfortunately i have to spend some time with my friends watching &quot;eurovision song contest&quot; or whatever, then i&#39;ll be able to get down to work.</p><p>If you have a more detailed version on how to make it work then don&#39;t hesitate to post it.</p><p>I thank thee!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sat, 12 May 2007 21:56:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And why would anyone use AlMP3 if they had to do this? <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div></div><p>
I don&#39;t know! I can&#39;t think straight (it was 2:10am) <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>I&#39;m just recalling what I&#39;m trying to do with libvorbisfile and libFLAC for OpenAL... Not so fun if I can&#39;t test it in the middle of programming it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Sat, 12 May 2007 21:56:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wow, how is ALMP3 a billion times more complicated than I remember it?</p><p>I was able to use it while I was still working on my first game, which was pure C with ridiculously awful practices and an endearingly noob-ish lack of skill/knowledge... I got through by the skin of my teeth. I wonder how I was able to contend with ALMP3.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 13 May 2007 06:42:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can&#39;t stream the mp3s directly of the disk by just sending chunks of data instead of it all? Loading up a 3-5MB mp3 just to send to almp3 seems a bit silly when libmad lets you load and decode on the fly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 11:39:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Thomas Fjellstrom said:</div><div class="quote"><p>
 You can&#39;t stream the mp3s directly of the disk by just sending chunks of data instead of it all? Loading up a 3-5MB mp3 just to send to almp3 seems a bit silly when libmad lets you load and decode on the fly.
</p></div></div><p>

I think you can.<br />ALMP3_MP3 *s; to create a non-stream type.<br />ALMP3_MP3STREAM *s; to create a stream type.</p><p>Anyway: i&#39;m accepting the AllegroMP3 challenge and now i&#39;m facing my first opponent. PACKFILES! i&#39;m having a huge problem understanding these fellas.<br />First of: how do i create a packfile? is there a tool?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 11:48:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A normal allegro packfile is just a regular file that can optionally be moderately compressed. <span class="source-code"><a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a> <a href="http://www.allegro.cc/manual/pack_fclose" target="_blank"><span class="a">pack_fclose</span></a></span> etc. The api is very similar to the libc standard file io routines.</p><p>Now if you mean datafiles, theres dat.exe and grabber.exe
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 11:50:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>nono! not datafiles, i have those under control.. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.<br />so how would i go about to create a packfile with for example a mp3file?<br />would i create a new program and use pack routines with fstream? or something..</p><p>gah, something like this would have made my day:</p><p>packfile.write(&quot;iman.mp3&quot;);</p><p> - -.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 11:53:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, the packfile stuff is very similar to &quot;stdio&quot;.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>pf <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span><span class="s">"w"</span>, <span class="s">"filename"</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fwrite" target="_blank"><span class="a">pack_fwrite</span></a><span class="k2">(</span>data, sizeof_data, pf<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fclose" target="_blank"><span class="a">pack_fclose</span></a><span class="k2">(</span>pf<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 11:57:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
&quot;PACKFILE *pf = pack_fopen(&quot;w&quot;, &quot;filename&quot;);&quot;<br />This loads a packfile right?</p><p>pack_fwrite(data, sizeof_data, pf);<br />Is this where you write to the opened datafile?<br />so whats data representing? or rather how would i load this data and to use with this function? and how would i get sizeof_data?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 12:08:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
This loads a packfile right?
</p></div></div><p>It just opens it, for &quot;w&quot;riting in this case.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is this where you write to the opened datafile?
</p></div></div><p>Packfile, and yes.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> data<span class="k2">[</span><span class="n">256</span><span class="k2">]</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>pf <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span><span class="s">"r"</span>, <span class="s">"filename"</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, <span class="n">256</span>, pf<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fclose" target="_blank"><span class="a">pack_fclose</span></a><span class="k2">(</span>pf<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

And that will read the first 256 bytes of whatever is in &quot;filename&quot;, and place it in data.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 12:11:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You can&#39;t stream the mp3s directly of the disk by just sending chunks of data instead of it all?
</p></div></div><p>No, you can. That&#39;s why AlMP3 doesn&#39;t provide filename-based functions and lets you do the dirty work. If it did, it would cut out a lot of the features.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sun, 13 May 2007 12:13:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> data<span class="k2">[</span><span class="n">256</span><span class="k2">]</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>pf <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span><span class="s">"r"</span>, <span class="s">"filename"</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, <span class="n">256</span>, pf<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/pack_fclose" target="_blank"><span class="a">pack_fclose</span></a><span class="k2">(</span>pf<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

ok, so thats how i read..</p><p>to write however:</p><p>pack_fwrite(data, sizeof_data, pf);
</p><div class="quote_container"><div class="title">manual said:</div><div class="quote"><p>
from memory location pointed to by `p&#39;.
</p></div></div><p>
memory means? can i replace data with the path to the mp3? (hopes for an easy solution)..</p><p>why: char data[256]?? <br />why does it read the first 256bytes? can&#39;t i have more than one information in one packfile? can i nest packfiles?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 12:24:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
memory means?
</p></div></div><p>Any memory address. like a pointer to something. Generally an array of some kind is used (since using it without the []s it acts like a pointer, and thus works in functions like these).<br />Everything in a running program is stored in memory. variables, functions, etc. You can also get a &quot;pointer&quot; to them as well, and use that pointer in functions that take one.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
can i replace data with the path to the mp3? (hopes for an easy solution)..
</p></div></div><p>If you want to read the mp3, you just place the filename in the &quot;filename&quot; bit in pack_fopen, and then use pack_fread to read it in.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
why: char data[256]??
</p></div></div><p>Because. No reason, just some random number I picked.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
why does it read the first 256bytes?
</p></div></div><p>Because a file &quot;read&quot; position starts at 0 by default, and I put &quot;256&quot; in the size bit in pack_fread, its also the size of the array (you never want to read more data than can fit in your memory variable).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
can&#39;t i have more than one information in one packfile?
</p></div></div><p>
IIRC its limited to about 2-4GB</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
can i nest packfiles?
</p></div></div><p><a href="http://www.allegro.cc/manual/api/file-and-compression-routines/pack_fopen_chunk">Yes</a>. Though thats a little more complex than just normal packfiles.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 12:36:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Though thats a little more complex than just normal packfiles.
</p></div></div><p>
Aka nothing i should bother with..</p><p>Well, below is my pathetic attempt to make a simple function to load and play mp3 files.. this didn&#39;t work, it doesn&#39;t crash either, which should have been preferred..</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#define DATASZ  (1&lt;&lt;15)</span></td></tr><tr><td class="number">2</td><td><span class="p">#define BUFSZ   (1&lt;&lt;16)</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td><span class="k1">void</span> <span class="k3">*</span>open_mp3_file<span class="k2">(</span><span class="k1">char</span> <span class="k3">*</span>filename<span class="k2">)</span></td></tr><tr><td class="number">5</td><td><span class="k2">{</span></td></tr><tr><td class="number">6</td><td>  <span class="k1">using</span> <span class="k1">namespace</span> sfx::music<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  </td></tr><tr><td class="number">8</td><td>  <a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>mp3file <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">9</td><td>  ALMP3_MP3STREAM <span class="k3">*</span>mp3 <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  <span class="k1">char</span> data<span class="k2">[</span>DATASZ<span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>  <span class="k1">int</span> len<span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  </td></tr><tr><td class="number">13</td><td>  mp3file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span>filename, F_READ<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, DATASZ, mp3file<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>  </td></tr><tr><td class="number">16</td><td>  <span class="k1">if</span> <span class="k2">(</span>len <span class="k3">&lt;</span> DATASZ<span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">17</td><td>    mp3 <span class="k3">=</span> almp3_create_mp3stream<span class="k2">(</span>data, len, TRUE<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">19</td><td>  <span class="k1">else</span> </td></tr><tr><td class="number">20</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">21</td><td>    mp3 <span class="k3">=</span> almp3_create_mp3stream<span class="k2">(</span>data, DATASZ, FALSE<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">22</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">23</td><td>  </td></tr><tr><td class="number">24</td><td>  almp3_play_mp3stream<span class="k2">(</span>mp3, DATASZ, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>  </td></tr><tr><td class="number">26</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

<img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 13:55:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>DATAZ is only 256kb in size, with a 128kb/s mp3, thats about 2 seconds of mp3 data.</p><p>Also, I think the MP3STREAM/mp3stream stuff is for streaming off the disk, so you read X bytes every so often and send into the stream, where as it looks like you want to just load it all and send, in which case, you need to dynamically allocate &quot;data&quot; with &quot;malloc&quot; or &quot;new&quot; the size of the file, and then send it using the non stream functions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 21:31:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
DATAZ is only 256kb in size, with a 128kb/s mp3, thats about 2 seconds of mp3 data.
</p></div></div><p>No, it&#39;s 32 KB.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sun, 13 May 2007 21:49:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, somehow I got the math wrong, its 1024kb, which is 8 seconds of playtime with a 128kb/s mp3.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 21:52:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
<span class="source-code"><span class="p">#define DATASZ  (1&lt;&lt;15)</span></span>
</p></div></div><p>It&#39;s 32,768 bytes long. 32 kilobytes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sun, 13 May 2007 21:57:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OOps, I&#39;m really fuzzy this morning. I was right to begin with. I&#39;m talking BITS here not bytes. To match with the way mp3s are labeled (in kbits/s).</p><p>32KB * 8bits is a whole 256kbits.</p><p>Do you see now what I&#39;m talking about?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 13 May 2007 22:22:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think my muscles was just replaced by lead.. <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />.. sight..<br />I feel like i&#39;m in a deadlock, to learn this, i need to learn that, but too learn that, i need to learn this. Anyway, just working my <span class="cuss"><span>ass</span></span> of usually shows results so here&#39;s some more questions(my definition of working my <span class="cuss"><span>ass</span></span> of <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />):</p><p>Ok, the goal is to load and play a mp3 non-streamed..</p><p>trying to get a grip on &gt;what i have to do to get it to work&lt; is important.<br />see comments for comments:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">//the ultimate lazy-man project function:</span></td></tr><tr><td class="number">2</td><td><span class="k1">void</span> whatever<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">3</td><td><span class="k2">{</span></td></tr><tr><td class="number">4</td><td>  <a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>mp3file <span class="k3">=</span> NULL<span class="k2">;</span><span class="c">// is a pack file really requiered and what is a </span></td></tr><tr><td class="number">5</td><td>  <span class="c">//packfile??</span></td></tr><tr><td class="number">6</td><td>  </td></tr><tr><td class="number">7</td><td>  ALMP3_MP3 <span class="k3">*</span>mp3 <span class="k3">=</span> NULL<span class="k2">;</span><span class="c">//how is this data type built up? and what is the idea of   </span></td></tr><tr><td class="number">8</td><td>  <span class="c">//having this thing?</span></td></tr><tr><td class="number">9</td><td>  </td></tr><tr><td class="number">10</td><td>  <span class="k1">char</span> data<span class="k2">[</span>x<span class="k2">]</span><span class="k2">;</span><span class="c">//ok? what the hell is this?</span></td></tr><tr><td class="number">11</td><td>  <span class="c">//why is the "data" stored as an char array?</span></td></tr><tr><td class="number">12</td><td>  </td></tr><tr><td class="number">13</td><td>  <span class="k1">int</span> len<span class="k2">;</span><span class="c">//what is this?...</span></td></tr><tr><td class="number">14</td><td>  </td></tr><tr><td class="number">15</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, x, mp3file<span class="k2">)</span><span class="k2">;</span><span class="c">//see above..</span></td></tr><tr><td class="number">16</td><td>&#160;</td></tr><tr><td class="number">17</td><td>  mp3file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span>filename, F_READ<span class="k2">)</span><span class="k2">;</span><span class="c">//this is obviously something packfile    </span></td></tr><tr><td class="number">18</td><td>  <span class="c">//related.. what should filename be? the path in char data type? ex: "muu.mp3".??</span></td></tr><tr><td class="number">19</td><td>  </td></tr><tr><td class="number">20</td><td>  <span class="c">//following(copying the example) this section makes less sense after</span></td></tr><tr><td class="number">21</td><td>  <span class="c">//pathetically converting it for non streamed type.</span></td></tr><tr><td class="number">22</td><td>  <span class="k1">if</span> <span class="k2">(</span>len <span class="k3">&lt;</span> x<span class="k2">)</span> <span class="c">//ok..</span></td></tr><tr><td class="number">23</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">24</td><td>    mp3 <span class="k3">=</span> almp3_create_mp3<span class="k2">(</span>data, len<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">26</td><td>  <span class="k1">else</span> </td></tr><tr><td class="number">27</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">28</td><td>    mp3 <span class="k3">=</span> almp3_create_mp3<span class="k2">(</span>data, x<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">29</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">30</td><td>  <span class="c">//ok.. so use the lowest value when creating the mp3.. why??</span></td></tr><tr><td class="number">31</td><td>  <span class="c">//is this because of the streaming thingie?</span></td></tr><tr><td class="number">32</td><td>  </td></tr><tr><td class="number">33</td><td>  almp3_play_mp3stream<span class="k2">(</span>mp3, x, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span><span class="c">//trying to play it.. </span></td></tr><tr><td class="number">34</td><td>  <span class="c">//mp3 = the mp3.. x = size of what? how do i allcolate the space required?</span></td></tr><tr><td class="number">35</td><td>  <span class="c">// 255 volume or pitch of something i don't need to focus on right now.</span></td></tr><tr><td class="number">36</td><td>  </td></tr><tr><td class="number">37</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

It&#39;s not easy being a newbie, <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.<br />Thanks a lot for eventual answers! really! <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 13 May 2007 23:42:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
is a pack file really requiered and what is a packfile??
</p></div></div><p>Yes, and its just a file handle. You use it to read and/or write to files.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
how is this data type built up? and what is the idea of having this thing
</p></div></div><p> Almp3 provides the type and builds it for you with &#39;almp3_create_mp3&#39;.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> data<span class="k2">[</span>x<span class="k2">]</span><span class="k2">;</span><span class="c">//ok? what the hell is this?</span>
<span class="c">//why is the "data" stored as an char array?</span>
</pre></div></div><p>

What type does almp3_create_mp3 take? char*? or void*? use which ever it happens to take, then follow the &quot;len&quot; directions.</p><p><span class="source-code"><span class="k1">int</span> len<span class="k2">;</span><span class="c">//what is this?...</span></span>Its the length of the mp3 data in bytes.</p><p>Something like this should work:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">unsigned</span> <span class="k1">int</span> len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/file_size_ex" target="_blank"><span class="a">file_size_ex</span></a><span class="k2">(</span><span class="s">"filename.ext"</span><span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> <span class="k3">*</span>data <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_551.html" target="_blank">malloc</a><span class="k2">(</span>len<span class="k2">)</span><span class="k2">;</span>
<span class="k1">if</span><span class="k2">(</span>data <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span> <span class="k2">{</span> DIE A HORRIBLE DEATH<span class="k3">!</span> <span class="k2">}</span>
</pre></div></div><p>

<span class="source-code">len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, x, mp3file<span class="k2">)</span><span class="k2">;</span><span class="c">//see above..</span></span><br />Should change that to:<br /><span class="source-code">len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, len, mp3file<span class="k2">)</span><span class="k2">;</span></span>pack_fread returns the actual number of bytes read, so if it didn&#39;t read all of &quot;len&quot; you only have that many...</p><div class="source-code snippet"><div class="inner"><pre>  mp3file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span>filename, F_READ<span class="k2">)</span><span class="k2">;</span><span class="c">//this is obviously something packfile    </span>
  <span class="c">//related.. what should filename be? the path in char data type? ex: "muu.mp3".??</span>
</pre></div></div><p>This <b><i>really</i></b> needs to go above the pack_fread. really. And the filename can be &quot;whatever.mp3&quot; or any C string.</p><p><span class="source-code">almp3_play_mp3stream<span class="k2">(</span>mp3, x, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span><span class="c">//trying to play it..</span></span><br />Almost:<br /><span class="source-code">almp3_play_mp3stream<span class="k2">(</span>mp3, len, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span></span>You have to tell it how much data there is to decode.</p><p>hth.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 14 May 2007 00:02:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Another attempt... i&#39;m really grateful for the help, and i&#39;m sorry i&#39;m learning this so slowly - -.</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> muu<span class="k2">(</span><span class="k1">char</span> filename<span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">using</span> <span class="k1">namespace</span> sfx::music<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>  </td></tr><tr><td class="number">5</td><td>  mp3file <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">6</td><td>  mp3 <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  </td></tr><tr><td class="number">8</td><td>  mp3file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span>filename, F_READ<span class="k2">)</span><span class="k2">;</span><span class="c">//opens a file?</span></td></tr><tr><td class="number">9</td><td>  </td></tr><tr><td class="number">10</td><td>  <span class="k1">unsigned</span> <span class="k1">int</span> len<span class="k2">;</span><span class="c">//unsigned?</span></td></tr><tr><td class="number">11</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/file_size_ex" target="_blank"><span class="a">file_size_ex</span></a><span class="k2">(</span>filename<span class="k2">)</span><span class="k2">;</span><span class="c">//gets the size of file?</span></td></tr><tr><td class="number">12</td><td>  </td></tr><tr><td class="number">13</td><td>  <span class="k1">char</span> <span class="k3">*</span>data <span class="k3">=</span> <span class="k2">(</span><span class="k1">char</span> <span class="k3">*</span><span class="k2">)</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_551.html" target="_blank">malloc</a> <span class="k2">(</span>len<span class="k2">)</span><span class="k2">;</span><span class="c">//malloc? googled it but didn't find any</span></td></tr><tr><td class="number">14</td><td>  <span class="c">//explanations i could understand..</span></td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td>  <span class="k1">if</span><span class="k2">(</span>data <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span> <span class="k2">{</span><a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"MOOO"</span><span class="k2">)</span><span class="k2">;</span><span class="k2">}</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>  </td></tr><tr><td class="number">18</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, len, mp3file<span class="k2">)</span><span class="k2">;</span><span class="c">//i don't really understand whats going on   </span></td></tr><tr><td class="number">19</td><td>  <span class="c">//here, first len got the value of "file size" and now what?</span></td></tr><tr><td class="number">20</td><td>  </td></tr><tr><td class="number">21</td><td>  mp3 <span class="k3">=</span> almp3_create_mp3<span class="k2">(</span>data, len<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">22</td><td>  </td></tr><tr><td class="number">23</td><td>  almp3_play_mp3<span class="k2">(</span>mp3, len, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span><span class="c">//mp3 = what to "decode" len = how much to </span></td></tr><tr><td class="number">24</td><td>  <span class="c">//"decode"?</span></td></tr><tr><td class="number">25</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
int almp3_poll_mp3(ALMP3_MP3 *mp3);<br />      This functions needs to be called in order to keep the ALMP3_MP3<br />      playing properly, since the mp3s need to be decoded at real time<br />      (either that, or to a huge memory buffer).
</p></div></div><p>I got the impression this was only used for streaming?</p><p>This didn&#39;t work, it didn&#39;t crash, i just didn&#39;t play. It&#39;s funny how you sometimes want it to crash... at least that gives you a clue about whats wrong.</p><p>Help appreciated!</p><p>off-topic: how come pixels colored &quot;0,0,1&quot; display the underlying active mediaplayer window... in windowed mode. i use vlc mediaplayer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Mon, 14 May 2007 11:03:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> muu<span class="k2">(</span><span class="k1">char</span> filename<span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">using</span> <span class="k1">namespace</span> sfx::music<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>  </td></tr><tr><td class="number">5</td><td>  mp3file <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">6</td><td>  mp3 <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  </td></tr><tr><td class="number">8</td><td>  mp3file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fopen" target="_blank"><span class="a">pack_fopen</span></a><span class="k2">(</span>filename, F_READ<span class="k2">)</span><span class="k2">;</span><span class="c">//opens a file?</span></td></tr><tr><td class="number">9</td><td>  <span class="c">//&gt; Yup.</span></td></tr><tr><td class="number">10</td><td>  </td></tr><tr><td class="number">11</td><td>  <span class="k1">unsigned</span> <span class="k1">int</span> len<span class="k2">;</span><span class="c">//unsigned?</span></td></tr><tr><td class="number">12</td><td>  <span class="c">//&gt; A "signed" integer uses one bit for the "sign" (if its negative or positive) meaning you only have 31 bits of space, or a number up to 2billion instead of 4billion (2GB versus 4GB).</span></td></tr><tr><td class="number">13</td><td>&#160;</td></tr><tr><td class="number">14</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/file_size_ex" target="_blank"><span class="a">file_size_ex</span></a><span class="k2">(</span>filename<span class="k2">)</span><span class="k2">;</span><span class="c">//gets the size of file?</span></td></tr><tr><td class="number">15</td><td>  <span class="c">//&gt; Yup.</span></td></tr><tr><td class="number">16</td><td>  </td></tr><tr><td class="number">17</td><td>  <span class="k1">char</span> <span class="k3">*</span>data <span class="k3">=</span> <span class="k2">(</span><span class="k1">char</span> <span class="k3">*</span><span class="k2">)</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_551.html" target="_blank">malloc</a> <span class="k2">(</span>len<span class="k2">)</span><span class="k2">;</span><span class="c">//malloc? googled it but didn't find any</span></td></tr><tr><td class="number">18</td><td>  <span class="c">//explanations i could understand..</span></td></tr><tr><td class="number">19</td><td>  <span class="c">//&gt; Ok, all computers have some ammount of "RAM", this is where programs are executed, and where programs store in use data, like loaded bitmaps, etc.</span></td></tr><tr><td class="number">20</td><td>  <span class="c">//&gt; malloc lets you get a "len" sized chunk of it to use however you want.</span></td></tr><tr><td class="number">21</td><td>&#160;</td></tr><tr><td class="number">22</td><td>  <span class="k1">if</span><span class="k2">(</span>data <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span> <span class="k2">{</span><a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"MOOO"</span><span class="k2">)</span><span class="k2">;</span><span class="k2">}</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>  <span class="c">//&gt; This is really a fatal error, using data after this check will cause memory corruption and a crash, or just a crash.</span></td></tr><tr><td class="number">24</td><td>  </td></tr><tr><td class="number">25</td><td>  len <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, len, mp3file<span class="k2">)</span><span class="k2">;</span><span class="c">//i don't really understand whats going on   </span></td></tr><tr><td class="number">26</td><td>  <span class="c">//here, first len got the value of "file size" and now what?</span></td></tr><tr><td class="number">27</td><td>  <span class="c">//&gt; Now that you have the "len" from file_size_ex, you pass it into fread so it attempts to read "len" bytes of data from the file (hopefully all of it).</span></td></tr><tr><td class="number">28</td><td>  <span class="c">//&gt; If fread _can't_ read "len" bytes, it returns the number of bytes it did read, or -1 on error. Which makes me think it should actually be this instead:</span></td></tr><tr><td class="number">29</td><td>  <span class="k1">long</span> newlen <span class="k3">=</span> <a href="http://www.allegro.cc/manual/pack_fread" target="_blank"><span class="a">pack_fread</span></a><span class="k2">(</span>data, len, mp3file<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">30</td><td>  <span class="k1">if</span><span class="k2">(</span>newlen <span class="k3">=</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">31</td><td>     <span class="c">// ERROR!</span></td></tr><tr><td class="number">32</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">33</td><td>  <span class="k1">else</span> <span class="k1">if</span><span class="k2">(</span>newlen <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">34</td><td>     <span class="c">// Probably an error as well.</span></td></tr><tr><td class="number">35</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">36</td><td>&#160;</td></tr><tr><td class="number">37</td><td>  len <span class="k3">=</span> newlen<span class="k2">;</span> <span class="c">//&gt; save the new length.</span></td></tr><tr><td class="number">38</td><td>&#160;</td></tr><tr><td class="number">39</td><td>  mp3 <span class="k3">=</span> almp3_create_mp3<span class="k2">(</span>data, len<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">40</td><td>  </td></tr><tr><td class="number">41</td><td>  almp3_play_mp3<span class="k2">(</span>mp3, len, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span><span class="c">//mp3 = what to "decode" len = how much to </span></td></tr><tr><td class="number">42</td><td>  <span class="c">//"decode"?</span></td></tr><tr><td class="number">43</td><td>  <span class="c">//&gt; Yup.</span></td></tr><tr><td class="number">44</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I got the impression this was only used for streaming?
</p></div></div><p>What I and the others mean by streaming is incrementally loading the data of the disk and passing it into the decoder.</p><p>I suppose you could call what almp3 does with non mp3stream&#39;s streaming, but best not, otherwise it can get confusing.</p><p> <b>almp3_poll_mp3</b> is used to tell almp3 to send some more data to the soundcard, a bit at a time, since you can&#39;t actually fit 40MB (decoded size of mp3 data) of sound data in most sound cards <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>If almp3_poll_mp3 didn&#39;t poll in this fashion you&#39;d need to decode all of the mp3 data into ram, and then place it into a SAMPLE, and play that. But that can eat up a lot of memory. So instead, it holds just the mp3 data, and when you poll, it decodes enough information to fill the buffer, and then queues it to play with allegro&#39;s sound system.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 14 May 2007 13:25:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Finally it worked!!.</p><p>You&#39;re my hero Thomas!! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />.</p><p>thanks to all the other nice people too!!<br />WOOOHOOO!!!!</p><p>but i still have questions ^^:<br />1: what is the sign used for? (unsigned signed stuff).</p><p>2: malloc lets me use the memory however i want eh,<br />so examples of not using how i want would be: int, char and stuff?<br />i kinda get it but at the same time not.. no, i don&#39;t think i get it at all..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Mon, 14 May 2007 15:33:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
1: what is the sign used for? (unsigned signed stuff).
</p></div></div><p>If an integer is unsigned, its range is from 0 through 2^32<br />If an integer is signed (which all are by default), the range is -2^31 through 2^31.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
2: malloc lets me use the memory however i want eh,
</p></div></div><p>It lets you get an arbitryily sized chunk of memory to use for just about anything. Dynamically allocating variables (int, char, arrays, structs, etc). Or whatever.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 14 May 2007 16:16:02 +0000</pubDate>
	</item>
</rss>
