<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>audio | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/audio/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Thu, 22 Dec 2022 20:21:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>audio | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>How to fix sound on the Raspberry Pi</title>
		<link>https://learncgames.com/how-to-fix-sound-on-the-raspberry-pi/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-fix-sound-on-the-raspberry-pi</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 22 Dec 2022 00:00:55 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[audio]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3152</guid>

					<description><![CDATA[<p>First I modded the code that inits sound to this: int success=Mix_OpenAudio(44000, AUDIO_F32LSB, 2, 8192); if (success==-1 ) { LogError2(&#34;InitSetup failed to init audio because %s&#34;,Mix_GetError()); } That extra call to Mix_GetError() returns a string saying what the problem is and in this case I got ALSA : Couldn&#8217;t find any hardware audio formats. ALSA [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-fix-sound-on-the-raspberry-pi/">How to fix sound on the Raspberry Pi</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:36,&quot;href&quot;:&quot;https:\/\/en.wikipedia.org\/wiki\/Advanced_Linux_Sound_Architecture&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260201212308\/https:\/\/en.wikipedia.org\/wiki\/Advanced_Linux_Sound_Architecture&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:14:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 03:48:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 17:07:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-01 04:10:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 17:18:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 23:28:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-20 00:40:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 16:57:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 00:31:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-14 12:03:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 04:37:32&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 04:37:32&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:37,&quot;href&quot;:&quot;http:\/\/blog.scphillips.com\/posts\/2013\/01\/sound-configuration-on-raspberry-pi-with-alsa&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251006101907\/http:\/\/blog.scphillips.com\/posts\/2013\/01\/sound-configuration-on-raspberry-pi-with-alsa\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:14:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 03:48:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 17:07:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-01 04:10:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 17:18:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 23:28:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-20 00:40:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 16:57:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 00:31:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-14 12:03:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 04:37:36&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 04:37:36&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft size-full wp-image-3154" src="https://learncgames.com/wp-content/uploads/2022/12/raspi-config.png" alt="Raspi-config for Raspberry Pi" width="656" height="448" srcset="https://learncgames.com/wp-content/uploads/2022/12/raspi-config.png 656w, https://learncgames.com/wp-content/uploads/2022/12/raspi-config-300x205.png 300w" sizes="(max-width: 656px) 100vw, 656px" />First I modded the code that inits sound to this:</p>
<pre><code class="language-c" data-line="">	int success=Mix_OpenAudio(44000, AUDIO_F32LSB, 2, 8192);
	if (success==-1 ) {

		LogError2(&quot;InitSetup failed to init audio because %s&quot;,Mix_GetError());
	}</code></pre>
<p>That extra call to Mix_GetError() returns a string saying what the problem is and in this case I got</p>
<p>ALSA : Couldn&#8217;t find any hardware audio formats.</p>
<p>ALSA is short for Advanced Linux Sound Architecture and <a title="Link to Wikipedia about ALSA" href="https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture" target="_blank" rel="noopener">Wikipedi</a>a is very informative. It certainly put some perspective on it.</p>
<p>&nbsp;</p>
<p>Also I found <a title="Link to article on configuring sound for the Raspberry Pi" href="http://blog.scphillips.com/posts/2013/01/sound-configuration-on-raspberry-pi-with-alsa/" target="_blank" rel="noopener">this article</a> adds a lot more information.  What fixed it though was doing</p>
<pre>sudo raspi-config</pre>
<p>Then pressing enter on 1. System Options and then S2 Audio and selecting the headphones option. Simple as that. After that asteroids played the sounds as expected.</p>
<p>There&#8217;s a lesson here which is to use the functions provided, in this case calling the Mix_GetError() function to show errors.  I added it into the PlayASound() call to see why it was failing, and it stopped doing it, i.e. it worked with lots of explosions on screen. I suspect it was the sound configuration hadn&#8217;t been properly set which is an issue with Raspberry Pis apparently.</p>The post <a href="https://learncgames.com/how-to-fix-sound-on-the-raspberry-pi/">How to fix sound on the Raspberry Pi</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3152</post-id>	</item>
	</channel>
</rss>
