Swig is broken in Ubuntu 16.04 (xenial)

If you’re building a swig Python module and encounter errors like:

where Foobar is some class that is being wrapped, then you are encountering a swig-3.08 bug.  Unfortunately this is still the official package in Ubuntu 16.04.  You can vote for the issue here.

Until the package is updated, one can download and manually install an updated swig package by following the following recipe:


Posted in computing, programming | Leave a comment

Building jEdit from scratch

I’ve been using jEdit for decades as it provides a nice text editor with similar feature set as something I used at Raytheon called SlickEdit:

  • easily records a macro of all actions in the editor
  • easily playback the recorded macro
  • save the macro and map to keyboard shortcut
  • vertical selection

But lately some of my favorite plugins have stop working due to an old plugin that hasn’t been recompiled.  So I’ll try to document the process of checking out the jEdit code to recompile it from scratch and recompile the plugins I depend on.

If I have time, I might make a Docker image to do this so it’s easily repeatable for others too.

Getting the jEdit code

To checkout the jEdit code do:

Building jEdit

Now that we have the latest trunk code do:

Oops, I guess I need a java compiler.  I tried to install openjdk-9-jdk but got an error.  Stackoverflow suggested the command below.

This problem turned out to be a bug in apache ant 1.9.6.

Upgrading Apache Ant on Ubuntu 16.04

I couldn’t find an existing .deb package so I installed the binary from ant.apache.org. I used the following recipe:

Now jedit builds!


Posted in computing | 1 Comment

P5js player widget in pure javascript

Okay, so I got really excited about p5js, checkout their examples page.  But I struggled a little bit to include a sketch on my wordpress blog, the canvas was showing up at the bottom of the website as I discussed in my previous post.

I got some help from the folks at p5js and they pointed out their embedding page.  While there I found the p5js-widget tool.  It was very close to what I wanted, but since I’m about to do more sketches, I thought it would be a good project to try to write my own widget.


I still have a few bugs to iron out. p5js-player is on github.

Posted in computing, programming | Leave a comment

Embedding p5.js processing sketches in WordPress posts

Yesterday I discovered the p5.js project by watching this video series.  I got excited and wrote my first sketch “bouncing points,” a classic that I once wrote as a java applet back in the 1990’s.  Very simple to do with p5.js.  I look forward to writing more experiments!

ERROR: Your browser doesn’t support the object tag!

javascript works fine in WordPress, one just switches to text mode while editing the post and paste in <script> tags and it works fine.  p5.js will even render the canvas correctly.  I did run into a problem though, the p5.js canvas element gets inserted at the bottom left of the page, below all the WordPress content:

As you can see, you might not notice that it’s working unless you scroll all the way down the page!

The solution: object tag

I found a workaround, I uploaded the p5.js code to my website, then in the WordPress post, I use an object tag to embed it into the post:

You have to size the object tag large enough for the created canvas to show up without scrollbars but it looks good on my PC.

Look, I can even insert a 2nd canvas!
ERROR: Your browser doesn’t support the object tag!

It also looks to be running fine on my Android phone! Success!

Posted in computing | 10 Comments

Nsound rewrite 2016

The Nsound code base is old, (10 years! I can hardly believe that).  Obviously I’m a much better developer today (:P), and there’s lots of things that need cleaning.  Maintenance is becoming a burden, the build process is complex, it’s difficult to debug.

So I am about to start to rewrite all of nsound, here are some of the directions I want to go:

  • C++14
  • float32 only (float64 is overkill, perhaps Buffer<T>?)
  • header only (avoid the need for .so or .dll)
  • serialize with JSON
  • switch to Boost.Python (dump swig)
  • create generic filter kernel objects
    • separate kernel design from filter objects
  • generic functions on std::vector or std::array
    • provide scipy-like signals module suite
  • combine AudioStream and Buffer into one object, no need to maintain both
  • Boost unit tests from the beginning
  • rewrite all the SCons files to keep it simple stupid!
    • move scons utilities & tests into proper tools (and share with the rest of the world!)

You can help out too! Working on open source is a great way to strengthen your skills!

Posted in nsound, programming | Leave a comment

Nsound broken on Ubuntu 16

I’m sad to report that nsound is broken by default on Ubuntu 16 until I get time to fix it.  The main issue is that the default swig package is swig3.0, for some reason this breaks most things in the Python module.

I’ve created an issue here.

Installing the swig2.0 package fixes most of the problems.


Posted in nsound, programming | Leave a comment

Stay GUI neutral with mplapp and Matplotlib

I’ve just released a package of widgets implmented with Matplotlib, this allows you to create simple interactive applications without having to write specific GTK, TK, QT code.  It provides simple layout with horizontal and vertical boxes, just stuff widgets in them and it will do the layout for you.

The code is on GitHub: mplapp

Install with pip:


Posted in Uncategorized | Leave a comment

Python pith

I just wrote a little tool to help with your Python development called pith.

Checkout the release.

Posted in programming | Leave a comment

Ranking Photos With Python

Photo Ranking With Python


What is this?

This is a tool that uses the Elo Ranking System written in Python using:

  1. Matplotlib
  2. Numpy
  3. exifread


  • Auto image rotation that the camera recored in the EXIF meta data
  • Persistent state from execution to execution so you can pickup where you left off
  • New photos that are added to the photo dir after initial ranking are picked up

Install dependencies

Use your system’s package manager to install Matplotlib & Numpy if you don’t already have them installed.

Next, you can use pip to install the EXIF image reader package exifread:

How to rank photos

Once you have to dependencies installed, run rank_photos.py on the command line passing it the directory of photos.

For example, iterate over all photos three times:

After the number of rounds complete, ranked.txt is written into the photo dir.

Ranking work is cached

After completing N rounds of ranking, a file called ranking_table.json is written into the photo dir. The next timerank_photos.py is executed with the photo dir, this table is read in and ranking can continue where you left off.

You can also add new photos the the directory and they will get added to the ranked list even though they weren’t included previously.


Suppose there is a dir containing some photos:

These photos haven’t been ranked yet, so lets rank them, in this example, 1 round:

Once the number of rounds complete, the ranked list is dumped to the console:

The ranked list is also written to the file ranked.txt. The raw data is cached to the file ranking_table.json:

If you run the program again, the cached data is loaded and new match ups can be continued using the cached data. If new photos were added, they also get added to the table data and are included in match ups.

The code has been posted to github.

Posted in computing, programming | Leave a comment

Listening to Gravity Waves with Nsound!

Gravity Wave Signal Processing

With all the excitement about LIGO and gravity waves, I’ve downloaded the raw GW150914 detection data for from here.  The file I downloaded was 32 seconds sampled at 4096 samples per second.

Next I reviewed some of the LIGO tutorial on signal processing here, and proceeded to write a Python script using Nsound to process the data.  Talk about finding a needle in a haystack!

Raw time-series data plot, the detection event occurs around 16.5 seconds in this plot:


Where’s the signal?  It’s buried in noise!  Mostly low frequencies.  But with the help of a band pass filter from 80 to 280 Hz, we can get a hint of the signal:


Zooming in:


Plotting the spectrogram:



And finally, we can listen to the universe!  The detection is a single blip as show above, however for your listening pleasure I’ve repeated the blip 4 times:

Link to the .wav here.

Python Code

Here is the Python code I used which uses my Nsound Python library:



Posted in computing, nsound, programming, science | Leave a comment