function varargout = resultados_separacion(varargin)
% RESULTADOS_SEPARACION M-file for resultados_separacion.fig
%      RESULTADOS_SEPARACION, by itself, creates a new RESULTADOS_SEPARACION or raises the existing
%      singleton*.
%
%      H = RESULTADOS_SEPARACION returns the handle to a new RESULTADOS_SEPARACION or the handle to
%      the existing singleton*.
%
%      RESULTADOS_SEPARACION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RESULTADOS_SEPARACION.M with the given input arguments.
%
%      RESULTADOS_SEPARACION('Property','Value',...) creates a new RESULTADOS_SEPARACION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before resultados_separacion_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to resultados_separacion_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 resultados_separacion

% Last Modified by GUIDE v2.5 28-Nov-2006 16:27:57

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @resultados_separacion_OpeningFcn, ...
                   'gui_OutputFcn',  @resultados_separacion_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before resultados_separacion is made visible.
function resultados_separacion_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 resultados_separacion (see VARARGIN)

% Choose default command line output for resultados_separacion
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes resultados_separacion wait for user response (see UIRESUME)
% uiwait(handles.figure1);

global y fs;
tiempo=(1/fs)*[1:length(y(1,:))];
axes(handles.grafica1);
plot(tiempo,y(1,:)),axis tight;
axes(handles.grafica2);
plot(tiempo,y(2,:)),axis tight;



% --- Outputs from this function are returned to the command line.
function varargout = resultados_separacion_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 reproducir_y1.
function reproducir_y1_Callback(hObject, eventdata, handles)
% hObject    handle to reproducir_y1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global y fs;
wavplay(y(1,:),fs);

% --- Executes on button press in specgram_y1.
function specgram_y1_Callback(hObject, eventdata, handles)
% hObject    handle to specgram_y1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global y;
% Quito los ceros del final para el correcto escalado del espectrograma
for i=length(y(1,:)):-1:1
    if y(1,i)>=1.5e-3
        break;
    end
end
aux=y(1,1:i+1);
specgramdemo(aux);

% --- Executes on button press in reproducir_y2.
function reproducir_y2_Callback(hObject, eventdata, handles)
% hObject    handle to reproducir_y2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global y fs;
wavplay(y(2,:),fs);

% --- Executes on button press in specgram_y2.
function specgram_y2_Callback(hObject, eventdata, handles)
% hObject    handle to specgram_y2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global y;
% Quito los ceros del final para el correcto escalado del espectrograma
for i=length(y(2,:)):-1:1
    if y(2,i)>=1.5e-3
        break;
    end
end
aux=y(2,1:i+1);
specgramdemo(aux);

% --- Executes on button press in salir.
function salir_Callback(hObject, eventdata, handles)
% hObject    handle to salir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close(gcbf);


% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


