Thursday, January 30, 2014

To a Man With Only a Hammer In His Toolkit Every Problem IS a Nail

Prelude:
Years ago my father read a magazine and stumbled upon a title that he couldn't comprehend. He passed it to my mother that remarked that although she recognized some characters, the whole things are incomprehensible. Then my mother passed it to my sister who immediately read it aloud. That brought laughter from both my parents.
The title was of Latin alphabets, stylized to make it looks like Chinese characters. Due to the presentation, my parents try to read it in Chinese. On the other hand my sister, lacking the skill in Chinese, read in the only way she knows.
There are 2 things I learned from that episode:
  1. KISS Principle.
  2. As the title said.
In above episode, the one with single tool won the round. But as problem complexity escalate, can the hammer wielder maintains the lead?
To contemplate: One who makes swift decisions is often admired / appreciated. However, how many people try to consider how each decision was made? Was it after careful contemplation; considering alternatives, implications, feasibility, oppositions|supports, cost|benefit of each alternative? Or was it simply because he only saw a nail and whacked at it as usual?

The Key to Good Humor is Knowledge

First a disclaimer: I'm using the word knowledge very loosely here. I'm not limiting the definition to text book stuff, but also local slang, culture (name of food, peculiarity of dialect / accent, etc) and so on -- every useless bits you can memorize. Info may be a better term, but I prefer knowledge.

My brother doesn't like to socialize with the bookworms because "they tell lame jokes". True, to have someone explaining every joke is kinda lame. However, if one's level of knowledge / exposure is on par with the surroundings,  jokes would have more hits than misses. Either learn or leave.
Why do crude-jokes (especially sex-related) have the highest rate of delivery? Because the knowledge are inherent (well, unless one has very strict parents and is a very obedient  child). That's also the reason why slapstick works like a charm. No brainer.
As jokes become more subtle, more background knowledge would be demanded. For example, to appreciate a joke in a series, the audience had to watched the previous episode, understand the character and so on ... read more here - I can't put it in better words.
Straying from the topic for a bit - while looking for the link above, I stumbled upon this. Published over a year later but has a Copyright?

Final Words

I'm not advocating the hyper-active knowledge gathering. Sometimes extra knowledge would only serve as hindrance rather than helpful. It may gets in the way of applying KISS principle, or worse. A partial knowledge may be misleading when one doesn't know the context of its application: when, where, how, under what condition &/ who has the capability to apply.
The wealth of knowledge certainly help as foundation, but foundation is the basic, not the goal in itself. The value of a person should then be decided on how one can apply, adapt/re-purpose or enhance an existing knowledge or create new ones.

Absorb knowledge in moderation, don't be a hammer specialist, but don't be a tool collector for the sake of collecting. It would be silly to own a tool that one doesn't know its name, much less its usage.
Humbly admit that we're ignorant to some topics and stay hungry on the topics that held our interest.
Never underestimate one who has less knowledge; he/she is not lesser, merely different.
Swing your hammer proudly, but learn to use other tool(s) as well.

The most difficult to apply:
Don't judge by the speaker, but  by the content. It's in human nature to pass judgement; and once a label is pasted, it sticks, even when further revelations should shed light that initial labeling was wrong.

Wednesday, January 29, 2014

The Heroes, The Bards and The Audiences

The Heroes, The Bards and The Audiences

I forgot where I heard/read about this: was it Xena the Warrior Princess or Violinist of Hameln? Anyway, the saying goes:
There are 3 types of people:
  1. The Heroes - the main characters, the object of praises, the ones under the spotlights.
  2. The Bards - the singers of praises, the ones putting the first group into the pedestal.
  3. The Audiences - this is where most people fit in. I'm here all my life.
Back then I thought "Heroes are the greatest. while Bards are not significant. Such is the greatness of a hero, even if a bard didn't pick up the story, another would."
But after I entered the working environment, my view was reversed. No matter how good a product is, if the owner can't sell it, it would be gone in obscurity. On the other hand, no matter how shitty a product is, if The Bard sings all the right tunes to the right ears, even flaws become strong points.
That, and I've come to realization that heroes are human too, they have flaws, they pee when dumping the big ones (an ex-colleague proved that he could un-load without peeing, but that was not pleasant - so there you have it).

