tiistai 12. helmikuuta 2013

Running Qt applications in Android

Digia (owner of Qt) is working on official Android and iOS ports of Qt, but meanwhile Qt applications can be built and run in Android using Necessitas, an open source project which forks official Qt SDK. Currently it is still in beta phase but is already usable. This document has been written in early February 2013 so it may not be valid with later Necessitas versions.

Setting up

 Necessitas SDK

Download and install Necessitas SDK from http://necessitas.kde.org/necessitas/necessitas_sdk_installer.php

Launch SDKMaintenanceTool from Necessitas. Select the desired API level from Miscellaneous/Android NDK. You could here also install Android SDK under Necessitas if you don't already have it installed.
Note: While testing API level 10 seemed to work the best. Later versions launched always in AVD even when a device was connected.




Android SDK

Download and install Android SDK from http://developer.android.com/sdk/index.html
Load the Android SDK version you want to support using android_sdk/tools/android tool.



Building

Launch Qt Creator from Necessitas installation using QtCreator/bin/necessitas (not bin/qtcreator!)

Open a project (existing one or create a new). A "Configure Project" dialog is shown.

Set the project as "Necessitas Qt 4.8.2 for Android armv7a" project. You can also select other platforms you might want to build to.

Select from menu Tools | Options and Android page. Set "Android SDK location" to the path you installed Android SDK. If you need to create a Android Virtual Device (emulator) create it now.

Some items were not autoconfigured in my install, so:

Set x86 GDB to android-ndk/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-linux-android-gdb
Set x86 gdbserver to android-ndk/prebuilt/android-x86/gdbserver/gdbserver
Set OpenJDK location to /usr/bin/java

 Click "Ok" to close dialog.
Click on build configuration icon in bottom left corner, above "Run" button. Select the Necessitas build and Debug or Release, which one you prefer.
Click Projects (on the left side bar) -> Run Settings -> Deployment -> Package configurations -> Android target SDK. Change it to the android version you plan to use.
In "Deploy configurations" you can select wheter to include Qt libraries in your package or use Ministro to download libraries on demand. Ministro seemed to work on device but not in AVD. Ministro is a "library downloader" which will install the required Qt libraries to Android so that they can be shared between Qt applications.

Press Ctrl-b to build the application.

Running

Press Ctrl-r to run the application. Application should start in device (if connected) or in AVD.
Sometimes i got error "Found some build errors in current task. Do you want to ignore them?" but ignoring errors worked and the application would run nicely.

Conclusion

The Necessitas SDK is clearly still beta quality, but already can be used to port existing Qt applications to Android or create Android apps from scratch. Source changes are normally not needed at all. Naturally UI's may need adjustment for touch interface if they have been implemented on desktop. Applications built
using Necessitas can be and have been published in Google Play store.

sunnuntai 29. tammikuuta 2012

State of Linux video editors

I need to edit some videos randomly. Nothing professional, mostly some clips from a GoPro or cell phone video camera. I need to cut & paste clips and add music soundtrack. This should be the basic feature set of any video editor, but unfortunately most of them fail one way or another.

See also State of Linux audio players

Here is a comparison of few free video editors available. They are tested on Ubuntu.

Kdenlive (tested march 2014)

Current winner. Does all I need without issues. UI could use some polishing, but good enough.

OpenShot (tested summer 2013)


Decent video player. Crashes randomly but is still usable. Ui misses some features, such as moving a clip to end of previous clip which makes editing long videos painful. Also there's still no way to select multiple clips.

PiTiVi 0.15 (tested jan 2012)


Mediocre but not bad UI. Preview becomes so slow that it's practically a slideshow with multiple 720p videos. Crashes frequently. Development is active but work is done for next version based on gstreamer editing services. I had a problem with rendered files having zero size, but this was fixed by removing gaps from the project. Many thanks to thiblahute on #pitivi.

Cinelerra (tested spring 2011)

Crashes so often that it's useless. UI looks like it's from 90's.

VLMC (checked summer 2013)


Spawned from VLC media player. Looks promising but i suppose develoment is dead as the official repository doesn't have packages for current or previous Ubuntu release.

torstai 26. tammikuuta 2012

Saving all channels in irssi

Normally it's only possible to save channels one by one in irssi. This is quite annoying. Here's a small script to save 'em all (thanks pulk!):

/alias channelsaveall script exec foreach my \$channel (Irssi::channels()) { Irssi::command("channel add -auto \$channel->{name} \$channel->{server}->{tag} \$channel->{key}")\;}

