My AIM is to implement COMPRESSION OF AUDIO SIGNALS USING WAVELETS TRANSFORMS! But when try this code and run in MatLab, it shows some GUI ERROR which I have no idea about! I am using R2016b. I have mentioned the line in which error occured in code as comments with line number. I have also given the source code for gui_mainfcn.
CODE I AM USING:
function varargout = AudioCompression2(varargin)% AUDIOCOMPRESSION2 MATLAB code for AudioCompression2.fig
% AUDIOCOMPRESSION2, by itself, creates a new AUDIOCOMPRESSION2 or raises the existing
% singleton*.
%
% H = AUDIOCOMPRESSION2 returns the handle to a new AUDIOCOMPRESSION2 or the handle to
% the existing singleton*.
%% AUDIOCOMPRESSION2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in AUDIOCOMPRESSION2.M with the given input arguments.
%% AUDIOCOMPRESSION2('Property','Value',...) creates a new AUDIOCOMPRESSION2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before AudioCompression2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to AudioCompression2_OpeningFcn via varargin.
%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help AudioCompression2
% Last Modified by GUIDE v2.5 21-Nov-2014 18:23:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @AudioCompression2_OpeningFcn, ... 'gui_OutputFcn', @AudioCompression2_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:}); % ERROE LINE (LINE 42)
end% End initialization code - DO NOT EDIT
% --- Executes just before AudioCompression2 is made visible.
function AudioCompression2_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to AudioCompression2 (see VARARGIN)
% Choose default command line output for AudioCompression2
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes AudioCompression2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = AudioCompression2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global file_name;%guidata(hObject,handles)
file_name=uigetfile({'*.wav'},'Select an Audio File');fileinfo = dir(file_name);SIZE = fileinfo.bytes; % ERROE LINE (LINE 85)
Size = SIZE/1024;[x,Fs,bits] = audioread(file_name);xlen=length(x);t=0:1/Fs:(length(x)-1)/Fs;set(handles.text12,'string',Size);%plot(t,x);
axes(handles.axes1) % Select the proper axes
plot(t,x)set(handles.axes1,'XMinorTick','on')grid on% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global file_name;if(~ischar(file_name)) errordlg('Please select Audio first');else[Data,Fs,bits] = audiioread(file_name);[Data, Fs, bits] = audioread('Windows XP Startup.wav');%chosing a block size
windowSize = 8192;%changing compression percentages
samplesHalf = windowSize / 2;samplesQuarter = windowSize / 4;samplesEighth = windowSize / 8;%initializing compressed matrice
DataCompressed2 = [];DataCompressed4 = [];DataCompressed8 = [];%actual compression
for i=1:windowSize:length(Data)-windowSize windowDCT = dct(Data(i:i+windowSize-1)); DataCompressed2(i:i+windowSize-1) = idct(windowDCT(1:samplesHalf), windowSize); DataCompressed4(i:i+windowSize-1) = idct(windowDCT(1:samplesQuarter), windowSize); DataCompressed8(i:i+windowSize-1) = idct(windowDCT(1:samplesEighth), windowSize);endaudiowrite(DataCompressed2,Fs,bits,'output3.wav')[x,Fs,bits] = audioread('output3.wav');fileinfo = dir('output3.wav');SIZE = fileinfo.bytes;Size = SIZE/1024;xlen=length(x);t=0:1/Fs:(length(x)-1)/Fs;set(handles.text14,'string',Size);%plot(t,x);axes(handles.axes2) % Select the proper axesplot(t,x)set(handles.axes2,'XMinorTick','on')grid onaudiowrite(DataCompressed4,Fs,bits,'output4.wav')[x,Fs,bits] = audioread('output4.wav');fileinfo = dir('output4.wav');SIZE = fileinfo.bytes;Size = SIZE/1024;xlen=length(x);t=0:1/Fs:(length(x)-1)/Fs;set(handles.text16,'string',Size);%plot(t,x);axes(handles.axes3) % Select the proper axesplot(t,x)set(handles.axes3,'XMinorTick','on')grid onaudiowrite(DataCompressed8,Fs,bits,'output5.wav')[x,Fs,bits] = audioread('output5.wav');fileinfo = dir('output5.wav');SIZE = fileinfo.bytes;Size = SIZE/1024;xlen=length(x);t=0:1/Fs:(length(x)-1)/Fs;set(handles.text18,'string',Size);%plot(t,x);axes(handles.axes4) % Select the proper axesplot(t,x)set(handles.axes4,'XMinorTick','on')grid on[y1,fs1, nbits1,opts1]=audioread(file_name);[y2,fs2, nbits2,opts2]=audioread('output3.wav');[c1x,c1y]=size(y1);[c2x,c2y]=size(y1);if c1x ~= c2x disp('dimeonsions do not agree'); else R=c1x; C=c1y; err = (sum(y1(2)-y2).^2)/(R*C); MSE=sqrt(err); MAXVAL=255; PSNR = 20*log10(MAXVAL/MSE); MSE= num2str(MSE);if(MSE > 0) PSNR= num2str(PSNR); elsePSNR = 99;endfileinfo = dir(file_name);SIZE = fileinfo.bytes;Size = SIZE/1024;fileinfo1 = dir('output3.wav');SIZE1 = fileinfo1.bytes;Size1 = SIZE1/1024;CompressionRatio = Size/Size1; set(handles.text21,'string',PSNR) set(handles.text23,'string',MSE) set(handles.text24,'string',CompressionRatio)endend
SOURCE CODE FOR gui_mainfcn:
function varargout = gui_mainfcn(gui_State, varargin)
% GUI_MAINFCN Support function for creation and callback dispatch of GUIDE GUIs.
% GUI_MAINFCN is called from inside MATLAB code files generated by GUIDE to handle
% GUI creation, layout, and callback dispatch.
%
% See also: GUIDE.
% GUI_MAINFCN provides these command line APIs for dealing with GUIs
%
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs
% are
% applied to the GUI before untitled_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
% Copyright 1984-2015 The MathWorks, Inc.
gui_StateFields = {'gui_Name'
'gui_Singleton'
'gui_OpeningFcn'
'gui_OutputFcn'
'gui_LayoutFcn'
'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
if ~isfield(gui_State, gui_StateFields{i})
error(message('MATLAB:guide:StateFieldNotFound', gui_StateFields{ i }, gui_Mfile));
elseif isequal(gui_StateFields{i}, 'gui_Name')
gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
end
end
numargin = length(varargin);
if numargin == 0
% UNTITLED
% create the GUI only if we are not in the process of loading it
% already
gui_Create = true;
elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
% UNTITLED(ACTIVEX,...)
vin{1} = gui_State.gui_Name;
vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
vin{3} = varargin{1};
vin{4} = varargin{end-1};
vin{5} = guidata(varargin{1}.Peer);
feval(vin{:});
return;
elseif local_isInvokeHGCallback(gui_State, varargin{:})
% UNTITLED('CALLBACK',hObject,eventData,handles,...)
gui_Create = false;
else
% UNTITLED(...)
% create the GUI and hand varargin to the openingfcn
gui_Create = true;
end
if ~gui_Create
% In design time, we need to mark all components possibly created in
% the coming callback evaluation as non-serializable. This way, they
% will not be brought into GUIDE and not be saved in the figure file
% when running/saving the GUI from GUIDE.
designEval = false;
if (numargin>1 && ishghandle(varargin{2}))
fig = varargin{2};
while ~isempty(fig) && ~ishghandle(fig,'figure')
fig = get(fig,'parent');
end
designEval = isappdata(0,'CreatingGUIDEFigure') || (isscalar(fig)&&isprop(fig,'GUIDEFigure'));
end
if designEval
beforeChildren = findall(fig);
end
% evaluate the callback now
varargin{1} = gui_State.gui_Callback;
if nargout
[varargout{1:nargout}] = feval(varargin{:});
else
feval(varargin{:});
end
% Set serializable of objects created in the above callback to off in
% design time. Need to check whether figure handle is still valid in
% case the figure is deleted during the callback dispatching.
if designEval && ishghandle(fig)
set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
end
else
if gui_State.gui_Singleton
gui_SingletonOpt = 'reuse';
else
gui_SingletonOpt = 'new';
end
% Check user passing 'visible' P/V pair first so that its value can be
% used by oepnfig to prevent flickering
gui_Visible = 'auto';
gui_VisibleInput = '';
for index=1:2:length(varargin)
if length(varargin) == index || ~ischar(varargin{index})
break;
end
% Recognize 'visible' P/V pair
len1 = min(length('visible'),length(varargin{index}));
len2 = min(length('off'),length(varargin{index+1}));
if ischar(varar
Best Answer