Tuesday 6 June 2017

Gnuplot/C Now Supports Multiplot Capabilities

A new version of Gnuplot/C has been uploaded to SourceForge that includes Multiplot capabiliites : https://sourceforge.net/projects/gnuplotc/. A simple example is shown in the following image :


In addition to handling multiplots, Gnuplot/C also includes a number of updates and optimizations for faster graph updates, particularly in 2D plots.

The above graph is taken from the SigLib DSP Library ToneLevels example. The plot is from some real data, that is the envelope of a sampled sinusoid.  The tone starts at -8 dBFS and then the -20 dB button is pushed. You can see there is a glitch when the output changes, this is caused by the switch within the signal generator.

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.

Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

Tuesday 21 February 2017

Numerix Host Library .wav file read / write functions updated

New functions have been added to the Numerix Host Library to include new .wav file read/write functions from C/C++ programs.

Here is a summary of the .WAV file header format :

    4 bytes     "RIFF"      ID for a RIFF file
    4 bytes     xxxx        Length of waveform (Bytes)
    8 bytes     "WAVEfmt "  ID for a .WAV file
    4 bytes     xxxx        Size of format section (Bytes)
    2 bytes     xx          Format - "1" indicates PCM data
    2 bytes     xx          Number of channels
    4 bytes     xxxx        Sample rate (Hz)
    4 bytes     xxxx        Data rate (Bytes per second)
    2 bytes     xx          Bytes per sample (rounded up)
    2 bytes     xx          Bits per sample
    /additional informaiton that may be used in more complex wave files/
    4 bytes     "data"      ID for data section
    4 bytes     xxxx        Length of data section (Bytes)

The .wav file functions allow reading and writing of .wav files from standard C/C++ programs and includes full source code.

The library can be downloaded from : http://numerix-dsp.com/files/.

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.
Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

Thursday 19 January 2017

Gnuplot/C On A Mac

I recently updated my Mac to Big Sur and found the previous Gnuplot (http://gnuplot.info/) installation procedure using Homebrew is no longer the best method so I've updated this blog post.

First install Gnuplot on Big Sur:
If you have MacPorts (https://www.macports.org/) installed then update it:
    sudo port -v selfupdate
If you do not have MacPorts installed then you can install it by opening the following URL:
Install gnuplot using MacPorts:
    sudo port install gnuplot +wxwidgets
(I like the wxwidgets API)

Perfect, lets test gnuplot :

$ gnuplot
gnuplot> plot sin(x)

We should now see a nice little sinusoid graph.

Now let's build Gnuplot/C :
$ cd gnuplot_c/src/
$ make -f makefile.macos

Now let's test Gnuplot/C :
$ cd gnuplot_c/examples/
$ ./br.sh LinesAndPoints

We should now see the graphs plotted.

Note, if you see the following message:
sh: /dev/nul: Permission denied

Then you need to do the following:
$ sudo mknod /dev/nul c 1 3
$ sudo chmod 666 /dev/nul

Now let's test Gnuplot/C again:
$ ./br.sh LinesAndPoints

Excellent. All running nicely :-)

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.
Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

Sunday 8 January 2017

Some Thoughts On Benchmarking Applications On A Pentium PC (Windows/Mac/Linux)

The ability to benchmark DSP algorithms to check that they execute in real time is a key part of the DSP development process. I've written several blog posts on the subject including :

http://blog.numerix-dsp.com/2013/01/how-to-benchmark-some-c-code-or.html
http://blog.numerix-dsp.com/2015/01/timing-code-running-on-xmos-xcore.html

While benchmarking code to run on a traditional DSP or embedded microcontroller is a relatively simple task, due to the deterministic nature of DSP architectures, doing the same on a Pentium PC is quite tricky. I've recently tried two of the most common techniques for benchmarking DSP algorithms on a Pentium PC. The two techniques are :

    Reading the Pentium Time Stamp Counter Register : http://stackoverflow.com/questions/9887839/clock-cycle-count-wth-gcc
    Instruction counting using GDB : http://stackoverflow.com/questions/21628002/counting-machine-instructions-using-gdb

The Time Stamp Counter option has a lot of disadvantages when used in a multi-tasking OS due to the whole task switching happening in parallel with the application.
The inital overhead calculation may take longer, due to a task switch, so the final benchmark may take less than 0 cycles when subtracting the overhead of calling the timer functions.

The GDB solution counts instructions but does not allow for pipelining, caching, and run-time parallel instruction execution.

So far the only option I have come up with is to use a statistical analysis of the results to get an approximation to how efficient an algorithm is.

Here are some results from some different filter functions that I have benchmarked (more details in an upcoming post about the different filtering functions).

The TSC technique shows that runtime parallelization of code gives better than 1 instruction per cycle execution but each mode was executed a twenty times and the average result was taken so take note of the problems listed above.

MODE    GDB         TSC
1              2514          975
2              1171          754
3              1188          547

In summary, GDB instruction counting gives a good approximation to how efficient an algorithm is but the Time Stamp Counter solution gives a better estimate to the actual number of CPU clock cycles are required.

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.
Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/

Tuesday 3 January 2017

Gnuplot/C Update II

A new version of Gnuplot/C has been uploaded to SourceForge that includes polar plotting capabiliites : https://sourceforge.net/projects/gnuplotc/.

This adds logarithmic x-axis support to the existing plot types.

Here is an image showing the capabilities :


The DTMF tones were generated using the SigLib DSP library.

If you have found this solution useful then please do hit the Google (+1) button so that others may be able to find it as well.
Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/