Category Archives: Coding

Dual Fade Nyquist Plugin for Audacity

On my hard drive a couple of wav recordings of classical concerts are waiting eagerly being split into the individual pieces and to be saved as ogg respectively mp3 files.

I’m using Audacity for the task, a famous open source audio editing software.

The tasks requires the following steps:

  1. Remove audio in front of the first piece.
  2. Remove audio past the final applause of the audience.
  3. Fade out the applause.
  4. Normalize both channels independently due to mike differences.
  5. Add silence between the pieces.
  6. Fade in the hum caused by the audience in front of each piece.
  7. Fade out the hum at the end of each piece.
  8. Create text markers for each piece containing the name of the compser, the name of the piece and the like.
  9. Let Audacity do the job by splitting and exporting the audio material based on the text markers.

I searched a possibility to ease steps 5 through 7. I found a code snippet by edgar-rft. He politely granted the permission to reuse the Nyquist plugin code, so I slightly modified it to get my job done.

Installation and Usage

  • Download and extract it.
  • Move the resulting file dual-fade.ny to the plug-ins folder of your Audacity installation.
  • (Re)start Audacity and load some audio data.
  • Select some of the audio.
  • From the menu effects, choose the command »Dual-Fade«.

That’s it. The first third of the selected audio will be faded out, the second third will appear as silence, and the last third will be faded in. The complete fade follows a three-stage envelope with linear segments (using pwl, »piece-wise linear functions«):

BTW: I also found the Fade+ plugin by Steve Daulton which uses bezier curves to apply some smoother fading curves instead of the usual linear one. In case you do not only want to fade noise but real audio pieces, I’d recommend to check whether it gives you pleasant results.

Edit: Obviously I didn’t search hard enough before writing a plug-in of my own, since I got a reply that a similar plug-in already exists.

First Spring Hiking 2012

10 people, two public transport tickets – we did a marvellous spring hiking trip from Calmbach to Pforzheim. That’s the viewpoint at Büchenbronner Höhe:

I find wild boars interesting, but I’m not really interested that they come that close – at least not somewhere in the woods. Fortunately this one was enclosed in a compound :) :

Almost everything on the way already was in the OSM database, so I only recorded stuff for minor edits. I used MoNav on the N900 for routing, track logging and note taking. Additionally I played with OsmAnd on the tablet every now and then. It provids tons of great features. The disadvantage is that it features tons of configurations options to cope with :) .

BTW: Thanks, Miro, for organizing the trip – I know you are reading this :) .

Since MoNav learned to speak

About two weeks ago I blogged about my first attempts to teach MoNav to provide speech output. While everything worked well on my desktop machines, MoNav did tend to crash every now and then on the N900, rendering it pretty useless for the intended use.

As debugging was a bit difficult, I have just rewritten a suspicious part of the code. Et voilà, a test drive through the city of Karlsruhe the past evening was of great joy and pleasure.

The speech output still is not mass compliant, though. MoNav is too verbose, instructions are spoken too late, and MoNav needs too long to detect that the vehicle left the precomputed route. But that’s just tedious work in progress to be done during the next weeks and months.

And though I’m complaining, do not forget that MoNav in its current state actually is capable to guide you to your destination, while I’m pleased with what I achieved during the past weeks.

I’ll continue the work on speech output for car drivers before I’ll dive into making it compliant with the needs of cyclists.

In case you want to play with the current code, you’ll need to compile the branch from source:

  • hg clone monav-permaroute
  • cd monav-permaroute
  • hg update permaroute
  • qmake
  • (/Developer/QtSDK/Desktop/Qt/474/gcc/bin/qmake on Mac OS X)
  • make

You’ll also need updated map packages for this version to run properly. I’ve already precomputed some mapsets:

The above lines are not intended for end users. It’s for all those openstreetmap addicts who are interested to follow the current development of MoNav.

Have fun!

Recently, as Maths made my Xmas Break

In the last posting I mentioned that I made the routes in MoNav more persistent:

As a consequence, I’ve just written some code that detects whether the vehicle is still “on track”. The route only gets recalculated in case the vehicle left it for more than x meters. This makes the route much more persistent and will cause far less headache than the previous approach.

Since the GPS position is always a bit inaccurate, it will almost never be exactly on the computed route. Instead, it will aberrate a bit from it. What you want to achieve is to detect whether the current position still is either near the route, e.g. left or right of it, no more than x meters away and still in direction to the planned target, or in the opposite direction.

Continue reading

When MoNav learned to speak

A couple of months ago I opened a branch named »ui-ng« in MoNav‘s repository to develop a new user interface. Meanwhile this branch became a playground for several hacks, and some of them are just spikes to check out whether some ideas work or not.

