DSPRelated.com
Forums

frequency masking help

Started by josh October 24, 2010
Hi,

very new to all this, so aplogise if this info is available;

I want to be able to analyse 2 sounds,and identify where their frequencies mask eachother (based on gain, frequency etc).

is there an equation which covers frequency masking, or better still is their matlab code which will calculate this?

Cheers,

Josh
Hi Josh,

If I understand you correctly, it sounds like you have 2 different audio files, each of which has a recording of a different sound, and you want to be able to tell if and where the two sounds will have overlapping frequency content? If so, probably the easiest approach would be to just compute FFTs of the two signals and examine their respective spectra. You should be able to tell whether their frequency content overlaps, particularly if the signals aren't too noisy.

A few things to keep in mind (I don't know what your level of expertise is with Matlab / DSP, so my apologies if I insult your intelligence):

1. You can use Matlab's wavread() function to load an audio file into the Matlab workspace.

2. When plotting the two FFTs, you'll want to make sure you check the sampling frequencies of the two signals to make sure you're labeling your frequency axis correctly

3. Unless each audio file consists of only a single burst of sound, with no silent periods, changing tones, etc, you'll need to make sure you're taking multiple FFTs to make sure you're looking at the spectrum of a portion of the signal where you're actually hearing the sound you're interested in. Computing a spectrogram (use the Matlab spectrogram() function) might be helpful for this; it's probably not accurate enough to get more than a first-order guess at whether masking is occurring, but it will help you to know which parts of the two files you should be comparing.

Hope this helps - please let me know if (a) I misunderstood you and didn't really answer your question, (b) you didn't understand something I wrote, or (c) if you need help writing Matlab code to accomplish this.

--Tom

Hi,
>
>very new to all this, so aplogise if this info is available;
>
>I want to be able to analyse 2 sounds,and identify where their frequencies mask eachother (based on gain, frequency etc).
>
>is there an equation which covers frequency masking, or better still is their matlab code which will calculate this?
>
>Cheers,
>
>Josh
>
Hi,
I have a picture like this (attachment), I want to ask if I wanted to show the
deep red color, or red, or yellow, or bright blue, or blue, or dark blue only.
I ask explanation how to display only one color section.

I really hope anyone can help me, thank you for your help.

Nana
Hi Nana,

One approach would be to load the image into Matlab using the imread() command - something like

im_data = imread('filename.jpg');

This would store an M x N x 3 array in im_data. This array contains the RGB values for each pixel in the image. So, all you'd need to do at that point would be to loop through all the pixels in the image and set each pixel to black if it doesn't match the color you want to display. You could have a loop like this:

% Suppose you've decided on an RGB range for some color, and you have
% the following variables initialized:
% R_hi upper bound on acceptable red level
% R_lo lower bound on acceptable red level
% G_hi upper bound on acceptable green level
% G_lo lower bound on acceptable green level
% B_hi upper bound on acceptable blue level
% B_lo lower bound on acceptable blue level

new_im = zeros(size(im_data)); % Initialize an output image array

% Start looping
for i = 1 : size(im_data, 1)
for j = 1 : size(im_data, 2)
R = im_data(i,j,1);
G = im_data(i,j,2);
B = im_data(i,j,3);

% Test whether the pixel matches the color you want to show
if ~((R >= R_lo && R <= R_hi) & ...
(G >= G_lo && G <= G_hi) & ...
(B >= B_lo && B <= B_hi))

% It doesn't match, so set it to black
new_im(i,j,:) = [0, 0, 0];
else
% It does match, so copy the pixel unchanged
new_im(i,j,:) = im_data(i,j,:);
end
end
end

% Now display the new image
figure;
imshow(new_im);

I haven't actually run this code (don't have Matlab on this machine) but as long as you define the RBG bounds appropriately, it should do what you wanted. Let me know if this works out for you, or if you have any more questions.

--Tom