
function [noFilterAmps, resonances] = measureAmplitudes2(frequencies)
    %MEASSUREAMPLITUDES Meassures the amplitude of sound played at different
    %frequencies.
    %   
    %PARAMETERS
    %   amplitude - The amplitude to play the sound at
    sampleRate = 44100 * 2; %Audio sample rate
    bits = 16; %Bits used to record the audio?
    amplitude = 1;

    %Recording the audio
    recObject = audiorecorder(sampleRate, bits, 1);
    playTime = 0.6; %Amount of seconds to play sound
    
    %Arrays to store amplitude
    amplitudes = [];
    noFilterAmps = [];
    resonances = [];
    
    %Going through all the frequencies to meassure
    for soundFreq = frequencies
        [fftMagnitude, soundPart, filteredPart, audioData, ampFiltered, amplitudeResult, amplitudeResult2 outSound] = testFrequency(recObject, amplitude, soundFreq, playTime, sampleRate);

        %Saving the amplitudes to the array
        amplitudes(end + 1) = amplitudeResult;
        noFilterAmps(end + 1) = amplitudeResult2;

%         figure(4);
%         subplot(2,1,1);
%         plot(soundPart);
%         title('Analyzed part');
%         ylabel('Amplitude');
% 
%         subplot(2,1,2);
%         plot(filteredPart);
%         title('Analyzed amplitude');
%         ylabel('Amplitude');

        %Plotting the recorded sounds
        figure(2);
        
        offset=25550;
        speaker=zeros(1,length(audioData));
        speaker(offset:(offset+length(outSound)-1))=outSound;
        
        ax0 = subplot(3,1,1);plot(1:length(audioData), speaker);
        title(['Signal till högtalaren vid ', num2str(soundFreq), 'Hz']);
%        ylabel('Amplitude');

        ax1 = subplot(3,1,2);plot(1:length(audioData), audioData);
        title(['Signal från mikrofonen vid ', num2str(soundFreq), 'Hz']);
%        ylabel('Amplitude');

        ax2 = subplot(3,1,3);plot(ampFiltered);
        title(['Skattad amplitud vid ', num2str(soundFreq), 'Hz']);
%        ylabel('Amplitude');
    end
    
    %Plotting the result of the discrete fourier transform amplitude
    %meassrements
%     figure(4);
%     clf;
% %     ax1 = subplot(2,1,1); 
% %     plot(frequencies,amplitudes);
% %     title('Using DFT');
% %     xlabel('Frequency');
% %     ylabel('Relative amplitude');
% 
%     ax2 = gca; 
%     plot(frequencies,noFilterAmps);
%     %linkaxes([ax1, ax2], 'x');
%     title('Amplitudkarakteristik');
%     xlabel('Frekvens');
%     ylabel('Förstärkning');
end