Romance of Three Kingdoms - Glory of Shu

This story never gets old; new writers would picked up the old story and re-told it, but most depict Liu and gang as the good guys. I beg to differ, though to be honest I never read the authoritative, only the dramatization Sānguó yǎnyì.
  1. Ma Chao was a terrible person, causing the death of not just his father, but his (almost) whole family.
  2. There was an episode in Sānguó yǎnyì where Liu Bei and Cao Cao visit a farmer. The farmer has no meat to serve and decides to butcher his wife to get some. Upon knowing it, Cao Cao wants to kill him, but he refrains and waits for Liu Bei's respond. Liu Bei praises the farmer's kindness (Boy, am I glad for not living then and there when such moral compass was in place.).
  3. Zhuge Liang was a revolting man. During the exodus to Xiakou, Cao Cao's ruthless butchering of civilians are infamous. But when I think from different perspective, rousing civilians as living obstacles certainly help to stall pursuers' progress (in a heated stand-off, slip a guy in to throw the first stone, slip out, sit back, enjoy the chaos, eat pop corn, piece of cake.)
For people unfamiliar with (any variant of) the story, above statements may not mean much, but for those who do, I'm just trying to be a Bard there, singing different tune.

The Horse and The Rider

In Silver Spoon, of the same fact: "A rider who can tell a horse where he wants to go and let it figure out how to get there on its own", Hachiken and Mikage come to different conclusion; the former considers the rider is amazing, while the latter considers the horse is the amazing one.
Which camp are you on? The Horse or The Rider?
Both are heroes in this story: Arthur and the knights of the round table, Robin Hood and his band of outlaws. Hachiken and Mikage play the bards, each imbues his/her own subjectivity. While we (as usual) are The Audiences.

This is the kind of story I like to hear/read. Rather than being force-fed by The Bard's judgement on right or wrong, give the facts give competing opinions keep it open let the audiences expand their imagination.
In the real world the rider would be the manager and the horse the worker. But for the worker to be able to find his/her own way, that's one competent worker. On the other hand, isn't that what managers do? bark orders then go home on the dot, leaving the workers doing overtime day in and day out? Well, that's one big over-simplification. Consider the context: equestrianism. Certainly The Rider's job is not that trivial; steering The Horse in line with the trajectory, reaching the goal as fast as possible, with no/minimum mistakes along the way.
That's my expansion from 2 panels of manga. Leaving an inconclusive situation may entices The Audiences to wear The Bard's hat. Maybe the tunes are all over the place; maybe no one would ever hear the tunes; maybe... maybe...; but surely there is satisfaction - however fleeting - of wearing different hat.

I'm grounded (not really, but sort of)

Samsung RF411 as Paperweight

Since last September my Samsung RF411 has been inflicted by frequent BSOD. The prime culprit was Canon driver - the only changes in months. After performing System Restore prior to installation I didn't get BSOD anymore.
After installing .Net framework 4, I was greeted by another BSOD. I performed another system restore (prior to .Net framework 4 installation) and I could use it again.

Late November the BSOD repeated its regular visits. At this point, I didn't think another system restore could resolve my problem.
Analyzing the minidumps (using WinDbg) points to NVIDIA driver, thus I proceed to uninstall NVIDIA driver. But even after that BSOD persisted.
I could circumvent BSOD by going to safe mode (with networking) every time, but somehow I occasionally missed the chance even though I've rapped on the F8 button frequently. My irritation was multiplied by BSOD that sometimes greet me during start up process. Before you comment, yes I've turned off Driver Verifier that actively triggering BSOD.

