Writing Audio Measurement Software

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Writing Audio Measurement Software

Postby CrocoDuck » Sat Oct 15, 2016 3:02 pm

Hi cool People!

I am starting looking deeper into audio applications development and I feel that in the open source landscape there is an important class of software that is missing (correct me if I am wrong): systems and signals measurement programs.

I am thinking of software like Baudline or Visual Analyzer (which are not open source), but more importantly of software intended to measure full impulse responses for linear systems or kernels for nonlinear systems. Most of these packages are libraries (not very user friendly) or commercial products.

I have studied these topics and produced tons of Matlab code that does that. All I would need to do is polish it up, add features like measurement error calculation, and release it. It would make possible to measure transfer characteristics of many systems.

Little problem: I don't know how to code very well outside high level languages like Matlab and Julia.

I started learning C++ and Faust, but I am not sure I can combine them into a project of this kind.

The thing would go like this:

  • Prepare a test signal(s)
  • Stream it to sound-card output(s) while simultaneously recording from sound-card input(s)
  • Make operations on windowed chunks of acquired data (involving fft in most cases)
  • Use the results of the previous steps to calculate a quantity of interest (mostly algebraic operations)

Any of you having a sort of idea at which language should I look at? I would like to avoid to use many languages, ideally I would like to use just one or two. I would also like to be able to design a GUI at some point. Maybe it could be possible with CSound?
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

progwolff
Establlshed Member
Posts: 44
Joined: Tue Sep 27, 2016 9:08 am
Location: Lübeck, Germany

Re: Writing Audio Measurement Software

Postby progwolff » Sat Oct 15, 2016 4:55 pm

Hi,

I just found this: http://sonicvisualiser.org/
Didn't try it yet, but it seems to be extendable by plugins (meaning you could implement FFT or what else you have in mind and use the provided frontend).

I am familiar with both Matlab and C++, so maybe I can help you with the implementation if you show me your scripts.

Edit: Seems like sonic-visualiser can't handle real time audio...

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Writing Audio Measurement Software

Postby CrocoDuck » Sat Oct 15, 2016 8:08 pm

Hi progwolff, thanks for your reply!

Sonic Visualiser seems a cool project, I will look into! However, I don't feel like it is what I need.

As for sharing code, I am afraid I have not much code which can be shared. As I said, I have tons of code, but most of it was written for university assignments and dissertation. As you could guess, it is very messy, hard to read and perhaps still covered by some university copyrights.

The rest of the code, the one not for uni, is implemented in Matlab apps I wrote at work, so it is property of the company I work for. I can of course share the algorithms themselves as a polished minimal working Matlab app (the algorithms are based on public knowledge), but I have to produce them first.

For the time being, one of the measurements I implemented follows closely Antonin Novak's Synchronized Swept Sine Method. The only difference is that mine is not a simulation: it uses dsp.AudioPlayer and dsp.AudioRecorder from Matlab to supply data in "realtime". Actually, Matlab is not very realtime and I have a solid 2 seconds of latency, which I remove after the data acquisition is run with methods similar to the ones I written in this pull request on DSP.jl.

Other methods involve measurements with random and pseudo-random noise, with or without reference channel. I have just a Julia example I can share I guess. It does not work... but perhaps I am better maybe even writing some pseudocode instead that clarifies the algorithms involved.
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

progwolff
Establlshed Member
Posts: 44
Joined: Tue Sep 27, 2016 9:08 am
Location: Lübeck, Germany

Re: Writing Audio Measurement Software

Postby progwolff » Sun Oct 16, 2016 10:28 am

Could you describe your needs a little more?
What exactly are the use cases?
Should the program be an effects plugin or a jack client?
Maybe you could draw some sketches of the GUI you have in mind?

I heard some lectures about signal processing and control engineering, but all from a computer science / engineering perspective. I don't know the workflows of an acoustician.

This seems to be an interesting project though, so I would like to start writing a framework with some more information.

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Writing Audio Measurement Software

Postby CrocoDuck » Sun Oct 16, 2016 3:17 pm

progwolff wrote:What exactly are the use cases?

Well, actually many. The theory to measure responses of systems does not vary among (classical) Physics fields. The only things that are peculiar in acoustics are post-processing things (Loudness metrics, Various Levels metrics, psicoacoustics models etc...), but I was not thinking to include them here. I would like this to be a tool to only measure (with errors) objective signals and systems properties. The only one feature I would add is the ability to export results to various formats. I would for sure support Matlab/Octave, Scilab, R and Julia binary formats (and cvs and similar), so that people can use measured quantities directly with their scripts or spreadsheets, without us having to mess with supporting 195264386 different metrics.

The fact that measuring systems and signals is not different in Acoustics means that the program can be used to measure electric circuit responses as well, for example.

progwolff wrote:Should the program be an effects plugin or a jack client?

