HOWTO display Chinese in Creative ZenMicro using Amarok

Desktop, Gentoo June 25th, 2007

Creative is less creative in building software, that is why so many users are asking how to display Chinese character in Creative ZenMicro using either Windows Media Player or Creative MediaSource. But this company really build solid hardware, and I could resist the temptation of ZenMicro RED 5G (refurbished) 49$ with free shipping from Outpost. So I got another one and found the same annoyance happened to Amarok 1.4.6. Amarok is open sourced, that leave the door open for me to dig into the problem.

According to the solution,

1. Go to your Control Panel
2. Select Regional and Language Options
3. Go to the Advanced tab
4. See the Language for Non-Unicode programs
5. Select Chinese PRC
6. The system will prompt you to restart.

it looks like the Creative ZenMicro uses the GB2312 code page to display Chinese. So the first move to solve this problem is to convert the ID3 tag to GB2312 before the track is downloaded to the device:

// $TOPSRC/amarok/src/mediadevice/njb/track.cpp
    QTextCodec *codec = QTextCodec::codecFromName(“GB2312″);
    // orig: NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( m_bundle.title().utf8() ) );
    NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( codec->fromUnicode(m_bundle.title()) ) );

Good news is the old messy code disappeared, the bad news is we have new messy code. It is worthy understanding how the device stores the information and how libnjb is designed for the developers. So I sent an email to the libnjb developers, and got the reply from Linus Walleij in a short period:

The Zen Micro like all Zens use UCS2 as internal representation. However
the libnjb library uses UTF-8 as input/output format if requested, so it
shouldn’t matter.
… …
It is however very important that the client calls the libnjb function
NJB_Set_Unicode() with the UTF-8 flag, in order for it to work. Else
libnjb will assume encoding is in ISO8859-1 and drop a lot of information
by making approximations and mangling chinese totally. The call should be
made before any other initialization

I combed the Amarok’s source code, and found the bug, Amarok’s developers setup the Unicode after call the NJB_Discover, it may be too late. Once we move that function call earlier, it works. You can download this patch here, and if you are a Gentoo user, here is the ebuild. Check out this HOWTO if you are not clear how to setup the portage overlay.

Further reading showed that the problem is caused by the transport layer from Creative which is built without Unicode support, that drops the ball, and Windows user could do nothing but request Creative to rebuild the code with Unicode; or they can use libnjb derived application, such as NomadSync(not tested yet).

Update Some Chinese characters are missing without a hint, like 一, 言, no idea which cause the bug. If you are using Creative ZenMicro, could you help to test it in Windows and leave a comment here?

Yet another cube

Web June 22nd, 2007

It took me a little while to hack the dojox.gfx3d framework. Though there is tons of work to be done, I need to mask the unexpected functions, clean the code, add more comments, and explore more advanced features like lightings, textures, and we might refactor the code later, I still feel quite excited to release the sneak preview of dojox.gfx3d: Yet another cube.

Yet another cube



This is the test case run in Firefox 2.0.0.4 on my Gentoo box, it is 100% sure not working in MSIE. You can grab the snapshot from here.

Upgrade to 2.6.20

Gentoo June 21st, 2007

After several months’ waiting, kernel 2.6.20 with suspend2 patch finally come into x86 branch. The upgrade is quite smooth except some bumps.

According to the experience of building the poor man’s wireless network, some exotic errors may happen if the .config is copied direct from kernel 2.6.18, so I went though all the configuration using make menuconfig. Read the rest of this entry »

Before we code, we document

Web June 20th, 2007

Before rolling-up sleeves to make my hands dirty, I would like to document each step we take: the design philosophy, implementation challenge, refactory to keep the community updated what I am doing in this summer.

Here is the draft of Introduction to dojox.gfx3d library, which will be eventually merged into the API document, and become much less verbose. Now it is wordy since I am trying to explain the detailed information about what is under the hood and why we take the specific approach to cope with this problem.

For best user-experience, please download PDF or DVI; or you may read it online here, if you are using Firefox 1.5 or later with MathML fonts installed, here is another online version; last but not the least, if you would like to contribute to this document, and send feedback for us, here is the LaTEX source.

Though I am using LaTeX, I am not “old school” enough, I am using Kile to edit and build the LaTex. And I still could not figure out how to use latex2html to generate one page HTML or put all the footnotes in one page when using TeX4ht, if you have any clue to do so, please leave me a message in the comments. Thanks.

Productivity vs. Performance

Development June 18th, 2007

Software developers usually struggle between productivity and performance, in another word: the algorithm representation and implementation. The most efficient high-level language to express ideas is pseudo code, you never need to worry about the outbound access or resource leak, you say “sort it”, the job is done regardless the implementation, just like God. In the business world, this alternative is usually Microsoft PowerPoint.

On the other end, low level languages, they are so close to the hardware, that the developers can take full advantage of the architecture, but usually it prevents the developers to express ideas more succinctly. For example, all Assembles and C. In between, we have all other “high-level” languages, they are most likely the trade-off between the two extremes, like Java, C++, Python etc.

This challenge is also posed in the parallel computing: there are different levels of parallelism: grid, node, SMP, symmetric mutli-core, heterogeneous multi-core, co-processor, ILP. It is tremendous burden for the developers to handle the complexity, no wonder that two HPCS language, Fortress and X10 choose Java as the foundation.

But hold on, do we really need a new language? Human being are not hard-wired, we intend to think things sequentially. Unless the new languages are designed with built-in parallelism as HDL, the developers may still program in sequential manner, with vector unit for SIMD parallelism and thread support for SPMD. Library may achieve the same goal. X10’s GALS(globally asynchronous, locally synchronous) is possible implemented by the asynchronous framework, for example asio in boost. IMHO, it is not wise to offload so much burden to the language itself, the computing environment are changing and people are lazy and reluctant to learn yet another new language.