Copy-paste that on a single line and then just /channelsaveall.

lauantai 8. tammikuuta 2011

How NOT to add force feedback to your flight stick

I want to add force feedback support to my CH fighterstick. Currently no one makes consumer-priced force feedback flight sticks, so I can't buy one.

This project started a few years ago and has lasted over several iterations.

First fail

The first version had a large RC car servo connected to the stick. For prototyping i implemented force feedback only on elevator axis of the stick. I bought a serial servo controller and a usb serial dongle to control the servo and wrote a plugin for X-Plane to control it. It worked well and caused good force, but the stick could not be "relaxed" at all. In slow flight i needed to push or pull the stick quite hard to move it (and the servo). High-speed aerobatics felt really good though, so i knew i was up to something. Unfortunately this was not realistic enough so i ditched this prototype.

Second fail

I found a few old printers from electronic waste bin at work and looted them for parts. They contained many usable parts such as motors, axles, gears and belts.


I set up one motor (don't know the specs, maybe 300 size) with a belt to a larger gear to get a sensible gear ratio. To control it i bought a Phidgets USB motor controller board.


Unfortunately this time controlling the force was difficult - with low power it just made noise and with large it suddenly started moving rapidly. Also the maximum force was not large enough. The belt slipped sometimes, no matter how i adjusted it. It wouldn't work so i ditched this one too.

Third fail

This time i decided to make a more powerful version of the last prototype. I got some stuff meant for RC planes: a gearbox and a Speed 400 motor. They fit perfectly together and felt mechanically strong.


This time there was plenty of power. I hooked up a multimeter to monitor current use and the largest current measured in beginning of tests was 19A. I decided to not to monitor current longer as the multimeter was meant for currents only up to 15A. After a little tuning the thing seemed to work! I removed the centering spring from fighterstick and did some additional testing until smoke started pouring out of the motor. Third fail.

Clearly electric motor is not the way to go. If i used a larger motor, the current would go even higher and over the limitations of the controller board. Using larger gear ratio would cause the same problem as with servo - it would be impossible to cause small or no force.

Next fail

Pneumatics? Hydraulics? Stay tuned!

perjantai 10. joulukuuta 2010

ExtPlane Panel for X-Plane

I bought a touchscreen monitor to use in my simpit a while ago. Unfortunately after that I noticed that X-Plane's external cockpits don't support any input - I can't press buttons and turn knobs using finger.

I almost got dismotivated by that but decided to do what any of us would do: write a plugin for X-Plane to support input from external apps and software to run my panel.

The plugin part lives inside X-Plane and starts a TCP server to get commands from. Currently it supports only reading and writing of datarefs (simulation variables) but button support is coming soon. The plugin's source code can be found at:

https://github.com/vranki/ExtPlane

The panel, called ExtPlane panel is a "client" for ExtPlane plugin. It displays a 2D panel showing various instruments. It can read and write X-Plane's datarefs via ExtPlane and display any information on screen. Currently it's aimed for making sharp, antialiased scalable vector graphic displays (as opposed to X-Plane's bitmap based) but in future "anything" can be done. Instruments can be added, moved and removed using mouse just like in X-Plane's Plane Maker.

The panel is written in Qt, so naturally i wanted to see if it would run on my Nokia N900 cell phone. As you can see, it runs without any modifications. Also there are no wires - The N900 communicates with X-Plane over WLAN connection. On the left is a airspeed gauge and on the right a compass. Currently they are the only instruments available, but it's very fast to write new ones using the framework provided. The airspeed indicator is 40 lines of code and compass is 37. The instruments can have configuration UI so that for example you can set the units used in airspeed indicator. I'll probably soon write some "generic" instruments that can show value of any dataref, just like in X-Plane.

All instrument graphics are vector graphics so they can be freely scaled and rotated while keeping graphics crystal clear. You can run the panel in portrait or landscape mode, or even with any angle.
Sources for ExtPlane-Panel can be found at:

https://github.com/vranki/ExtPlane-Panel

If you're not a developer and don't know how to build from sources, ExtPlane is not ready for you just yet. I'll need to add more instruments and do some more finishing until I'll start making binary releases for general public.

perjantai 3. joulukuuta 2010

Streaming live DVB using VLC

The problem: i needed to stream live DVB broadcast from home to the outside world. Limiting factors are bandwidth (1Mbps up) and CPU (Core 2 Duo @ 1.8Ghz). I found out a lot of guides on how to do it using VLC, but only a few worked. Source for the video in this case is a USB DVB-C tuner, but any DVB tuner which VLC sees should work.

After a lot of tuning, the best result was obtained with the following command line:

cvlc -v channels.conf \
--sout \
'#transcode{vcodec=theora,venc=theora,acodec=null,deinterlace,vb=700,fps=16,threads=2,scale=0.7}:standard{access=http,mux=ogg,dst=:8081}'

This will give a average of 700kbps ogg theora stream scaled a bit down and with 16fps
frame rate. This stream doesn't include audio, so you'll probably want to set acodec=vorbis
and audio bitrate (ab=) something sensible.

Stream is served at port 8081 and can be viewed locally at url http://localhost:8081/ using VLC or other video player. You'll need the channels.conf file (google how to obtain it). You can also use vlc instead of cvlc to get GUI. You can change channel from playlist window. This can probably also be done on command line somehow.
Set threads= to number of cores in your CPU. On Core 2 Duo it's naturally 2.



The quality can be described as "youtube-like". You don't want to watch Avatar on this but for some basic stuff such as sports, talkshows and news it's way better than no stream at all. Naturally if you have more bandwidth, increase the vb parameter. With 1M uplink 800kbps resulted in jerky video, so 700 is pretty close to optimum.

Notes on some other codecs: x264 encoder didn't obey the bitrate parameter at all and was unusable. ffmpeg created corrup video (random bright colors et all) so i decided to use ogg theora which worked really well.

perjantai 5. marraskuuta 2010

State of Linux audio players

(Last updated: 2.8.2012)

I've been looking for a good music player for advanced users. I have a large music collection (hundreds of gigs) on a server which is mounted over sshfs. My requirements are

- iTunes like UI based on tags - NOT file names and directories.
- Ability to scan the large connection over and sshfs share in reasonable time.
- Must not forget the whole database if the network share is  down temporarily.
- Stay responsive. All programmers know that you shouldn't do any potentially long operations in UI thread, but most players seem to do so.
- Ability to edit tags. A large part of collection is either untagged or wrongly tagged.

Wishlist:
- Allow multiple locations to be selected for library.
- Some kind of indicator about what the scanner is doing. Ability to force re-scan of collection.

And now to the players:

Rhythmbox (Updated 30.7.2012)

The Gnome's default music player. UI is pretty slick and nice. Works pretty well, except tagging files doesn't work at all (Unable to save song information - Timeout was reached). And sometimes grays out a little bit.
If the network gets congested, Rhythmbox's UI gets totally confused and grays out. Looks like file operations are done in UI thread. This is the player i use the most, as on good day it can scan the full collection and be usable.

Amarok 2.5.0

Started scanning the library nicely and UI stays responsive. After 6 hours the
scanner progress bar hasn't moved at all and there are 0 tracks in collection.

Quod Libet

I selected the library directory and hit "Reload Library". 0 files found. Maybe it doesn't understand symlinks?
Ok, let's try playing from file system. I enter the library directory and.. The player grays out for a couple of minutes. The UI is very slow.. maybe it's scanning after all? I'll never know as i kill it.

Exaile

I add the library directory. Ui grays out just a little bit but says "Scanning collection..".
After a while it still is scanning and has found 0 songs. The Radio tab seems to work and i can play a Shoutcast radio while waiting. UI is slow, so looks like some processing is done in the UI thread.
I left exaile scanning for the weekend. On monday morning it was still scanning at 0%.

Banshee (Tested 23.11.2011, Ubuntu Oneiric)

UI seems very nice and possibly even better than Rhythmbox so this player gives a lot of hope. I added the collection directory and the app started scanning very nicely. Now, after almost 24 hours it displays 78%, uses 3.3 gigabytes of memory and is very unresponsive.

Nightingale (Tested 30.7.2012)

Download link and the ppa advertised do not work, so unable to test.

Clementine (Tested 2.8.2012)

UI looks nice and might be a good player if it works. Unfortunately it doesn't. It starts updating library and gets to 99% soon.. but the percentage drops to 85% and then back up.. until it repeadetly drops down. During scanning it doesn't add anything to library to be playable so it's impossible to see if it is really progressing.  To give it a chance i left it running overnight. After over 24 hours of scanning it is "Updating library 98%" and i decide to quit it.

Conclusion

They all suck, more or less. Let me know if you find any good player to be added here. I'll try to update this post whenever i test new players.