Sequence is the sequence of the selected audio from the dropdown menu Sequence=app.DropDown.Value;

computer science

Description

Record Function

 

function RecordButtonPushed(app, event)

           

            app.recObj = audiorecorder; %create audio object

            record(app.recObj, 5); %start Recording, length: 5 sec

           

 end

 

 

Data loading function

% data is the variables of this function’s output

function Dataloading(app,event)

% Sequence is the sequence of the selected audio from the dropdown menu

    Sequence=app.DropDown.Value;

% We supposed that all our recordings are in mp3 format, because this format

% is the most international/common format people use.

% We suppose our file name for each audio is automatically named “recording+#”

    FileName=strcat('recording',num2str(Sequence),'.wav');

% the output is the loaded data

    [MyRec,Fs]=audioread(FileName);

End

 

function sigAnalysisDisplay(data, Freq, length)

% should these be user inputs or should they be hard coded?

[A, Fs] = audioread(data);

dt = 1/Fs;

Tstop = data.time(end);

T=[0:dt:Tstop];

 

%Compute signal - is this just the data that gets passed in? like how does

%that work

ft = zeros(length(A)-1,length(T));

for j = 1:length(A)

    ft(j,:) = A(j)*sin(2*pi*Freq(j)*T);

end

 

%Record computed signal

ft(end+1,:) = sum(ft);

 

%Calculate FFT

Fw=fft(ft(end,:)/Fs); %=fft(ft*dt)

Fw=fftshift(Fw);

Fw=abs(Fw);

 

% range to plot over

freqs=[-Fs/2:1/Tstop:Fs/2];

 

% DFT vs freq

plot(freqs,Fw,'b');

xlim([0 500]);

xlabel('Frequency (Hz)','fontsize',10,'fontweight','bold');

ylabel('F(\omega)','fontsize',10,'fontweight','bold');

title('Frequency Domain','fontsize',12,'fontweight','bold');

set(gca,'fontsize',10,'fontweight','bold');

End

 

%% Audio saving function (draft)

function(app,event)

Sequence = i

i=i+1

FileName = strcat('recording',num2str(Sequence),'.wav');

audiowrite(FileName,data,Fs)

 

 

 

FILTER AND DISPLAY FN

function signalFilterDisplay(data, order, cutoff, filterType, length)

% I just took these out of the if statement so they can be more concise and only be written once

Fs = 1000;

    dt = 1/Fs;

    tStop = length;

     A = 1; %what is A?

 

    t = [0:dt:tStop];

 

if filterType == 0 % set to 0 if it is for low pass

% low pass

   

 

 

    for i = 1:length(A)

        ft(i,:) = A(i)*sin(2*pi*freq(i)*t);

    end

 

    ft(end+1,:) = sum(ft);

 

    ft(end+1,:) = sum(ft);

 

% this is 60 hz, do we want it to be 60 or how do we set that/what to?

    ft(end+1,:) = 10*rand(1,length(t)).*sin(2*pi*60*t);

 

    Wn = app.FilterCutOffEditField.Value / (Fs/2);

    [num,denom] = butter(order,Wn,'low');

    ft(end+1,:) = filter(num,denom,ft(end,:));

 

    figure(2)

    freqz(num,denom,Fs);

% this is plotting the filter response, do we also want original signal,

% noise, etc that is in the example?

 

elseif filterType == 1 % for high pass filter

   

    for i = 1:length(A)

        ft(i,:) = A(i)*sin(2*pi*freq(i)*t);

    end

 

    ft(end+1,:) = sum(ft);

 

    ft(end+1,:) = sum(ft);

 

% this is 60 hz, do we want it to be 60 or how do we set that/what to?

    ft(end+1,:) = 10*rand(1,length(t)).*sin(2*pi*60*t);

 

    Wn = app.FilterCutOffEditField.Value/(Fs/2);

    [num,denom] = butter(order,Wn,'high');

    ft(end+1,:) = filter(num,denom,ft(end,:));

 

    figure(2)

    freqz(num,denom,Fs);

% this is plotting the filter response, do we also want original signal,

% noise, etc that is in the example?


Related Questions in computer science category