I think it should be a standalone JACK client, so that the program outputs can be routed to sound-card channels using JACK, without the program having to mess with the routing itself. Perhaps it could be possible to have the measurements to be performed on recorded data, so the plugin approach could work as well I guess, but I confess I did not have this in mind.

progwolff wrote:Maybe you could draw some sketches of the GUI you have in mind?

Well, something along these lines (hopefully cooler than this):
Screenshot from 2016-10-16 15-19-08.png

So, pretty much I would like the program to be able to execute many measurements in parallel. There would be a sort of list where measurements can be added and configured. For example, measurement 1 could be a cross-spectrum based frequency response measurement using white noise and reference channel. As such, it would allocate for itself two jack inputs (for example measurement1_system, measurement1_reference) and one output (measurement1_testsigout). The user would connect those to the sound-card channels he wishes. Measurement 2 could be instead still a frequency response measurement, but with a MLS test signal, without reference channel. As such, it would need one input and one output (measurement2_system and measurement2_testsigout). All of this would be decided in the setup window.

I imagine the application to be multi-window or multi-tab. The plotting would happen in another window or tab, which would have a tab for each measurement. The plot layout for each measurement would be configured in the setup window as well. For measurements that support it, the test signal could be streamed to output also independently from the measurement.

To clarify this last point, many measurements would work like this: stream the test signal to a sound-card output while listening to input(s). Window out input chunks, calculate quantities of interest, store results. Repeat for a given amount of iterations. Calculate mean and error of the stored results.

So, if the user could start the stream, he could see in the plot tab the quantities being calculated for each windowed signal chunk, being able to understand whether the results are going to make sense. Then, he could hit the start button and trigger the data collection algorithm. Pretty much, Start/Stop Streaming would be a real-time version of the measurement, without averaging and error calculation, just display of result window after window.

Not all measurements support this tho. For example, the Ant Novak method or MLS methods need to record all the output of the test signal before to be able to calculate something.

When the start all button is pushed all the measurements cycles would start at the same time, in parallel. I would like this to happen so that the user can use multichannel sound-cards to make many measurements at the same time of many systems. I imagine that the user could save the measurements line-out (the list of parallel measurements), with all their setup, and either load them or decide to execute various line-outs one after the other, either with the use of a timer or a trigger that could be a keyboard press or other event (maybe even MIDI). In this case it could be useful for the program to remember to which JACK clients it has connect the various measurements tho...

There needs to be a section somewhere to calibrate. Digitalized waves go from -1 to 1, but voltage signals in input (output) to the sound-card might go from -2 V to 2 V. It is possible to calibrate both input and output using sine waves and an oscilloscope, so that the program can map numbers to -1 from 1 to voltages. The functionality should be provided. Finally, I would like support for transducer sensitivity. If one uses a microphone, the microphone will translate pressure [Pa] to volts. Sensitivity is the quantity governing the conversions between pressure and voltage and must be known so that one can measure the target physical quantity. I would like the user to be able to manage calibrations and transducers into a database of some kind.

So, as you can see... it is a lot of stuff. The way I was thinking of doing it was by baby steps. For example, one could start from the simplest measurement possible, implementing it as a command line JACK client. And then move to another, trying to keep in mind that after each step there should be software that can be modular enough to be plugged easily in the bigger picture.
You do not have the required permissions to view the files attached to this post.
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Writing Audio Measurement Software

Postby CrocoDuck » Wed Oct 19, 2016 7:56 pm

Uhm... actually, I think there is a better approach. Create a simple as possible JACK Client program for each task. Then, they can be used together freely and to run multiple parallel measurements, just make them to respond to jack transport. I think I will try to break the ice with few Faust based utilities and then switch to analyser programs written in C++...
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

progwolff
Establlshed Member
Posts: 44
Joined: Tue Sep 27, 2016 9:08 am
Location: Lübeck, Germany

Re: Writing Audio Measurement Software

Postby progwolff » Thu Oct 20, 2016 9:25 am

Sorry for the late reply.

The new semester just started and I have to get a few things managed before I could look at this in detail.

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Writing Audio Measurement Software

Postby CrocoDuck » Thu Oct 20, 2016 10:53 am

progwolff wrote:Sorry for the late reply.

The new semester just started and I have to get a few things managed before I could look at this in detail.


No problems! I am working 9-17 all week, so unfortunately I can study audio programming (and code stuff) only on weekends. It will be a slow project. But that's not a problem I guess.
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

User avatar
CrocoDuck
Establlshed Member
Posts: 787
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Writing Audio Measurement Software

Postby CrocoDuck » Mon Oct 24, 2016 11:38 am

Hey, I just found there are workshops on Audio Measurement by Fons Adriaensen, submitted at LAC 2014 and 2015:

Audio measurements using free software and some simple hardware (LAC 2014)
Slides Video

Audio measurement workshop (part 2) (LAC 2015)
Slides Video

There are many other similar topics across the various LACs.
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 1 guest