I forgot who gave me the idea, but I decided to try updating my BIOS via Samsung SW Update; which gave me corrupted BIOS - it couldn't boot. Again, I could circumvent this by inserting a bootable disc and sticking a bootable usb and not pressing any key when asked. But this gives me no chance to hit F8 to go to safe mode, and the BSOD is lurking around.
Today, 29 Jan 2014 I tried to chat with Samsung support on ways to rectify the BIOS issue and got the generic answer: hit F4 for Samsung Recovery. I had my doubt, but I decided to give it a try anyway:

  • Restart
  • Press F4
  • See a prompt "Please Wait..."
  • Keep the machine on for an hour with nothing happening.
  • Turn it off.

Now every time I turn it on, I just see Samsung logo and "Please Wait..." plea. Yay.
Lesson learned: Whenever you hit a problem in Windows, remember the golden rule: don't bother troubleshoot - re-install!.

ACER D255 to Decommissioned?

Due to RF411 issue, I've been using my mom's netbook. I picked Windows SDK for development because it's comparatively light-weight -- coding in notepad, compiling in command prompt. However, using Visual C++ 2010 as the compiler means that my application depends on .Net framework 4.0.
Thus I made the switch to Qt. It's a behemoth for the tiny netbook; the system often gets unresponsive with very heavy disc activities. It has auto-shutdown twice now, and I think it was cue for me to stop.

DELL D410 to the Rescue?

I still have this old laptop that despite its age is more powerful than D255. Yet, after over 7 years of usage it has a unique flaw: after extended period of heavy usage, it would complained loudly (translation: after 30 minutes of playing facebook flash game, a loud sound would be heard).
I can try re-installing Windows while crossing my finger, hoping that the source of groaning is over-burdened OS rather than wear and tear of the components. Either that or...

I Should Try to Revive The Best One

Found a thread of Samsung BIOS Update Issues. I'll read through the 15 pages and if I find no confidence to proceed myself (which is very likely) I'll post a question there.

Tuesday, January 28, 2014

Continuing MP3 Player Development?

Problems

There are at least 3 problems with Qt 4.8 + Phonon
  1. Unable to play some songs - well known issue with known solution?
  2. For some media, the timer might be off (by a lot, almost 3x). - well known issue.
  3. Dragging progress slider would make the position out of sync - this is a big issue for me since my main intent is to show lyrics in timely manner.
Comparing it with previous development under Ms. Visual C++ from Windows SDK
  1. I managed to resolve the same problem by manually adding WM ASF Reader Filter.
  2. Unknown - didn't display time in this version
  3. No problem on some media that exhibit this issue at Phonon, but a LAME-encoded media exhibits the same problem.
As I've mentioned in another post, I don't want to continue developing via Windows SDK because of dependency to .NET Framework 4.0. Specifically because installation of it on my Windows 7.0 64bit caused BSOD - and later found out this is not unique experience.

After I un-installed Qt 4.8 and installed Qt 5.2 I realized that Phonon has been dropped in favor of QMediaPlayer. After testing QMediaPlayer out:
  1. Same issue as Phonon - can't play some songs
  2. Unknown - forgot which song has the wrong timing - might update this later.
  3. Same issue as Phonon - SDK version is more reliable.

To be sure, I'm not suggesting that Windows SDK is better than Qt; simply that I had more success with Windows SDK thus far.

Confusions

First Confusion Stemming from Qt Bug Tracker

QtMultimediaKit would first try to apply WM ASF Reader Filter for mp4 playback.
Yes, it's different tool for different purpose; but my point is: if Qt can use WM ASF Reader Filter there, it should be usable for QMediaPlayer? There shouldn't be any licensing issue with Microsoft for filter usage.
The bug above has been deemed invalid by suggesting Media Foundation over DirectShow.
I've also read someone said Windows Media Player uses Media Foundation rather than DirectShow (to deflect criticism: WMP can play it, why can't yours?). But I used DirectShow in SDK version and managed to tackle the issue? Sigh.

Straying from topic for a bit; a guy here goes further by claiming that
Even the folks in the Qt irc channel told me not use QMediaPlayer on Windows. They suggested using SDL.
 Not sure how much truth in there, but I think using 3rd party codec is more reliable.

Second Confusion: What Codec Should I Use?

