Simple morse player for the N950

September 26, 2011 at 9:56 am | Posted in Software Development, Uncategorized | Leave a comment

Remember the old fashioned movies with spies and sailors going dit-dit-dah to each other. Well now you can relive that nostalgia with the “Morse Code Player (source code available below).

This application was supposed to be a quickie that just does a few simple things, but in the end it turned out to be a headache due to my limited understanding of the threading behaviour of QML and Qt C++. The core of the application consists of two C++ classes the MorsePlayer that converts text to morse, and the ToneEngine that creates a audio tone.

The MorsePlayer class is relatively straightforward QML binding class that has a bit of logic for converting text to morse, and then for call the ToneEngine to play the necessary tone. The ToneEngine class is a bit more complicated; it copies logic from the AudioOutput example for generating a simple tone. The tricky bit (that took several half days to solve) was working out that the audio handling code (ToneGenerator, QAudioOutput) needs to run in its own thread, with its own event handler othwerwise the audio output blocks. Additionally. MorsePlayer needs to send signals to the ToneEnginer otherwise the audio blocks. Another tricky bit is the use of resume and suspend to start/stop the audio output, this is simply because QAudioOutput start/stop takes too long to create the initial buffers etc.

The current code is not perfect, it still occasionally has buffer underflows (any help here would be appreciated). As an application, it needs some extra features like a way to set the morse code rate, and tone frequency. Additionally, it could do with more features like haptic feedback and other clever ideas. I could also clean up the code more (add more comments, play with the design, make it a QML plugin) so I am just releasing it “as-is” as a simple example of tone generation from QML.

A simple wiki page with historical source code.

A direct link to the source tarball.



Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at
Entries and comments feeds.

%d bloggers like this: