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

Gravity Freakin’ Waves!

How lucky we are to live in this time, the first moment in human history, when we detected gravity waves!  It was only 4 years ago in 2012 when the Higg Boson was discovered at the LHC, 2 years ago we landed on a comet, 1 year ago we flew past Pluto. Today, we detected gravity waves!

This will open up a whole new era of astronomy, potentially detecting gravity waves across our universe, unobstructed by gas and dust. We could potentially even get hints about the big bang that are older than the cosmic microwave background (CMB), the oldest light in the universe.  Gravity waves could also provide new clues and limits for the quantum theory of gravity, perhaps leading us to the theory of everything!

Way to go LIGO and everyone who worked on this achievement!

Science wins!

Posted in science | Leave a comment

Nsound spotted in the wild

Today I found a simple Python app that uses a TK GUI that wraps around Nsound’s AudioStream to resample .wav files:


Link: ResampleGui


Posted in nsound | Leave a comment

Nsound::biquad::FilterBank Work In Progress

I’ve made some good progress on a biquad filter bank on this branch.  I’ve been able to replicate Figure 10 from this reference:


That’s a filter bank with 4 individual biquad filters, here’s the C++ code that produced the plot:

The program also produces this output:

This work is to enable a parametric equalizer application, where an audio sample can be loaded and filtered in real-time while the user adjusts the filter parameters.

I’ve been using the picojson library and it was been really easy to use.

Posted in nsound, programming | Leave a comment

Nsound spotted in the wild

Here’s another link to someone using Nsound:

Posted in Uncategorized | Leave a comment