I denied to work on speech output this spring, as I knew this would become a rather lengthy task. But it was obvious that I won’t resist the temptation during the cold and dark winter months. So I added the first code to generate spoken turn instructions recently. It is an ugly hack, just to determine what was possible. The code as found in the »ui-ng« repo works, well, at least a bit. The instructions are far away from being useful, except for lonesome crossings or roundabouts without other crossings nearby.

I’m using prerecorded samples for now, as the current open source speech synthesis systems did not show the results I desired. OTOH, this means I cannot generate instructions with dynamic contents like distances or street names. Additionally, those samples currently are included in the application binary, which will pollute the memory of handset devices as soon I’ll add further localized samples (currently speech is available in german and english language only).

The main issue is that MoNav recalculates the route each time a GPS position update is received – which means each second on the N900. As the GPS position always is a bit inaccurate, MoNav will speak »Please turn right« when you pass, for example, a gas station and the GPS position is off the road by a couple of meters.

As a consequence, I’ve just written some code that detects whether the vehicle is still “on track”. The route only gets recalculated in case the vehicle left it for more than x meters. This makes the route much more persistent and will cause far less headache than the previous approach. As this happened just a couple of minutes ago, the code is not in the repo yet.

There’s still a lot of work to do, and I’m curious whether I’ll stay motivated enough to do all of the work ahead. On the other hand it’s just plain fun to explore the secrets of a usable routing application.

So stay tuned. The next week(s) will show whether I’ll »head straightforward« :) .

MoNav User Interface now available in German Language

The last two days I’ve worked on a first translation system for MoNav. Thanks to Qt4 it was just simple, and admittedly I copied over some lines of code from one of my other projects, Gebabbel.

MoNav checks the user’s system for a locale string, searches for a matching translation file, and if available, it gets loaded. Currently, the translation files are included in the binary, so we do not need to care about install paths and the like. As soon we have some translations available, they will be removed from the binary and installed as separate files to save some memory.

This also means we are in desparate need of translators for the upcoming releases. Do you want MoNav to appear in your mother tongue, maybe Russian, Chinese, or Bamanankan? As no programming skills are required to create a translation, do not hesitate to contact us.

Can MoNav do bike routing #17251¹

Today my way led from Darmstadt to Aschaffenburg, where I visited some relatives and friends. MoNav did a very good job guiding me. As it chose a route which led along major roads, I set a via point in Messel, and got really great results.

The trip info page I recently introduced was very helpful. Well, it’s like a progress bar on computers. It does neither shorten the remaining distance, nor does it beam you to the destination. But anyway, it’s very useful to have some figures right at your fingertips during the tour, so you know whether you should hurry or you can enjoy a short rest.

The trip was about 50 kilometers which I planned to cope with in 2 hours. Though the terrain is completely flat, some head wind caused an average speed of 20 km/h only – I needed 30 minutes more as I planned.

Once again, I really enjoyed to have MoNav’s excellent offline routing available during the trip. Before I used MoNav, I spent hours in front of my computer to prepare a trip. Today, I just check what MoNav suggests before I leave and help it with some via points – that’s it. An issue of minutes, not hours.

I’d like to thank all Co-Mappers who contributed the data I used during today’s trip. Thanks girls and guys.

¹ According to echo $RANDOM

Trip Info Page for MoNav

Though I’m currently rewriting the user interface of MoNav, I’m still missing some features while being on the road. During a trip, I want to see information about the remaining route distance, the distance and time already traveled, and as a cyclist who sometimes crosses hilly regions, I found some altitude information very useful. Obviously some volunteer is needed to write the code to accomplish that. Waiting for someone else is a valid option, but I know it’s much better to get things done™ :) .

I pushed the first code to the central repository a couple of minutes ago. It’s not polished yet, and the user interface requires some more dedication. I’d also like to add a display of the average speed, but this required some redesign of the track logger code first.

Frankly, it’s a great joy and pleasure to contribute to MoNav. I’d like to thank its creator and maintainer, Christian Vetter, for the great work he put into it. The use of Qt for the backend and the frontend code. The uber fast routing engine. The use of OSM data for routing and the fast address search. And last but not least for his openness when it comes to new ideas and changes. Oh, and did I mention MoNav ran on the N900 out of the box from the first day I tried it :) ?

I’d also like to thank James Hollingshead who wrote the first ready to use vector renderer for MoNav. Though it still shows some minor glitches and is missing rendering of street names, it currently serves us very well for displaying offline vector map data.

Enough rant for now. The code is written, and I better should go to bed :) .

MoNav user interface overhaul – the cross platform hassle

