Skip to content
Apr 14 10

Android: USB Connection driver on Windows 7 64bit

by peterdk

I wanted to use my G1 to debug my application. Somehow the offical USB Drivers for android devices do not install on windows 7 64 bit.

The solution for this problem was:

  1. Install PDANet: It installs the drivers correctly.
  2. (Optional) Go to device manager and update the driver of the android device: select the driver from the offical usb driver folder.
Apr 11 10

Android: JIT

by peterdk

Really happy to find out that Google themselves are working on a JIT compiler for android. With a bit of luck, older devices will experience 2-3x more speed. For my app Fretter, this will increate the possibility that it will also work on the upcoming low-end devices.

Its also good that it’s Google themselves. There were some rumours about a company that tried to sell it’s JIT technology to carriers, but that would only bring more fragmentation to the android platform.

A talk on Google I/O on this subject will be held around May, so you might expect to see something concrete by that date.

Apr 11 10

Android: Fretter

by peterdk

Currently I am also working on an Android App called Fretter. It’s an advanced chordfinder for guitar, banjo and ukulele. Advanced, because it support lots of tunings and even custom ones for all mentioned instruments and tries to find all voicings of a single chord. So when you select the C chord, it will give you around 12 possible valid options of how to play that Chord. Really cool.

How it works
It’s even more cool, because the chorddiagrams are not stored in the database but calculated on the fly. That means that I (thank God) didn’t entered all the variations in a database and simply retrieve them on user command. No, I wrote it that it knows what a major chord is, that it knows what a C note is and by combining this knowledge knows which notes a CMajor chord consists off.  It then is able to calculate all the valid chordfingerings for a given tuning.  The great thing about this, is that I can simply add chordtypes to it’s library, and it will be able to calculate them for every pitchclass and every instrument. That’s what computerprograms should be like: letting the computer do the hard work.

Profiling and optimizing
One of the really cool things during development was the optimization phase. I had some prior experience with profiling code because I had joined a simple programming competition where you needed to create a “zeeslagje” bot (Battleship game). Such a bot needed to run as fast as possible, so I tried a profiler for the first time.
In the case of Fretter, it’s obvious that the actual chordfinding needs to be as fast as possible. If it takes more than 1 or 2 seconds, the user will be frustrated because of the waiting (Well, I would definitely be). In that case I would need to use  a pre filled database with all the calculated results. I still would have the benefits of not having to enter all the chords manually, but users would still have to wait long when they select a non-standard tuning. I guess I would end up with a 10mb sqlite database, which is unacceptable.

It didn’t looked good the first time when I tried the completed chordfinder. It took 4-6 seconds to generate the chords. That’s a lot. Thankfully, VisualVM helped me pinpoint a lot of hotspots that could be optimized. It’s really cool to work on something, and then when you profile again, you get a 200% faster program! Some methods just needed a little work, and some methods needed to be rewritten into a smarter one. But the endresult was: from 4-6 seconds to 1-2. Really cool and now workable!

Same thing for the reverse chordfinder. It is definitely slower then the normal chordfinder, but that was to be expected. I think I improved the algorithm speed by around 250%. Now it takes I guess 4 seconds to complete. Very acceptable, since it’s something you will use more incidentally.

The real world
Today I have received my G1, and in a few days I will be able to test my app on a real android device. I am greatful to Google that they have limited their emulator to a certain bogomips. I expect the real device will perform with the same processing power as the emulator, but that certainly needs to be tested. Looking forward to it.

Availability and info
Fretter will be available on the appstore for €1.50,-. It supports guitar, 4-string and 5-string banjo and ukelele.
If you have another instrument you would like to have added, let me know. Custom tunings are supported.

Apr 5 10

VisualVM: A free profiler for Java

by peterdk

Currently I am developing for Android, and my code really uses a lot of processing power to do it’s job. A good profiler can really help with finding hotspots that you can eliminate or optimize.

On StackOverflow there are 2 good questions on the subject of profilers for Java. Most of the profilers however are quite user-unfriendly or expensive.  Fortunately one of the suggested profilers is really good: VisualVM

VisualVM is a standalone profiler for Java. It is also used integrated into NetBeans, but for those working in Eclipse, a simple plugin is available that let you launch the profiler. It is also part of the Java JDK, but that version is quite old, so you better download the most recent one from their website.

Only problem I have with VisualVM is it’s inability to defer launching of the app until profiling is started. Now I need to make my program sleep for 10 seconds while I start the CPU profiling. In NetBeans this is not the case. I guess it’s the benefit of integration. Other than this little downside, VisualVM works great! Really recommended.

Mar 26 10

Getting FOP to work with table-layout = auto

by peterdk

For my songbook design project I needed a XSL-FO Processor that could handle table-layout = auto.
XEP supports this perfectly, but FOP doesn’t and from the looks of it, it won’t in the foreseeable future.
Fortunately there is a patch available that adds very basic support for auto table-layout.

