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.

sunnuntai 8. elokuuta 2010

Cross-compiling Qt applications for Windows, the easy way

For a while I've been looking for a way to cross-compile my Qt app for Windows on Linux. I don't have any Windows PC's at home or at office, so native build is out of question. There are several instructions how to do this, but they involve cross-compiling the whole Qt from source and a lot of other manual work.

I found and easier way using Wine.

1. Install Nokia Qt SDK for Windows using Wine. It should install fine.

2. Create a build script that does something like this:

export QTDIR=$HOME/.wine/drive_c/Qt/2010.04
export Path=C:\\windows\\system32\\\;C:\\windows\\\;C:\\windows\\system32\\wbem\;C:\\Qt\\2010.04\\mingw\\bin\\\;C:\\Qt\\2010.04\\qt\\bin\\\;\
C:\\Program\ Files\\NSIS\\
cd app_directory
wineconsole --backend=curses qmake.exe
wineconsole --backend=curses mingw32-make.exe

3. That's it! You should now have a working .exe in yout project directory. You can run it using wine.

When shipping your application, you need to include the required mingw and Qt DLL's with it. For example:

$QTDIR/qt/bin/mingwm10.dll
$QTDIR/qt/bin/libgcc_s_dw2-1.dll
$QTDIR/qt/bin/QtCore4.dll
$QTDIR/qt/bin/QtGui4.dll
.. and any other DLL's your app needs. Remember to use the d-versions if you build your app in debug mode.

For SQL drivers install them into directory named sqldrivers in the directory where your .exe is installed. For SQLITE the DLL is $QTDIR/qt/plugins/sqldrivers/qsqlited4.dll.

If you want to create an installer, I can recommend the open source Nullsoft installer (NSIS).

maanantai 31. toukokuuta 2010

RC Hornet first flight

Recently I bought a F-18 Hornet model from Bananahobby.com. It's a ARF foamie which is pre-painted and looks pretty good. It has a brushless electric ducted fan motor and a 4 cell LiPo battery pack. The model took a few hours to build, most time taken by gluing wings and stabilizers and installing servo wires. The kit had a 2.4Ghz radio included and installed, but i opted to use my own DX7 with it's 7 channel receiver. If you or your friends need a cheap 4 channel RC radio set at Tampere area, let me know. I haven't tested if the receiver works with DX7 yet.

I also decided to connect left and right ailerons to different channels in receiver and thus making them flaperons with DX7's mixing functions.

Yesterday was the first flight day. First i flew with a full size sailplane (LS-8) and then made some preparations and waited for a rain shower to go away. When the rain stopped, weather was semi ok for first flight - there was some light wind but no strong gusts.



Pre-flight photo.

The flights went fine. I flew 3 flights, totalling maybe 15 minutes. I was alone at the airfield so there are no in-flight photos, sorry. The model has plenty of power - maybe close to 1:1 power to weight ratio. Cruising can be done at half throttle. It's also surprisingly stable - center of gravity is so low that it tends to correct any bank by itself. It's also pretty agile and looks great in flight. It's not easy to fly though - for example stalling can cost 10 meters of altitude easily. Landings must be done pretty carefully and at low angle to avoid hitting ground tail first.

I tried using flaps (both up and down) but they caused huge trim change and almost losing control so i didn't use them during landings yet.

The ESC that came with the kit doesn't warn about low battery by cutting power like ESC's usually do. This one just outputs less power which came as a surprise to me and caused unscheduled landing. I guess I'll have to have a stopwatch to estimate flight time left.



Construction pic. Electronics are behind the plastic door which is glued into the fuselage.



Looks like I'll have to buy a larger car if I want to get larger models than this.


Link to the model (it's on sale now!):

http://www.bananahobby.com/1940.html

perjantai 26. helmikuuta 2010

Converting music to mp3 in place

I bought a new car stereo a while ago. I'm not going to specifics about it as this is not a car hifi blog. What's interesting is that the player can play mp3's from CD, USB memory and SD card.

My digital audio collection is mostly in ogg and flac format for better quality/file size and the player can't handle them. I tried to find a nice solution to mass convert files from ogg/flac to mp3 but none of them were satisfactory so i wrote my own script:


#!/bin/bash
# Convert flac & ogg audio to low quality mp3 for mobile playing.
# By Ville Ranki

find -type f -name "*.flac" -o -name "*.ogg" | while read file
do
outfile=`echo $file | sed 's/\.[^\.]*$/.mp3/'`
echo "Converting $file to $outfile"
gst-launch-1.0 filesrc location="$file" ! decodebin ! audioconvert ! lamemp3enc target=quality quality=4 ! id3v2mux ! filesink location="$outfile"

if [ -f "$outfile" ];
then
   echo "Removing original $file"
   rm "$file"
else
   echo "Error: File $outfile was not created."
fi

done



This script will find recursively all files in current directory, convert them to mp3's (while preserving id3 tags) and delete the original files. It preserves directories as they are - my car player should be able to browse by directory although i haven't figured out how to do so.

I use it by copying wanted music to a temporary directory, run the script in the directory and copy the results to usb stick or other media.

Make sure you have all the commands installed before running the script, such as gst-launch-0.10. Also don't run the script where the original collection is or you'll lose it. Copy files somewhere else first.

I hope this is helpful for others with the same problem.

(Updated 23.7.2015 for gst-launch-1.0 and simplified the script at the same time)