The recent 0.3 release of MoNav provides a useful interface, which allows to invoke all features directly from its main window. It’s a great, both finger as well as user friendly interface, especially on mobile devices such as the Nokia N900. The downside is that it does not conform to the look and feel of the other applications of a given platform.

Continue reading

MoNav 0.3 Released

MoNav performing bicycle routing

MoNav performing bicycle routing

Christian Vetter, the inventor and maintainer of MoNav, just announced the release of MoNav 0.3. Finally the improvements and new features developed during the last weeks and months are available as precompiled installers. Here’s a copy of the original posting:

Hello everyone,

I am pleased to announce the release of the 0.3 version of MoNav
[1][2][3] just in time for your favorite Easter holiday trip.

The highlights of this release are:

  • UI Overhaul, take a look at the screenshots[4]
  • Offline vector renderer: QTileRenderer[5]
  • Better handling of map data and map modules: It is now very easy to switch between routing ( motorcar, bicycle, pedestrian ) and rendering modes ( online, offline vector… ).
  • Full Maemo support
  • Track logging
  • PBF[6] support: 10 times faster OpenStreetMap data parsing!
  • Console version of the preprocessor
  • Improved import of OpenStreetMap data: surface, smoothness, barriers, …
  • And many more

Of course MoNav still delivers blazingly fast routing, even for huge
graphs on mobile devices.

Downloads available[3]:

  • Client binaries for Windows32, Ubuntu 32/64 and Maemo
  • Map packages for most countries: pedestrian, motorcar and bicycle routing; online and offline vector rendering.

We are still looking for contributors in the following areas:

  • GUI design
  • Address Lookup ( Karlsruhe Schema, novel approaches … )
  • Binary package maintenance for various systems / distributions
  • Usability tests and improvements
  • New features
  • Of course other contributions are always welcome If you believe you can contribute and are interested in joining the development team please let us know.

Feel free to contact us on our mailing lists[7][8] or to post bugs to our bug tracker[9]

Please note that this project is under active development and while
considered stable may still contain serious bugs.
Comments, bug reports and suggestions are welcome and can be filed under [9]

Happy routing!
Christian Vetter

[1] MoNav Homepage:
[2] MoNav at OpenStreetMap Wiki:
[3] MoNav Downloads:
[4] MoNav Screenshots:
[5] QTile Renderer:
[6] PBF at OpenStreetMap wiki:
[7] MoNav mailing list:
[8] MoNav developer mailing list:
[9] MoNav bug tracker:

When bollards baffle bicycle routing

MoNav bike routing 1 (map data by openstreetmap and its contributors, CC-by-SA)

MoNav bike routing 1 (map data by openstreetmap and its contributors, CC-by-SA)

My last black forest trip by bike led me through Baden-Baden, and MoNav created an interesting route, avoiding the best one. At home, I figured out that bollards caused the weird behaviour. Actually MoNav didn’t route across nodes with any barrier tag applied.

I checked the code of the preprocessor, and allowing bikes to cross bollards was just simple. However, the preprocessed bicycle maps available for download all were of less use.

Some script currently recomputes all maps. For each region provided, you’ll only find one zip package instead of three. The zip file contains the following data:

  • Address search.
  • Online tiles (Mapnik style, internet connection required).
  • Fast offline vector rendering (due to early code, no streetnames rendered still).
  • Car routing.
  • Bicycle routing.
  • Pedestrian routing.

In case you do not need all of the routing data, just remove the folder you do not need after extraction. I hope these data sets will serve cyclists and pedestrians better than the previous ones.

MoNav bike routing 2 (map data by openstreetmap and its contributors, CC-by-SA)

MoNav bike routing 2 (map data by openstreetmap and its contributors, CC-by-SA)

First Windows installer for MoNav available – Help wanted

Christian was able to fix a nasty bug which caused MoNav to crash during startup on Windows. I used the occasion to create an early NSIS Windows installer.

The installer contains experiental software, as I applied some quick and dirty hacks to get it compiled. It is thus not intended to be used by end users. As I’m rarely booting into Redmond OS, some developer who is savvy enough to maintain the NSIS installer is required to update the package every now and then. Contributors are always welcome!

MoNav packages updated

Due to a nasty bug concerning the generation of tracklogs, I’ve updated all MoNav packages (Ubuntu i386, Ubuntu amd64, Maemo). The code is tested during two trips and behaves »as advertised«. Hint: On the N900, you’ll need to scroll down a bit in the preferences dialog to access the button to clear the tracklog (see the above hardcopy).

Desktop users do not need to update, as the desktop versions do not support GPS subsystems. N900 users should update the package as soon as possible.