The patch won’t work with current trunk, it’s written for a revision from around June 2009. It’s not too old, but also not very new. I haven’t tried to find a revision that is more current then the revision it is targeted at, so it may well be possible that it works for let’s say a January 2010 revision. If you do, please leave a comment about your mileage.

You’ll need to check out revision 783305 from fop-trunk. Apply the patch and let ANT build it. Shouldn’t take long. The result is a working auto-table-layout capable FOP.

Limitation of the patch is that you can’t apply a margin-left to the table, or the containing block(s!). If you do that, the table reverts somehow to the original table layout system.So it only works if the table starts at the left side of the page, with no margin. That’s quite restricting.

To work around this, you can use the following ugly hack:

Wrap your table in another 2-column table. Set the width of the first empty column to the required margin, fill the second column with the table you need. The 2nd table will now auto-layout properly.

Mar 23 10

XSL-FO Processors Strugle

by peterdk

Currently I am working on a new service for songbook creation.

I originally worked on this project when CSR Delft, my christian student union, needed a new songbook with guitarsongs. (Think 300+ songs).
I don’t really know anymore how I got involved, but somehow I ended up creating a webdev environment in Ruby on Rails, using ChordPro as the main songlayout method. While we were at it, we needed to find a way to be able to control the rendering of the songs. Back then we opted for rendering HTML => PDF using the browsers print method and a PDF printer service. CSS has some interesting options for page-breaks like: page-break-after:always;  and things like keep-with-previous:always;. Using this, you can/could control the layout pretty good like: titles always need to be on the same page as the first verse.

Too bad these days only Opera really supported al these CSS commands (we´re talking 2006, though I doubt firefox implements them these days). So for the final design we used Opera to render the html that got send to the pdf printerservice.

We didn’t just only used chordpro, we also had database records for every song with title information, authors, bibleverses, etc. These data was used for creation of the songbook’s indexes and the copyright info on the bottom of every song.

It was really cool to do. I learned a lot about Ruby on Rails, back then a very new framework. And the whole creation of a platform that enabled people to work together on a big project was really cool.

3 years later,   the songbook needed a addition, and I had left Ruby on Rails for C# and .Net. I just discovered ASP.NET MVC, quite similar to Ruby on Rails, and decided to port over the project to C#. That was fun and the project now is sustainable.

But hey, this post was about XSl-FO. Suffice to say, I hadn’t heard or discovered XSL-FO back when we started and also with the second version of the platform I didn’t know any better way to auto-layout large PDF’s. And that wasn’t really a problem. It worked, the results look very good and the process was streamlined.

During volunteer work for a organization that needed a new website I discovered XSl-FO and for that matter XML. I was really excited about it. And frankly, I still am. It was just the right tool I needed to be able to try and create a more commercial version of the songbook project. I had the knowledge of the whole process, I could build a more generic platform and with XSL-FO the user wouldn’t need to use specialised Opera browsers and PDF printers, but the server could just handle the whole PDF generation.

The first results where quite promising, however Fop didn’t support auto-table-layout.
That’s more of a problem then you would expect. The chords above the lyrics need to be displayed exactly above the right part of the lyrics. Since we don’t want to use fixed-width-fonts, we couldn’t rely on spaces to position them. To get a good result you need to split every line up into a table, and put the chords in the first row and the lyrics in the second. The tablecells need to shrink until they fit the content exactly. This way you don’t even see that there is a table present.

So, with FOP not able to render the layout in any way, I looked to alternatives.
The best, and really the best, I found was XEP’s RenderX. They really implemented the standard in such a way that it just worked like you expected. Really professional, really good. And really expensive.
They charge like 350$ for a desktop version, and the server edition we would need would cost around 6000$ dollar.
Oops. As a student side-project that’s not funded in any way, that’s just too much.

So I looked to alternatives, and I found a bunch of other ones, but they all didn’t support the stuff we really needed: the tables. Or they just rendered basic layout totally garbaged. So I kept coming back to XEP.
Somehow in the process of optimizing my XSLT for XSl-FO I decided to see how FOP would render them, and to my surprise FOP did complete render them according to design. It didn’t made stupid errors like other non-XEP commercial FO Processors, it was just on par with XEP, except for the table-layout.
I almost decided to buy the desktop version of XEP and just forget about server-side PDF generation, until I came by a patch that was submitted to FOP’s bugzilla that added auto table layout. It had a bunch of limitations, but I really don’t need any advanced table-layout, just the auto-fitting of the cells. I tried it, and wow, it worked on one of my templates!

Unfortunately… it has a big bug: it doesn’t work when the block that contains the table or the table itself has a margin-left set.
And that’s quite a bummer, since I do need to layout the table somewhere on the page.

I decided that I am going to try to fund the development of that feature or put a bounty on it, so FOP can be usable for us on the server. It’s a nice way of giving something back to the opensource developers, and also making that feature available to other users.
If it works, we can use FOP on our server, without stupid licensing restrictions and costly software purchases.
And maybe we can even make some money! That would be great. 🙂

