<?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>soledad penadés &#187; cpp</title>
	<atom:link href="http://soledadpenades.com/tag/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Sun, 29 Jan 2012 23:03:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Native startPreview failed on Nexus S? Check your preview size</title>
		<link>http://soledadpenades.com/2011/04/05/native-startpreview-failed-on-nexus-s-check-your-preview-size/</link>
		<comments>http://soledadpenades.com/2011/04/05/native-startpreview-failed-on-nexus-s-check-your-preview-size/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 20:58:21 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[native]]></category>
		<category><![CDATA[nerdstalgia]]></category>
		<category><![CDATA[nexus s]]></category>
		<category><![CDATA[surfaces]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3430</guid>
		<description><![CDATA[I got several error reports for Nerdstalgia from people using Nexus S. They were something akin to this: 04-05 12:22:50.371: DEBUG/SEC_Overlay(102): overlay_createOverlay:IN w=176 h=144 format=99 04-05 12:22:50.375: DEBUG/SEC_Overlay(102): src width, height are changed [w= 176, h= 144]-&#62;[w=176, h= 144] 04-05 12:22:50.375: INFO/SEC_Overlay(102): Opened video1/fd=253/obj=006e2468/shm=251/size=4096 04-05 12:22:50.375: DEBUG/SEC_Overlay(102): dst width, height have changed [w= 16, h= [...]]]></description>
			<content:encoded><![CDATA[<p>I got several error reports for <a href="https://market.android.com/details?id=es.s013.projects.ns">Nerdstalgia</a> from people using Nexus S. They were something akin to this:</p>
<div class="syhi_block"><code>04-05 12:22:50.371: DEBUG/SEC_Overlay(102): overlay_createOverlay:IN w=176 h=144 format=99<br />
04-05 12:22:50.375: DEBUG/SEC_Overlay(102): src width, height are changed [w= 176, h= 144]-&gt;[w=176, h= 144]<br />
04-05 12:22:50.375: INFO/SEC_Overlay(102): Opened video1/fd=253/obj=006e2468/shm=251/size=4096<br />
04-05 12:22:50.375: DEBUG/SEC_Overlay(102): dst width, height have changed [w= 16, h= 1] -&gt; [w=16, h= 16]<br />
04-05 12:22:50.375: INFO/SEC_Overlay(102): Postponing Stream Enable/1/0<br />
04-05 12:22:50.375: ERROR/v4l2_utils(75): Error = Invalid argument from stream on<br />
04-05 12:22:50.375: ERROR/SEC_Overlay(75): Stream Enable Failed!/-1<br />
04-05 12:22:50.375: ERROR/CameraHardwareSec(75): ERR(virtual android::status_t android::CameraHardwareSec::setOverlay(const android::sp&lt;android::Overlay&gt;&amp;))::(mOverlay-&gt;setCrop(0, 0, 176, 144) fail<br />
04-05 12:22:50.375: ERROR/CameraService(75): mHardware-&gt;setOverlay() failed with status -2147483648<br />
04-05 12:22:50.378: DEBUG/AndroidRuntime(3875): Shutting down VM<br />
04-05 12:22:50.378: WARN/dalvikvm(3875): threadid=1: thread exiting with uncaught exception (group=0x40015560)<br />
04-05 12:22:50.378: ERROR/AndroidRuntime(3875): FATAL EXCEPTION: main<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.lang.RuntimeException: startPreview failed<br />
&nbsp; &nbsp; &nbsp; &nbsp; at android.hardware.Camera.startPreview(Native Method)<br />
&nbsp; &nbsp; &nbsp; &nbsp; (and here starts my code)</code></div>
<p>So it was failing well outside my <em>domains</em>&#8211;in a <strong>native</strong> method! There wasn&#8217;t even a line number to have a look at. But was it because of something I did? I thought maybe it was because I wasn&#8217;t synchronizing things properly&#8211;so I went to make sure everything was properly initialised, nothing was done before it was due&#8230; and still it crashed.</p>
<p>Then I paid even more close attention and I noticed that the difference between &#8216;crash&#8217; and &#8216;no crash&#8217; was that before it crashed it always output a <em>mHardware-&gt;setOverlay() failed with status -2147483648</em> message</p>
<p>So since I couldn&#8217;t find any solution or pointer anywhere, I decided to have a look at the native code&#8211;that way, I could at least find out what was that <em>setOverlay() failed</em> message about.</p>
<p>It took me a bit to navigate the code, since there are lots of messages and calls going back and forward between Samsung&#8217;s specific code and Android&#8217;s core, and I&#8217;m not sure I have totally understood how it works, but it <em>seems</em> that the firmware for the Nexus S (alias <em>Samsung Crespo</em>) requires that</p>
<ul>
<li>the preview surface width is a multiple of 8 (and at least 8), and</li>
<li>the preview surface height is at least 16</li>
</ul>
<p>That is defined in the <a href="http://android.git.kernel.org/?p=device/samsung/crespo.git;a=blob;f=liboverlay/overlay.cpp;h=6220106fc8cbeb313c4aa5d5328b751abe6c9613;hb=HEAD#l984">check_fimc_dst_constraints</a> function in <a href="http://android.git.kernel.org/?p=device/samsung/crespo.git;a=blob;f=liboverlay/overlay.cpp;h=6220106fc8cbeb313c4aa5d5328b751abe6c9613;hb=HEAD">mydroid/device/samsung/crespo/liboverlay/overlay.cpp</a></p>
<p>I changed the preview size to 8&#215;16, and now the app doesn&#8217;t crash on the Nexus S, although there&#8217;s an unfortunate side effect: the preview is <em>more</em> visible than it was before &#8211;yes, it was visible. It was a 1&#215;1 sized preview, and that&#8217;s why it was failing on the Nexus S (and probably any other setup with that kind of surface size restriction). Now I need to find a way to hide it&#8230; oh wait, I found it! The answer, on the following post :P</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3430&amp;md5=bff06ccba44570817597095a68a457a7" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2011/04/05/native-startpreview-failed-on-nexus-s-check-your-preview-size/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sorollet V2, out NOW!</title>
		<link>http://soledadpenades.com/2010/04/07/sorollet-v2-out-now/</link>
		<comments>http://soledadpenades.com/2010/04/07/sorollet-v2-out-now/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 22:38:37 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[real time]]></category>
		<category><![CDATA[renoise]]></category>
		<category><![CDATA[sorollet]]></category>
		<category><![CDATA[sound synthesis]]></category>
		<category><![CDATA[vsti]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2495</guid>
		<description><![CDATA[Your wishes have been fulfilled &#8211; Sorollet V2 it&#8217;s finally out, for you to enjoy (or suffer, depends on your tastes, but hopefully you&#8217;ll like it). The project comes with the song that I released for the Breakpoint&#8217;s 2010 newschool exe music compo, Bizarría sorollosa &#8211; which can be listened to here too: Bizarría sorollosa [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://soledadpenades.com/imgs/sorolletv2.jpg" alt="Sorollet V2" /></p>
<p>Your wishes have been fulfilled &#8211; <a href="http://soledadpenades.com/projects/sorollet/">Sorollet V2</a> it&#8217;s finally out, for you to enjoy (or suffer, depends on your tastes, but hopefully you&#8217;ll like it).</p>
<p>The project comes with the song that I released for the Breakpoint&#8217;s 2010 newschool exe music compo, <em>Bizarría sorollosa</em> &#8211; which can be listened to here too:</p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fsupersole%2Fbizarria-sorollosa"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fsupersole%2Fbizarria-sorollosa" type="application/x-shockwave-flash" width="100%"></embed></object>  <span><a href="http://soundcloud.com/supersole/bizarria-sorollosa">Bizarría sorollosa</a> by <a href="http://soundcloud.com/supersole">supersole</a></span></p>
<p>If you&#8217;re running Windows, you can also download and listen to the song running <em>real-time</em> in your computer, by downloading the <a href="http://xplsv.com/prods/music/sole/exe_music/supersole_-_bizarria_sorollosa.zip">compo entry</a> (the zip is huge because it also includes an .ogg rendering of the song; the .exe is just less than 12kb). If you want to listen to it real-time but are not running Windows please <a href="http://github.com/sole/sorollet">download the source</a> and build it yourself &#8212; it should be only a matter of typing <em>scons</em> on a terminal, or pressing the <em>build</em> button if using Netbeans like me.</p>
<p>My entry itself ranked last, which was a bit of a disappointment, although there were fantastic entries on the compo which totally <em>deserved</em> to rank superhigher than me. But more on that on a future post&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/04/07/sorollet-v2-out-now/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Breakpoint demolog, days 56-57: wrapping up</title>
		<link>http://soledadpenades.com/2010/03/31/breakpoint-demolog-days-56-57-wrapping-up/</link>
		<comments>http://soledadpenades.com/2010/03/31/breakpoint-demolog-days-56-57-wrapping-up/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 09:29:33 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[sound synthesis]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2480</guid>
		<description><![CDATA[I managed to make a bit of sense out of the little mess my song was initially. It&#8217;s still rather unconventional, and it happened to me that the first time you listen to it, it sounds very weird. The second time you begin to like its oddities, the third time you love them. And so [...]]]></description>
			<content:encoded><![CDATA[<p>I managed to make a bit of sense out of the little mess my song was initially. It&#8217;s still rather unconventional, and it happened to me that the first time you listen to it, it sounds very weird. The second time you begin to like its oddities, the third time you love them. And so on. Maybe not the best thing for a compo &#8211;where all it&#8217;s about the &#8216;wow factor&#8217; and the &#8216;love at first sight&#8217; effect&#8211; but we&#8217;ll see :-)</p>
<p>I&#8217;m going to prepare the zip with the exe, the .ogg dump, readme.txt and all that so that I won&#8217;t do it in a hurry, in the partyplace.</p>
<p>After all I have to think about a way of having the synth ready for 32k exe music compos if need be, but specially get it working again for embedding it into a VSTi, using the same code in both places. So that means I&#8217;ll examine thoroughly iq&#8217;s framework and pick only the pieces I need. Sorry for ripping open your framework, iq, but it&#8217;s in the interests of <em>science</em>! Hopefully I won&#8217;t end up with Frankenstein-esque code&#8230;</p>
<p>The final step will be to upload the code and all that to my <a href="http://github.com/sole">github repo</a> and release it for general enjoyment (heh). I might also provide a linux build of the VSTi but after <del datetime="2010-03-31T09:03:12+00:00">using</del> fighting with Visual C++ for a few weeks I don&#8217;t really feel like providing a build of anything for Windows. On Mac&#8230; I have gcc installed in my PowerBook, so once I manage to get this code compiled with gcc again it shouldn&#8217;t be too hard to compile it for Mac OS X. But I can&#8217;t promise anything; computers are unpredictable, and computers+code that one didn&#8217;t write (i.e. the VST SDK) are even worse ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/03/31/breakpoint-demolog-days-56-57-wrapping-up/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Breakpoint demolog, days 51-55: fixing framework bugs, and composing a song too</title>
		<link>http://soledadpenades.com/2010/03/30/breakpoint-demolog-days-51-55-fixing-framework-bugs-and-composing-a-song-too/</link>
		<comments>http://soledadpenades.com/2010/03/30/breakpoint-demolog-days-51-55-fixing-framework-bugs-and-composing-a-song-too/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 00:15:41 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[assembler]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[sound synthesis]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2476</guid>
		<description><![CDATA[Thanks to a series of very fortunate findings, I happened to fix the two bugs that made my synths sound horrible when running on top of iq&#8217;s 64k framework, and even worse, in Release mode. There were two problems, firstly with the noise functions and second with the rounding to integer functions. The framework has [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to a series of very fortunate findings, I happened to fix the two bugs that made my synths sound horrible when running on top of iq&#8217;s 64k framework, and even worse, in Release mode. There were two problems, firstly with the noise functions and second with the rounding to integer functions.</p>
<p>The framework has several noise functions, intended to be fast, very fast. But for some reason they also generate NaN values from time to time (1.#QNAN00 in Visual Studio&#8217;s jargon), and this was making things go crazy whenever one of those values appeared (read: distorted). I solved this using another noise function, from <a href="http://code4k.blogspot.com/2009/10/random-float-number-using-x86-asm-code.html#more">this article</a> that dario_phong mentioned <a href="http://soledadpenades.com/2010/02/11/breakpoint-demolog-day-9/#comment-53869">a few weeks ago</a>:</p>
<div class="syhi_block"><code>seed <span style="color: #000040;">*</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">16807</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span><span style="color: #008000;">&#41;</span>seed<span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span><span style="color: #008000;">&#41;</span><span style="color: #208080;">0x80000000</span><span style="color: #008080;">;</span></code></div>
<p>This one doesn&#8217;t produce any NaN values and seems reasonably fast.</p>
<p>Funnily, the same article gave me somehow a hint as to why the synth sounded awful when in release. It seems the framework uses the /QIfist compiler option in release and that produced a very rough float to int conversion, hence the cranky sound when in release.<br />
But if I removed the option, the compiler complained about a missing _ftol function. So I solved my problem in a slightly slow and cumbersome, and probably not very elegant way, which was to add a new function using the assembler implementation provided in the same article:</p>
<div class="syhi_block"><code><span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">long</span> floorSSE<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">double</span> x<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; __asm cvttsd2si eax,x<br />
<span style="color: #008000;">&#125;</span></code></div>
<p>It actually is in my MathUtils class, as MathUtils::floor. So everywhere that was a construct like this:</p>
<div class="syhi_block"><code><span style="color: #0000ff;">int</span> v <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#40;</span>floatVariable<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></code></div>
<p>I changed it into </p>
<div class="syhi_block"><code><span style="color: #0000ff;">int</span> v <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #008000;">&#41;</span> Math<span style="color: #008080;">::</span><span style="color: #0000dd;">floor</span><span style="color: #008000;">&#40;</span>floatVariable<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></code></div>
<p>I am unsure as to whether this is a good idea or not, but the synth sounds properly now and the performance doesn&#8217;t seem to have increased or decreased, so I assume that at least is OK. </p>
<p>The only minor issue is that the assembler instruction belongs to the <a href="http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions">SSE</a> instruction set so old processors (<1999) might not have it, although they probably won't be able to run the rest of the code anyway (performance wise speaking, it is a bit of an unoptimised resource hog :P). Also, I haven't tried to compile these last changes with gcc, so I don't know whether it will be OK with this inline assembler syntax. I think it should be fine and won't ask me to use the AT&amp;T syntax instead, which I find pretty horrible by the way. But there's something for sure, I'll have to look for an alternative if I want to compile this in my PowerPC powered PowerBook :)</p>
<p>On the composing side, I've got about 2 minutes of raw, unpolished and unadorned song. It's turning out to be quite weird and a quite bit "in my style", so if there are any <a href="http://supersole.net/">supersole</a> fans in the audience they might easily recognise the song even without looking at the screen at all, haha!</p>
<p>I&#8217;d love to finish the song tomorrow, fingers crossed!</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/03/30/breakpoint-demolog-days-51-55-fixing-framework-bugs-and-composing-a-song-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Breakpoint demolog, days 38-50: change of plans</title>
		<link>http://soledadpenades.com/2010/03/25/breakpoint-demolog-days-38-50-change-of-plans/</link>
		<comments>http://soledadpenades.com/2010/03/25/breakpoint-demolog-days-38-50-change-of-plans/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 09:32:57 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[64k intro]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[executable music]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sound synthesis]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2472</guid>
		<description><![CDATA[I&#8217;m quite sure most of you might have thought that I had either a) silently abandoned my goal or that b) I was just too busy to post here. I can tell you the answer is b) :-D We went to Spain for a few days (hence the plane meditation title of a previous post) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m quite sure most of you might have thought that I had either a) silently abandoned my goal or that b) I was just too busy to post here. I can tell you the answer is b) :-D</p>
<p>We went to Spain for a few days (hence the <a href="http://soledadpenades.com/2010/03/11/breakpoint-demolog-day-36-plane-meditation/">plane meditation</a> title of a previous post) to visit family and have a taste of that <em>hell-in-Earth</em> celebration that are Fallas, and I could keep productively working on the demo for the first few days. After that, things just stopped going so smoothly &#8211;or I was too distracted&#8211; and I lose a lot of time with trying to compose a song which could work for a demo, with my synth. Unsuccessfully.</p>
<p>After a fruitful conversation with <a href="http://mrdoob.com">mrdoob</a>, I understood that I couldn&#8217;t have the cake and eat it too, so I decided to aim for a <em>cupcake</em> instead. Therefore I&#8217;ll skip the visual part and focus on creating a <strong>song for the executable music compo</strong>.</p>
<p>Which on one hand is a pity since I really wanted to fill that gorgeous huge screen with my stuff, but since there are always a TON of demos I guess it&#8217;s better to not to add another half-finished demo to the competition.</p>
<p>With that in mind I began to make my code fit in 32kb. I tried first to do things from scratch and learn in a few hours how to make that waveOut Windows API work. At which I failed miserably. And I didn&#8217;t want to install the DirectX framework (and going through the genuine windows validation thing meanwhile) just for this, if only because I fear it would ruin my Windows installation.</p>
<p>Hours later I remembered that <em>His 4k/64k Majesty</em> iq had helped me to fit my previous intro into his 64k framework, and the code is <a href="http://github.com/sole/demoscene/tree/master/releases/xplsv/to_the_beat/win_port/">out there</a>. And amazingly, it compiled without a complaint from Visual Studio 2008! (unlike the 64k framework sources that are in his own website).</p>
<p>So I spent yesterday changing the code to use pure vectors instead of std::vector, devising alternative data structures to avoid using std::map and things like that, since the 64k framework doesn&#8217;t use the standard c++ memory allocation, and everything with templates just won&#8217;t compile. And since my previous code assumed that I would load the Song.xml directly, I also wrote a new importer from Song.xrns to Song.h, using python, so that the song data is extracted and converted into a long array of floats, prior to compiling.</p>
<p>Now I have an executable that when compressed only uses 8-9kb, including a semi-elaborated song, so there&#8217;s plenty of space for more elaboration if need be. Unfortunately the sound isn&#8217;t exactly what comes out from Renoise &#8211;the code being more or less the same&#8211;. It&#8217;s got something to do with the implementation of math functions that the framework uses, since we had a similar issue when we ported the intro to Windows: things would sound weird and distorted in Windows only. I&#8217;m tracking things down by using simple sounds and testing them separately, changing one parameter at a time. It&#8217;s a bit slow but it&#8217;s the only way of tackling this.</p>
<p>Wish me luck! :D</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/03/25/breakpoint-demolog-days-38-50-change-of-plans/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

