From: Wayne King on
"John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1i0ro$n8v$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1h6ad$qqe$1(a)fred.mathworks.com>...
> > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> > > Hey Everybody,
> > >
> > > I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
> > >
> > > -John
> >
> > Hi John, you can also just use logical indexing.
> >
> > Say you have a matrix A
> >
> > A = randn(10,10);
> >
> > and you want to set all values in A in the interval (-0.5,0.5) to zero
> >
> > A(abs(A)<0.5) = 0;
> >
> > However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.
> >
> > Wayne
>
> Hey Wayne,
> Thanks for the help. I actually tried using logical indexing and it did what I needed it to, but I also found that you're right about this not being the best way to filter audio data. I think I have to use the Signal Processing Toolbox and create a filter (which I have no idea how to use yet) and that should probably be a much more efficient way to filter my data.
> -John

I think you're right John. You can design a number of useful filters with the Signal Processing Toolbox. Write back if you get stuck with more details about your application and how your data are structured, e.g. do you have matrix of data, or is your audio signal one long vector (Nx1, or 1xN), etc. Make sure to give people adequate details so that they can help you like the sampling frequency.

Wayne
From: John Lenehan on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <i1i2ec$5ff$1(a)fred.mathworks.com>...
> "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1i0ro$n8v$1(a)fred.mathworks.com>...
> > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1h6ad$qqe$1(a)fred.mathworks.com>...
> > > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> > > > Hey Everybody,
> > > >
> > > > I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
> > > >
> > > > -John
> > >
> > > Hi John, you can also just use logical indexing.
> > >
> > > Say you have a matrix A
> > >
> > > A = randn(10,10);
> > >
> > > and you want to set all values in A in the interval (-0.5,0.5) to zero
> > >
> > > A(abs(A)<0.5) = 0;
> > >
> > > However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.
> > >
> > > Wayne
> >
> > Hey Wayne,
> > Thanks for the help. I actually tried using logical indexing and it did what I needed it to, but I also found that you're right about this not being the best way to filter audio data. I think I have to use the Signal Processing Toolbox and create a filter (which I have no idea how to use yet) and that should probably be a much more efficient way to filter my data.
> > -John
>
> I think you're right John. You can design a number of useful filters with the Signal Processing Toolbox. Write back if you get stuck with more details about your application and how your data are structured, e.g. do you have matrix of data, or is your audio signal one long vector (Nx1, or 1xN), etc. Make sure to give people adequate details so that they can help you like the sampling frequency.
>
> Wayne

I haven't had much experience using the Signal Processing Tool (none really) so I wouldn't say I'm stuck, I'm just a little bit confused on where to begin. My data is a WAV file, and its also stereo, so it is a matrix, but I only really need to use one of the columns so I have a single vector of usable data. The sampling frequency is 44,000 since it is a WAV file. My overall goal is to simply remove the static noise from the file. I have some lower sounds that I would like to keep so the filter has to be somewhat precise as to only remove certain sections. What I want to do seems easy and probably is, but the filter design seems like it can do so much that even something simple can be difficult for a beginner like me.
From: Wayne King on
"John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1ich0$j4g$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1i2ec$5ff$1(a)fred.mathworks.com>...
> > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1i0ro$n8v$1(a)fred.mathworks.com>...
> > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1h6ad$qqe$1(a)fred.mathworks.com>...
> > > > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> > > > > Hey Everybody,
> > > > >
> > > > > I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
> > > > >
> > > > > -John
> > > >
> > > > Hi John, you can also just use logical indexing.
> > > >
> > > > Say you have a matrix A
> > > >
> > > > A = randn(10,10);
> > > >
> > > > and you want to set all values in A in the interval (-0.5,0.5) to zero
> > > >
> > > > A(abs(A)<0.5) = 0;
> > > >
> > > > However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.
> > > >
> > > > Wayne
> > >
> > > Hey Wayne,
> > > Thanks for the help. I actually tried using logical indexing and it did what I needed it to, but I also found that you're right about this not being the best way to filter audio data. I think I have to use the Signal Processing Toolbox and create a filter (which I have no idea how to use yet) and that should probably be a much more efficient way to filter my data.
> > > -John
> >
> > I think you're right John. You can design a number of useful filters with the Signal Processing Toolbox. Write back if you get stuck with more details about your application and how your data are structured, e.g. do you have matrix of data, or is your audio signal one long vector (Nx1, or 1xN), etc. Make sure to give people adequate details so that they can help you like the sampling frequency.
> >
> > Wayne
>
> I haven't had much experience using the Signal Processing Tool (none really) so I wouldn't say I'm stuck, I'm just a little bit confused on where to begin. My data is a WAV file, and its also stereo, so it is a matrix, but I only really need to use one of the columns so I have a single vector of usable data. The sampling frequency is 44,000 since it is a WAV file. My overall goal is to simply remove the static noise from the file. I have some lower sounds that I would like to keep so the filter has to be somewhat precise as to only remove certain sections. What I want to do seems easy and probably is, but the filter design seems like it can do so much that even something simple can be difficult for a beginner like me.