Check some example XSL-FO PDF output on our website: (or
All the PDF examples are rendered with FOP. , except for the first SongBook Example (Hemelsbreed template), that was rendered with XEP.


I found a way to get margin-left working. You just wrap the table in another table with 2 cells: the first cell you make as wide as you want your margin. The second cell you put in your auto-layout table. Auto Layout just keeps on working now.
So now: All examples on the site are rendered with FOP. Amazing!

Feb 20 10

Recording TV with Media Center (Windows 7) to a Networked Drive?

by peterdk

ell, you would think that Windows 7’s new MediaCenter would be up to the task of recording your TV to a network share/drive.Too bad, it looks like it’s just not possible.

I have a windows 2008 R2 server, and a Windows 7 machine with a TV card. Since my server has 2TB of storage, it would be nice to record directly to it’s networked drive. (I mounted it as Z:).

I tried the following:

1. Selecting it in Media Center Itself: Not working. Not available.

2. Editing the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\Recording , setting RecordPath to Z:\TV. Not working.

3. Editing the registry: setting RecordPath to \\server\TV. Not working.

4. Creating a Symlink (mklink \D) to Z:\TV and \\server\TV and setting that in the registry as RecordPath.

Currently I am out of options. I could ofcourse Install Windows7 on my server, but I have no license for that, and my windows 2008 r2 is free from dreamspark.

Are there people that are succesfully recording to a networked drive/storage?

Update 1
Some friendly soul at suggested using StarWind to make a iSCSI drive. It turns out that it only supports disk-images, so I can only use a pre-allocated 500GB file.

Multiple connections to a single iSCSI target with a NTFS filesystem can result in hosing your filesystem, so it aint a solution for my problem, since I need to acces the recordings also from my laptop drive, without having my media center pc on.

Microsoft oh Microsoft, why do you not just work with Mounted Network Drives…..

Feb 20 10

Solution to Msg.exe “Error 5 getting session names”

by peterdk

My Windows-Server 2008 R2 machine couldn’t msg my Windows 7 box due to Error 5 getting session names.
I found the solution here, in a comment made by Consoles. I reblog it so it can be found easier.

It turns out it has nothing to do with not being on the same domain or whatever. It is due to a setting related to Terminal Server.
That’s not to miraculous, since msg.exe is designed for messaging to terminal users.

So, changing a simple registry value and rebooting makes it all work again.

On the machine that you cannot message to:
Use regedit to navigate to: HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server
Then change the following value:

Name : AllowRemoteRPC
Value : 1

Reboot. Now it should work. 🙂

Feb 17 10

Solving Transfer Speed Drop Gigabit Network Windows 7/2008 Server R2

by peterdk

I bought a new Gigabit Switch this week, so I could use my fileserver as a fileserver…

My workstation runs Windows 7 and my Server runs currently Windows Server 2008 R2.

I happily saw a 3GB Iso file transferred with 80 Megabyte/Sec. But suddenly just before the end, the speed dropped to around 10 Megabyte/Sec. I suspected the switch in being the troublemaker, but the leds indicated that we still were on Gigabit instead of 100mbit. Running Iperf confirmed this.

So, it wasn’t the network, it was the server. Looking around the internet it turns out that most likely it was the diskspeed. That was strange, since I have a Raid5 array in the fileserver, and it surely could handle 50megabyte at least. Well, it turned out something was wrong with my write cache settings.

Somehow I had decided one day that it was a bad idea to have the write cache enabled for my raid5 array. Strange thing was that in the devicemanager it was enabled. But when I looked into the intel storage manager, it was actually disabled. Fortunately a simple option there made it enabled.

Now the transfer didn’t slow down at the end, and I now have full speed the whole time. (That is, when transferring large files, lots of small files will definitely be always slow).

Some info: The memory usage on the server grew and grew when the speed was high. Then it stopped growing (around 78% usage of 4 GB), and the speed collapsed. So that looked like some caching problem.

Feb 11 10

Eduroam Instellingen voor Open Universiteit voor Ubuntu 9.10

by peterdk
  1. Maak verbinding met het wireless Eduroam Netwerk
  2. selecteer ‘Dynamic WEP (802.1x)’
  3. Authentication : Protected EAP (PEAP)
  4. Anonymous Identity: leeg laten
  5. CA Certificate: we hebben het GTE CyberTrust Global Root certificate nodig. Dat is niet standaard opgenomen in Ubuntu.
    Je kan het hier downloaden, sla het op in een bereikbare map, en dan selecteren.
  6. Inner Authentication: MSCHAPv2
  7. Username:
  8. Password: studienetwachtwoord.

Dan zou hij het nu moeten doen. Het inloggen duurt even, kan een minuut ofzo bezig zijn. Hier in de Leidse Universiteitsbibliotheek werkt het als een zonnetje.