Großdeutschland in MoNav

Map data by openstreetmap and its contributors, CC-by-SA

Map data by openstreetmap and its contributors, CC-by-SA

Living in Karlsruhe, Germany, I often found it annoying that my map data was cut along the german-french border, so I could only load either france or germany into MoNav. Of course, routing crossing the border was not possible this way.

Thus I created a map package using a bounding box which includes germany and adjacent areas. The exact coordinates used are top=55.0 bottom=46.0 left=5.7 right=15.1.

Additionally I’ve run the routing preprocessor three times, so the package contains routing for car drivers, cyclists, and pedestrians. This map is a must have for any german openstreetmap addict. Get from the download page.

Creating a Debian package file for Maemo 5, public domain, public domain

A friend of mine asked for a package of MoNav for the Nokia N900 smart phone.

Creating a proper package requires to read a lot of documentation (yes, there is pretty good documentation) and to put together all the bits correctly. But I just wanted a very basic package, containing a binary, an icon, and a desktop shortcut file. Should be simple, eh?

Yes, it is simple. Just put the files in a directory, add a basic control file, and you’re done. Here we go:

  • Create a working dir, e.g.
    • mkdir builddebpackage
  • Make it the working dir:
    • cd builddebpackage
  • Create the base dir for the package, e.g.
    • mkdir monav-0.3
  • Make it the working dir:
    • cd monav-0.3
  • Create the folders you want to populate on the target machine:
    • mkdir -p usr/bin
    • mkdir -p usr/share/applications/hildon
    • mkdir -p usr/share/icons/hicolor/scalable/hildon
  • Copy the files to those directories:
    • cp ~/dev/monav/bin/monav usr/bin
    • cp ~/dev/monav/bin/monav.desktop usr/share/applications/hildon
    • cp ~/dev/monav/bin/monav.png /usr/share/icons/hicolor/scalable/hildon
  • Create a folder named DEBIAN:
    • mkdir DEBIAN
  • Create a control file in this directory, with the following content:
    • vi DEBIAN/control
    • Package: monav
    • Version: 0.3-1
    • Architecture: armel
    • Maintainer: ce
    • Installed-Size: 1456
    • Section: user/navigation
    • Priority: extra
    • Homepage:
    • Description: Routing application
    • [insert one blank here]Allows to track the GPS position and provides very fast and exact route calculation.
  • Make the upper directory the working directory:
    • cd ..
  • Create the package, while ensuring there is no trailing slash at the end of the folder’s name:
    • dpkg-deb --build monav-0.3
  • Upload the resulting package to your web space:
    • scp monav-0.3.deb remotehost.yy:/htdocs/installers

I’m pretty sure there will be some stoning tomorrow, organized by some open source evangelists :) . I do not care. I just want to install three files on a smart phone. Nothing else.

Recent MoNav Additions

Displaying a tracklog using data (CC-by-SA)

Displaying a tracklog using data (CC-by-SA)

Since the last post, I spent a couple of hours writing code for MoNav. The follwing list provides an overview over the lastest additions of mine:

  • There are three map widgets in MoNav, the main map, the place chooser map, and the street choser map. As there was no central instance to control the zoom level, some nasty effects occured in case the user used the various zoom controls (F-keys, mouse wheel, zoom bar, zoom buttons). The zoom levels now are stored persistently for each individual map, and managed by one central method, setZoom(int). The code now provides reasonable default zoom values instead of using the maximum possible zoom at each startup.
  • On the N900, the backlight now remains switched on as long as there is GPS data. Of course the user can still switch off the backlight using the hardware switch.
  • MoNav centered the map only in routing mode. In the map view mode, the GPS position left the viewport without the map following its position. As a cyclist, it may well be that you don’t want to use routing, but want the map to follow the GPS position anyway. There is no preference option for this new feature. The map link to the GPS position gets lost as soon as the user pans the map. It gets set during application startup, when loading another map data set, the user selects “Goto Departure”, or the user selects “Goto Gps-Location”.
  • In routing mode, the auto rotation now is optional. In case you are used to maps which always show north up, this option is for you.
  • MoNav got GPS updates by the GPS subsystem every 5 seconds or so. Though the documentation of QGeoPositionInfoSource states that a default object gets updates each time there are any, calling setUpdateInterval(1000) clearly boosts the GPS performance of MoNav.
  • The user can now switch track logging on and off via the preferences.
  • The tracklog files created by MoNav now are proper UTF-8 encoded files, which JOSM no longer denies to consume.
  • MoNav now is capable of rendering the tracklog in red colour (see screenshot), which is a much sought-after feature for pedestrians, hikers and cyclists.