Free DSP scripts for measuring audio stuff

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

user 37518

Well-known member
Joined
Nov 15, 2008
Messages
2,221
Location
-
Hi everyone,

After being somehow "reprimanded" and suggested to make some scripts by Bo Deadly, I decided to write some Octave/Matlab scripts and offer them for free here in the GDIY community. I've noticed that people want to perform several audio measurements but there is no special software for it or they either need to download different one trick pony apps to do it (or spend thousands in an AP), they also either have to rely on their DAW tools which are not specifically tailored towards audio measurement or use REW , which is great, but it doesn't cover everything and it is not as powerful/customizable as what can be achieved with Octave/Matlab.

For those of you who don't know, Matlab is a mathematics software which allows to basically do anything ranging from biology to avionics, but it is very costly, Octave is essentially the freeware version of Matlab and in 99% of the cases the commands are the same. I have access to Matlab because I teach EE at a university but Octave can be downloaded freely.

This will be a trial and error endeavor and you will be—if you accept—my Guinea pigs in order to test the scripts. I encourage everyone who wants to add or improve some things to the scripts to do it, but rather than posting them in an new post, send them to me with their mods and if I find them to be beneficial, I'll include the mod in the next script version along with the name of the contributor, and I'll post it in the same place Also, if some of you decide to make your own scripts, we can include them as well.

I'll post everything in a Wordpress site I will create, and I will post direct links to the scripts in the second post of this thread.


At first, things might be shaky, specially when it comes to configuring the audio interface with Matlab/Octave, since everyone has different interfaces and so on, but I know that eventually we will find the easiest way, I'm guessing that the solution will require the "Asio4All" drivers.

I don't know if they will work on Mac (in case you were going to ask), the scripts will be tested in a PC, the rest is up to you or to whomever wants to pursue this route.

Does this seem like something you guys would find useful? I would certainly enjoy doing it as a side project. I just ask that if you use the scripts for something commercially or to publish a paper, or whatever, that you give me and those who contributed due credit.
 
Last edited:
Here is the preview of the first project I'll be uploading, I think you will enjoy it!

A lot of people like to do "A-B" or "null tests" to check if two pieces of gear are equal, or if the plug-in emulation is the same to the hardware, etc.... The problem with null tests, or rather, the problem with the way most people conduct them is that they perform the null test in the time domain, when they should be doing it in the FREQUENCY DOMAIN. The problem with null tests is that they depend greatly on both signals being amplitude matched AND phase matched, if there is even a slight mismatch there will be a residual and people will draw false conclusions like "the plug-in doesn't sound the same to the real deal".

The idea of the script I will be uploading is that the user can import two audio files and the program will perform the null test in the frequency domain.

Here is the prototype to exemplify:

I generated a white noise signal called "signal A" , I then copied this signal, delayed it one sample (around 22.7 microseconds) and added to it a pure 1kHz tone -40db below the peak level of the noise, this is called "signal B", here are the audios, can you hear the 1kHz sine wave in Signal B? I bet you can't ** WARNING: THESE FILES ARE LOUD**




I bet you can't see it either:

signals.png



After making the null test as everyone does, that is inverting the polarity of one channel and summing them this is what we get, what is called the "residual":



And this is the graph:



residual_time_domain.png

From the audio and from the residual graph, one would conclude that the signals are completely different, and in fact, if I didn't tell you, you wouldn't even know the 1kHz tone is there. But look at what happens if we do the null test in the frequency domain:

mag_phase_res.png

Look who is lurking up there at 1kHz (10^3Hz)! the sine wave, everything at zero means it is equal in both signals, everything different from zero means it is different in both signals, the rise in phase at higher frequencies is due to the fact that I not only added the 1kHz signal but I also delayed the original white noise signal one sample as I explained earlier. As you can see both signals are identical with the exception of the 1kHz tone.

If we convert from the frequency domain back to the time domain we get the residual and we can also listen to it, it is so small that I had to amplify it a lot for you to listen to it, here it is



graph_freq_residual.png


As soon as I finish the script I will be uploading it
 
Last edited:
Looks good. All my E stuff is packed away but I'll follow along as much as I can.

I assume by "null test in the frequency domain" you mean doing FFTs and then diffing the magnitudes by subtracting one from the other?

My only recommendation at this point would be to try to make it as accessible as possible so that people can actually use it. If you just post a .m file I think the barrier to getting started could be a little too high for most people.
 
Looks good. All my E stuff is packed away but I'll follow along as much as I can.

I assume by "null test in the frequency domain" you mean doing FFTs and then diffing the magnitudes by subtracting one from the other?