Hi John, Here's an example of what you can do.

% assume that x contains your Nx2 matrix from wavread
y = x(:,1); % extract one of the columns
% now start to design your filter
% start by specifying your filter response
h = fdesign.lowpass('Fp,Fst,Ap,Ast',8e3,8.4e3,0.5,60,44.1e3);
% design your filter--Here an FIR equiripple filter, but not your only option
Hd = design(h,'equiripple');
% Look at your filter response
fvtool(Hd)
% apply your filter to your data
yfilt = filter(Hd,y);
% play the audio
soundsc(yfilt,44.1e3);

Because I do not know your signal (whether it's music or speech, etc.) I just took a shot in the dark and designed a lowpass filter that passed everything below 8,000 hertz. If your data is speech, the static will have energy at higher frequencies not present in the speech signal. If it is indeed speech, you can easily move the passband frequency (8,000 hertz) lower, probably down to around 4,000 hertz with no loss of intelligibility.

Hope that helps,
Wayne
From: John Lenehan on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <i1n92u$em9$1(a)fred.mathworks.com>...
> "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1ich0$j4g$1(a)fred.mathworks.com>...
> > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1i2ec$5ff$1(a)fred.mathworks.com>...
> > > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1i0ro$n8v$1(a)fred.mathworks.com>...
> > > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i1h6ad$qqe$1(a)fred.mathworks.com>...
> > > > > "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> > > > > > Hey Everybody,
> > > > > >
> > > > > > I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
> > > > > >
> > > > > > -John
> > > > >
> > > > > Hi John, you can also just use logical indexing.
> > > > >
> > > > > Say you have a matrix A
> > > > >
> > > > > A = randn(10,10);
> > > > >
> > > > > and you want to set all values in A in the interval (-0.5,0.5) to zero
> > > > >
> > > > > A(abs(A)<0.5) = 0;
> > > > >
> > > > > However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.
> > > > >
> > > > > Wayne
> > > >
> > > > Hey Wayne,
> > > > Thanks for the help. I actually tried using logical indexing and it did what I needed it to, but I also found that you're right about this not being the best way to filter audio data. I think I have to use the Signal Processing Toolbox and create a filter (which I have no idea how to use yet) and that should probably be a much more efficient way to filter my data.
> > > > -John
> > >
> > > I think you're right John. You can design a number of useful filters with the Signal Processing Toolbox. Write back if you get stuck with more details about your application and how your data are structured, e.g. do you have matrix of data, or is your audio signal one long vector (Nx1, or 1xN), etc. Make sure to give people adequate details so that they can help you like the sampling frequency.
> > >
> > > Wayne
> >
> > I haven't had much experience using the Signal Processing Tool (none really) so I wouldn't say I'm stuck, I'm just a little bit confused on where to begin. My data is a WAV file, and its also stereo, so it is a matrix, but I only really need to use one of the columns so I have a single vector of usable data. The sampling frequency is 44,000 since it is a WAV file. My overall goal is to simply remove the static noise from the file. I have some lower sounds that I would like to keep so the filter has to be somewhat precise as to only remove certain sections. What I want to do seems easy and probably is, but the filter design seems like it can do so much that even something simple can be difficult for a beginner like me.
>
> Hi John, Here's an example of what you can do.
>
> % assume that x contains your Nx2 matrix from wavread
> y = x(:,1); % extract one of the columns
> % now start to design your filter
> % start by specifying your filter response
> h = fdesign.lowpass('Fp,Fst,Ap,Ast',8e3,8.4e3,0.5,60,44.1e3);
> % design your filter--Here an FIR equiripple filter, but not your only option
> Hd = design(h,'equiripple');
> % Look at your filter response
> fvtool(Hd)
> % apply your filter to your data
> yfilt = filter(Hd,y);
> % play the audio
> soundsc(yfilt,44.1e3);
>
> Because I do not know your signal (whether it's music or speech, etc.) I just took a shot in the dark and designed a lowpass filter that passed everything below 8,000 hertz. If your data is speech, the static will have energy at higher frequencies not present in the speech signal. If it is indeed speech, you can easily move the passband frequency (8,000 hertz) lower, probably down to around 4,000 hertz with no loss of intelligibility.
>
> Hope that helps,
> Wayne

Wow, that does help a lot. You have been an amazing help. Thank you so much, you made my life a lot easier.
John