Previously I've considered going direct to FFmpeg/libav or Libavcodec but I read in wikipedia that:
  • GStreamer has made a wrapper for FFmpeg/libav
  • Phonon uses / supports it http://en.wikipedia.org/wiki/GStreamer#Distribution_and_adoption
Working on a wrapper will definitely make my work a lot easier, yet considering Phonon has the issues above, can I make the assumption that GStreamer is not a complete wrapper?

Third Confusion: Completeness

An often raised argument is the fact that MP3 implementations are heavily loaded with patents. To support all implementations mean to buy in those patents.
Although a lot of applications use FFmpeg/libav under the hood, each must've improved on it -- like applying the proper filter, properly calculating media duration and current position, etc.
Using Phonon and QMediaPlayer as reference, I highly doubt I'll be able to build an application that can play all MP3s smoothly.

Conclusion?

None for the time being; I need to try implementing WM ASF Reader Filter first, before deciding whether to go on ahead or drop it.

Sunday, January 26, 2014

Minor Update v0.01b

Grab the newer version at the download page.

Change logs:
  • Bug fix: dialog to confirm lyrics creator portion was previously obscured by the main form - this has been fixed.
  • Remove menu bar and replace actions with buttons.
  • Track list table used to show Title, Artist and Album; now it only shows the Title.

Saturday, January 25, 2014

Anime Lyrics

I don't have much for the time being; and I doubt I can add a lot by myself. Thus current presentation layout suffices.

Plan lyrics refer to lyrics without any fancy stuff in it. SubRip specifications allow relative positioning (that has no bearing for audio) and extra formatting (coloring and such).
I wish to support coloring in my player to make it clear who sings what phrase. This feature is important especially for Nichijou - Web Radio songs; where one cuts another sentences.

K-On!

Single - Gohan wa Okazu / U & I

  1. Gohan wa Okazu - plain lyrics
  2. U & I - plain lyrics.

Houkago Tea Time II

  1.  Tenshi no Fureta yo! - plain lyrics.

 

Nichijou

WEB Radio - Nichijou no Radio

  1. Yukko-Mio-Mai no Sucharaka San-nin Shuu - plain incomplete lyrics.
 I want to create one for the 1st song (Shinonome Kenkyuujo no Kyou mo Heiwa desu); unfortunately I don't have a proper English translation for it.

 

Shinryaku! Ika Musume

Metamerism

  1. Metamerism - plain lyrics
I may create the lyrics for the 2nd song (Kimi ga Ireba) next.

Friday, January 24, 2014

MP3 Player with Lyrics

Note: feel free to skip my ramblings and go directly to download page.

Background

Due to my recent interest to hear Japanese songs - particularly those associated with certain anime - I've been wanting to have an application with features:
  • Play mp3 (obviously)
  • Show lyrics
  • It should be modal (always on top even when out of focus)
  • It should be semi transparent, enabling me to do other activities
  • (optional) It can be used to create lyrics.
Finally I've decided to make one myself.
There is a chance that I've just re-invented the wheel - for I'm sure what I want is not something unique - but I don't want the trouble &/ risk of trying out free/share-wares that may suit my wants.

Development History

I used Windows SDK 7.1 for my first try, but after some times decided to switch to Qt 4.8 instead.
Presently (as music player) the SDK version is better than the Qt version but I won't be sharing it.
Reason: It requires .Net Framework 4.0 to run. Framework installation causes BSOD for my best Windows 7.0 laptop and some searches reveal this symptom is quite common.

Creating Lyrics

Lyrics creation is only possible when there is only one item in the track list and there is currently no lyrics available for it.

The steps to create a lyrics

  1. Open a song.
  2. Show Subtitle Creation section.
  3. Fill in the text box(es) with lyrics. Tick on the checkbox and fill in the text box below it if secondary / tertiary lyrics is/are available.
  4. Play the song.
  5. Hit [Start] to grab a line into the lyrics box - don't worry too much if you're always clicking it a bit late.
  6. Hit [Stop] to indicate that line has been uttered completely.
  7. Repeat step 5 & 6 until the end. You might want to pause somewhere in the middle to take a breather.
  8. Hit [Save Lyrics] to save your lyrics.
