        Filtering Techniques
 Quantization  Create a for loop that will search through the transformed sound wave and eliminate (set to zero) all frequencies with coefficients below a certain value to be determined. The for loop used in this type of filtering is as below, where L is the transformed sound wave, and z is the quantization level: For i = 1: length(L);If abs(L(i)) < z;L(i) = 0;end endThe optimum frequency value to use in the elimination could be found using spectrograms; by observing the spectrograms of the modified and unmodified signals, you can compare their relative energies and also observe which frequencies your loop is cutting out.Quantization will result in a decent compression, with a good quality sound.
 1.
 2.
 Eradication of a continuous range of a frequencies. By first plotting the graph of the absolute value of our waveform in the frequency domain we found it to have an envelope that dropped off exponentially. After studying this graph, a frequency was chosen that seemed to mark the end of frequencies with any great significance in our waveform; thus, eliminating all frequencies above this value would not harm our signal's sound quality to any great extent. The for loop below was used in cutting off this range, where Fc is the 'cutoff' frequency:for i = [Fc: 219 - Fc ]R[i] = 0;end
 3
 Filtering every odd frequency. Another for loop was created, this time to eliminate (set to zero) every second frequency. for i = 1: length(L);L(2*i) = 0;endThis type of filtering will produce a waveform inaudibly different from the original, due to fact that each adjacent frequency is only very slightly different. However, the level of compression is not ideal.
 Retaining only one frequency in x. Here only one frequency was retained out of a group of x consecutive frequencies. The for loop below was created to carry out the filtering (here, x = 5 and L is the signal to be filtered):for i = (1: 104852);L((5*i) + 1: (5*i) + 4) = 0;end
 4.
 5.
 Variable filtering. In this filtering method, the frequency spectrum is separated in a log4 fashion, where fs = sampling rate, frequency = 44160, and n = sample length.  Freq                       samples                                      Method 1                    Method 2 0-20                       0 - 20n/fs                                  remove all                    remove all 20-80                     20n/fs+1 - 80n/fs                     remove none                remove none 80-320                   80n/fs+1 - 320n/fs                          1/2                                1/5 320-1280               320n/fs+1 - 1280n/fs                      2/3                                2/5 1280-5120             1280n/fs+1 - 5120n/fs                    3/4                                3/4 5120-20000           5120n/fs+1 - 20000n/fs                  4/5                                4/5 20000-fs/2             20000n/fs+1 - n/2                      remove all                    remove all Thus, in method 1, we remove half the samples in the frequency range from 81 to 320 hertz, two out of three samples from 312 to 1280 Hertz, etc. etc. Method 2 has a constant denominator of 5. The functions below will implement this compression, where fs = sampling rate, frequency = 44160 and L is the ffted signal (note, if memory is a problem, use a 2^17 or 2^16 signal).function removefreq(fs, L, method) n=length(L); sampleHi=[80*n/fs;320*n/fs;1280*n/fs;5120*n/fs;20000*n/fs]; sampleLo=[20n/fs+1;80*n/fs+1;320*n/fs+1;1280*n/fs+1;5120*n/fs+1]; If method=1                                       Fracnum=[1;2;3;4];                            %% Fraction numerators for Method 1       Fracden=[2;3;4;5];                             %% Fraction denominators for Method 1 end If method=2       Fracnum=[1;2;3;4];                                  %% Fraction numerators for Method 2       Fracden=[5;5;5;5];                                   %% Fraction denominators for Method 2 end for i=1:4 for n=1:Fracnum(i) for q=1:int((sampleHi(i)-sampleLo(i))/Fracden(i)) L(sampleLo(i)+n+q*Fracden(i))=0; end end end L(n/2:n+1)=fliplr(L(1:n/2)); %% This last step takes the first half of the frequency spectrum and flips it %% placing it on the last half. If the frequency spectrum is symmetric along %% fs/2, then this should work. And a beta finished program... %% note, input = 'filename1.wav' and output = 'filename2.wav' function compression(input, output, signalstart, signalend, method)                           %% make sure n = signalend - signalstart = power of 2 [[l,r],fs,nbits] = wavread(wavfile,[signalstart signalend]; n = signalend - signalstart l = fft(l,n); r = fft(r,n); sampleHi = [80*n/fs;320*n/fs;1280*n/fs;5120*n/fs;20000*n/fs]; sampleLo = [20n/fs+1;80*n/fs+1;320*n/fs+1;1280*n/fs+1;5120*n/fs+1]; If method = 1             Fracnum = [1;2;3;4];             Fracden=[2;3;4;5]; end If method=2             Fracnum=[1;2;3;4];             Fracden=[5;5;5;5]; end for i=1:4   for n=1:Fracnum(i)       for q=1:int((sampleHi(i)-sampleLo(i))/Fracden(i))            l(sampleLo(i)+n+q*Fracden(i))=0;       end   end end l(n/2:n+1)=fliplr(l(1:n/2)); for i=1:4    for n=1:Fracnum(i)       for q=1:int((sampleHi(i)-sampleLo(i))/Fracden(i))           r(sampleLo(i)+n+q*Fracden(i))=0;       end    end end r(n/2:n+1)=fliplr(r(1:n/2)); l=ifft(l,n); r=ifft(r,n); soundsc([l,r],fs,nbits)