My only recommendation at this point would be to try to make it as accessible as possible so that people can actually use it. If you just post a .m file I think the barrier to getting started could be a little too high for most people.
Yeap, I am doing FFTs. To do the null test in the frequency domain and obtain the residual in time domain so you can actually listen to an audio file you need the entire FFTs including phase, not diffing the magnitudes, but since most people will only care about the magnitude residual when looking at graphs, I will also include the differences in magnitude of the FFTs as you mention, I am also applying windowing, nothing really complicated.

Regarding accessibility I will try to make it as fool proof as possible and provide a small "read me " file. Basically all you will have to do is click on the "play" button at the top.
 
Last edited:
Regarding accessibility I will try to make it as fool proof as possible and provide a small "read me " file. Basically all you will have to do is click on the "play" button at the top.
Ah. I've never used the IDE. I always used octave-cli.

You could also use uicontrols to create a custom UI (never used that either).

The ideal installation IMO would be to unpack a package, set OCTAVE_PATH in a .sh or .bat script, run it, get a UI for a pointy-clicky experience, set your USB interface in loopback configuration, click "Capture" and you should get an FFT showing dBFS.

People will want instant positive feedback that it's actually working. That would be step 0. Then add controls (tabs maybe) for different measurements like your frequency domain null test.
 
Ah. I've never used the IDE. I always used octave-cli.

You could also use uicontrols to create a custom UI (never used that either).

The ideal installation IMO would be to unpack a package, set OCTAVE_PATH in a .sh or .bat script, run it, get a UI for a pointy-clicky experience, set your USB interface in loopback configuration, click "Capture" and you should get an FFT showing dBFS.

People will want instant positive feedback that it's actually working. That would be step 0. Then add controls (tabs maybe) for different measurements like your frequency domain null test.
Well, maybe you could help me out with the whole user interface, I can only do so much.
 
This is a spectacular effort, thanks very much indeed for doing this and sharing with the community. I can see it being an immensely valuable resource.
 
Great! Thank you for doing this.
This is a spectacular effort, thanks very much indeed for doing this and sharing with the community. I can see it being an immensely valuable resource.
You are welcome! Its a joy for me and, even though I am not a digital guy, I do enjoy DSP. However, I am not a programmer in the sense that I really don't know anything about graphical interfaces, user experience, app development and such. I will develop the codes and scripts and, if anyone here wishes to take them to another level and make them more accessible, I think it would benefit everyone. I will still try to make a simple guide for people to use them. If people with little experience can manage to build a G1176 from scratch, I think they can manage to load these scripts in Octave.
 
I'll be glad that you add a warning next time you put audio files white noise FULL SCALE 😂
Haha sorry for that. My laptop has very weak speakers so when I tested them I didn't think that some people would listen with headphones or studio monitors. Just added the warning, but hey, there is worse sounding and louder bad music out there than white noise and I receive no warning whatsoever.
 
Just figured out something, I noticed that other thread where they mention Labview software, and it turns out that I know how to program in Labview and it accepts Matlab code in it (I think there are some instructions not recognized, whatever, I have to check) so I could definitely do a self-contained user interface with that. Don't know why I didn't think of that before. Anyway, lets go little by little....
 
This sounds great, I’d like to be a part of this. Also thank you for taking the initiative. I can’t wait to see how it unfolds.
 
I would as well. One of my hats is doing testing in the IT field, plus I'm a wanna-be EE and a pretty decent audio dude.

I need to focus on a few immediate matters here at home, so my time is limited for the short term, but I'll follow along for certain :) When the time is right I'll pipe up.

I just became aware of Octave (courtesy of the thread @user 37518 refers to) so I'll become familiar with it so I'm useful. Thanks again.
 
This is the first script I will be uploading very soon, critiques accepted.... Abbey will hate me when I say "invert the phase" sorry Abbey....


 
Last edited:
This is the first script I will be uploading very soon, critiques accepted.... Abbey will hate me when I say "invert the phase" sorry Abbey....




"Playback on other websites has been disabled by the video owner"
It seems if you want the embedded link to work on gdiy you need to make some kind of settings change through your YouTube account.
 
I have a passing interest in FFT... a few years ago I was coding FFT in machine language for a next generation drum tuner. I made good progress shotgunning a multiple pitch sine wave test signal using the DSPic's built in DAC. With FFT amplitude readings I could quickly scan a drum head for resonances and zero in on the dominant resonances (for drum tuning I generally use the lowest two, fundamental and first overtone).

I got tangled up extracting both level and phase information from the FFT to execute my drum tuning algorithm. I could fall back to my old way for measuring phase (comparing send to return sinewave signals) but FFT phase output would be slicker.

At this point this is just of academic interest to me since I shut down my drum tuner business almost 2 years ago (only one more year to go on my 3 year warranty, so far zero service requests). :cool:

JR
 
"Playback on other websites has been disabled by the video owner"
It seems if you want the embedded link to work on gdiy you need to make some kind of settings change through your YouTube account.
Can you give it another try please?
 
Back
Top