Wav Read dengan Matlab

5 12 2009

Wave Read, Pada matlab fungsi untuk membaca file Wav (Wav Read) sudah disediakan, bentuk umum dari fungsi ini adalah, sbb:

y = wavread('filename')
[y,Fs,bits] = wavread('filename')
[...] = wavread('filename',N)
[...] = wavread('filename',[N1 N2])
[...] = wavread('filename','size')

Ket:
y = wavread(‘filename’) Me-Loads sebuah file wav, ditentukan oleh string filename
[y,Fs,bits] = wavread(‘filename’) Mengembalikan sample rate Fs dalam Hertz dan jumlah bit per sampel bits yang digunakan untuk menyandikan data dalam file.

Pada aplikasi yang akan kita buat, kita akan membaca beberapa file wav, dan menampilkannya pada grafik.

Untuk Lebih jelasnya langsung menuju ke pembuatan programnya:

ScreenShoot :

waveread

Full Source Code:

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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help WaveRead

% Last Modified by GUIDE v2.5 12-Jun-2009 10:11:47

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @WaveRead_OpeningFcn, ...
                   'gui_OutputFcn',  @WaveRead_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(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 WaveRead is made visible.
function WaveRead_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 WaveRead (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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

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

[y, fs, nbits] = wavread('jaran.wav');
sound(y,fs)
tt=length(y);
t=1:tt;
plot(t,y)
grid on

% --- 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)

[y, fs, nbits] = wavread('gerak.wav');
sound(y,fs)
tt=length(y);
t=1:tt;
plot(t,y)
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)

[y, fs, nbits] = wavread('close.wav');
sound(y,fs)
tt=length(y);
t=1:tt;
plot(t,y)
grid on

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

quit;

Bila teman-teman ingin mencobanya, File nya bisa diambil di SINI


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: