<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Audio Streams in C++</title>
		<link>http://www.allegro.cc/forums/view/587240</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 28 Aug 2006 16:51:51 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I posted a question about audio streams once before. I subsequently found out that the reason my code wasn&#39;t compiling was because I was using C++ and not C. The type exchanging stuff (IMHO) is better in C. Now, how would I go about doing audio streams in C++? Any thoughts?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Sat, 26 Aug 2006 17:06:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
the reason my code wasn&#39;t compiling was because I was using C++ and not C. The type exchanging stuff (IMHO) is better in C. Now, how would I go about doing audio streams in C++?
</p></div></div><p>
Post source.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 26 Aug 2006 17:24:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/AUDIOSTREAM" target="_blank"><span class="a">AUDIOSTREAM</span></a> <span class="k3">*</span>stream<span class="k2">;</span>
...
stream <span class="k3">=</span> <a href="http://www.allegro.cc/manual/play_audio_stream" target="_blank"><span class="a">play_audio_stream</span></a><span class="k2">(</span>BUFFER_SIZE, <span class="n">8</span>, FALSE, SAMPLING_FREQUENCY, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span>
...
...
<span class="k1">unsigned</span> <span class="k1">char</span> <span class="k3">*</span>buffer <span class="k3">=</span> <span class="k2">(</span><span class="k1">unsigned</span> <span class="k1">char</span> <span class="k3">*</span><span class="k2">)</span><a href="http://www.allegro.cc/manual/get_audio_stream_buffer" target="_blank"><span class="a">get_audio_stream_buffer</span></a><span class="k2">(</span>stream<span class="k2">)</span><span class="k2">;</span>
...
</pre></div></div><p>
if you use 8 bit sound and
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/AUDIOSTREAM" target="_blank"><span class="a">AUDIOSTREAM</span></a> <span class="k3">*</span>stream<span class="k2">;</span>
...
stream <span class="k3">=</span> <a href="http://www.allegro.cc/manual/play_audio_stream" target="_blank"><span class="a">play_audio_stream</span></a><span class="k2">(</span>BUFFER_SIZE, <span class="n">16</span>, FALSE, SAMPLING_FREQUENCY, <span class="n">255</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span>
...
...
<span class="k1">unsigned</span> <span class="k1">short</span> <span class="k3">*</span>buffer <span class="k3">=</span> <span class="k2">(</span><span class="k1">unsigned</span> <span class="k1">short</span> <span class="k3">*</span><span class="k2">)</span><a href="http://www.allegro.cc/manual/get_audio_stream_buffer" target="_blank"><span class="a">get_audio_stream_buffer</span></a><span class="k2">(</span>stream<span class="k2">)</span><span class="k2">;</span>
...
</pre></div></div><p>
if you use 16 bit sound.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 26 Aug 2006 17:25:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Evert, I really don&#39;t think that&#39;s necessary as I hardly have any and I&#39;m just looking for the framework.</p><p>EDIT:<br />Thank you, miran!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Sat, 26 Aug 2006 17:56:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If your source is giving you problems `because you&#39;re using C++, not C&#39;, then you should post said source so that we can say what you should change or add to make it work. Otherwise it wouldn&#39;t be really useful to post random thoughts about it, would it? <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 26 Aug 2006 20:06:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Btw, &quot;the type exchanging stuff&quot; is called typecasting or casting for short. C is a weakly typed language (not really, but that&#39;s not the point), because when you have <tt>void*</tt> it means you have a pointer to anything. C++ on the other hand is strongly typed which means that <tt>void*</tt> shouldn&#39;t even be valid code (it&#39;s valid as a special case for backwards compatibility with C). In C++ when you have a pointer to something (void* is like a pointer to nothing in C++) and want to use it as if it was a pointer to something else, you need to cast it to that something else type. For your needs (using a C library that uses void pointers in C++) a simple C-style cast is good enough. A C style cast is when you write the type you want to cast to in front of the variable you want to cast in parenthesis. For example to cast a variable called x of type float to type int, you would write <tt>(int)x</tt>, and when you want to cast a variable called buffer of type void* to type int*, you type <tt>(int*)buffer</tt>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 26 Aug 2006 20:36:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>(never mind (grumble, grumble))
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 28 Aug 2006 01:10:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So what&#39;s C++ typecasting like?<br />EDIT: Oh, wait. What you showed me <i>is</i> C++ typecasting, yeah?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Mon, 28 Aug 2006 16:45:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.cplusplus.com/doc/language/tutorial/typecasting.html">It looks like this</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 28 Aug 2006 16:51:51 +0000</pubDate>
	</item>
</rss>
