Greyscale spectrograms from MIRToolbox

I am using the excellent MIRToolbox for Matlab for a lot of sound analysis applications these days. It meets a lot of my needs, but there are a few things that I miss. Perhaps the most important one is the ability to make clean greyscale spectrograms. The regular mirspectrum function returns a colour spectrogram with lots of garnish, like this:

Such a spectrogram may be useful in some contexts, but not always. Often I just want a plain, greyscale spectrogram, like this:

Here is my trick to do this, based on mirspectrum:

a=miraudio('myfile.wav');
as=mirspectrum(a, 'Frame', 'Max', 3000);
asm=mirgetdata(as);
figure;
imagesc(asm);
axis xy;
lgrays=zeros(100,3);
for i=1:100
   lgrays(i,:) = 1-i/100;
end
colormap(lgrays);
set(gca,'XTick',[]);
set(gca,'YTick',[]);

Let me know if you have a better solution for doing this.

 

Published by

alexarje

Alexander Refsum Jensenius is a music researcher and research musician living in Oslo, Norway.

One thought on “Greyscale spectrograms from MIRToolbox”

Comments are closed.