For your 1st lyrics, it's recommended to:
  1. Save after only 2-3 lines.
  2. Close and re-load the song (apologize for the inconvenience).
  3. Play it and observe whether the lyrics appear too late.
  4. If so, consider adjusting the setting before starting another lyrics creation.

Before we begin lyrics creation, there are some things to note

  1. It's recommended to adjust app's width to max by dragging on app's corner.
    The application picks the lyrics line by line, as shown in the text boxes. This means that word-wrap may break a line, causing Japan-Romaji-Translation lyrics to be out of synch.
  2. If a line is still wrapped despite above, consider editing it. Revising a line later is easier than out-of-synch lyrics.
  3. Remove empty lines between verses.

Technical consideration for above

Qt practitioners recommend block over line capturing. When I copy-pasted UNICODE text (one with Japanese / other characters) a block would be a line, disregarding word-wraps. However, if I copy-pasted ASCII text (translated lyrics) a block is the entire lyrics. An easy work-around is to inject a UNICODE character somewhere beforehand; yet I can't expect all users to follow this step.
Application won't automatically remove empty lines. Some empty lines maybe necessary if some parts (in the middle) don't have proper translation.

Application Settings



Currently there are only 2 settings available.
The first is to set opacity level with value ranging between 50 and 100. Value of 50 means 50% transparency while 100 means no transparancy at all. I personally feel 70 is the best, but because I don't want to force my own flavor, I initialize the value at 100 (solid view).
The second is to set time adjustment for lyrics creation with current value ranging between -600ms and 0ms. The minimum value is for people with slow reflect while the maximum is for one with precognition / has the entire song already imprinted in one's brain.

Current Limitations, Known Bugs and Other Shortcomings

Phonon (Qt's default wrapper for media playback)

  • Can't play some MP3. The SDK version can play those songs after manually applying a certain filter.
  • Dragging the progress slider forward/backward would mess-up the timing. The SDK version doesn't have this problem.
  • Timing for certain MP3 is off - up to 3x of actual timing. I didn't bother to show timing for the SDK version, so no comparison on this one.

Usability

  • No feature to delete a song from track list.
  • No feature to re-order the track list.
  • No feature to drag-n-drop into the track list.
  • Open dialog always start from the top (rather than the last opened folder).
  • Objects (table, text box, etc) dimension can't be adjusted individually.

Annoyance

  • Unconditionally creates LogFile.log that may grow quite big.

Future Enhancements (in no particular order)

Settings

  • Save settings into a config file.
  • Font for lyrics box should be configurable.
  • Debug level should be configurable.

Player Codec

  • May drop Phonon for direct access to Windows' driver or switch to FFMPeg.

Usability

Download MP3 Player with Lyrics

STOP!! Don't bother downloading anything here.

Just uninstalled Qt 4.8 to try Qt 5.2; long story short, Phonon library is required for music playback and I don't have the library anymore.

 The original intention was to see whether some known Phonon issues have been resolved in Qt 5.2 - only to realize that Qt doesn't use Phonon - natively - anymore.

Tested Environments

 Works

  •  Windows 7 Starter on a netbook with Intel Atom N550.

Doesn't Work

  • Windows XP --> application runs, but can't load any song.

Download 

Dependency Libraries 

Only need to download once, unless I decide to use other library(ies).

Application


Ramblings


This application is created using Qt 4.8. It is currently dynamically linked, thus several libraries are required for it to run.
Statically linked application would be smaller, but that means:
  • I have to statically compile my Qt.
  • The license for application would change - I haven't read through what's the implication.
In any case, if I decide to statically compile Qt, it would be the latest version of Qt rather than 4.8.

Version 0.01b has been uploaded within a zip file.
I provide the application as an executable rather than bundling it in a zip file.
Reason: I'm curious if any anti-virus would flag it as a virus or such.
--edit 1--
Well, well,  bitly already considers it problematic. I've replaced the link for the application with the real-longer link.