No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.9 | 42 ratings Rate this file 27 Downloads (last 30 days) File Size: 12.7 KB File ID: #2796 Version: 1.0
image thumbnail



Jesse Hansen (view profile)


29 Nov 2002 (Updated )

MATLAB Record GUI: Used to record, edit, and analyze speech or other sounds.

| Watch this File

File Information

The program is intended to simplify the recording and basic editing of speech waveforms as well as to present the spectrogram and the time waveform in a side-by-side format for ease of analysis.

Getting Started:

Before you can do any recording through Record, you will need to connect a microphone or other sound source to the microphone input on your sound card. The next step is to ensure that your computer is set up to record from the microphone. On a Windows machine, you must select the microphone as the source in the Record Control window. The Record Control window can usually be accessed from a speaker icon in the system tray.

Running the program:

The program can be run by typing record at the MATLAB prompt or by opening the program in the MATLAB editor and selecting Run from the Debug menu


Sound recording is initiated through the MATLAB graphical user interface (GUI) by clicking on the record button. The duration of the recording can be adjusted to be anywhere from 1 to 6 seconds. (These are the GUI defaults, but the code can be modified to record for longer durations if desired.)

Upon being clicked, the record button executes a function that reads in mono data from the microphone jack on the sound card and stores it a MATLAB vector.

Most of the important information in a typical voice waveform is found below a frequency of about 4 kHz. Accordingly, we should sample at a least twice this frequency, or 8 kHz. (Note that all sound cards have a built in pre-filter to limit the effects of aliasing.) Since there is at least some valuable information above 4 kHz, the Record GUI has a default sampling rate of 16 kHz (however, the waveforms portrayed in this document were sampled at 11.025 kHz).

Once recorded, the time data is normalized to maximum amplitude of 0.99 and displayed on the upper plot in the GUI window. In addition to the time domain waveform, a spectrogram is computed using MATLAB's built in specgram function (part of the signal processing toolbox).

Zooming in on the Waveform:

One can examine a region of interest in the waveform using the Zoom in button. When Zoom in is clicked, the cursor will change to a cross hair. Clicking the left mouse button and dragging a rectangle around the region of interest in the time domain waveform will select a sub-section of data.

Zooming out:

The Zoom out button will change the axis back to what it was before Zoom in was used. If you zoom in multiple times, zooming out will return you to the previous axis limits.

Listening to the Waveform:

The Play button uses MATLAB's sound function to play back (send to the speakers) the waveform that appears in the GUI. If you have zoomed in on a particular section of the waveform, only that portion of the waveform will be sent to the speakers.

Saving and Loading Data:

Save is used to write the waveform to a wave file. If zoomed in on segment of data, only that portion of the waveform will be saved.

Click Load to import any mono wave file into the Record GUI for analysis.

For a full description, see:

Required Products Signal Processing Toolbox
MATLAB release MATLAB 5.3 (R11)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (47)
10 Nov 2016 noodles

Requires data acquisition toolbox:
Error in record>init_sound (line 396)
ai = analoginput('winsound');

This can be done without that toolbox:

27 Apr 2016 Ghadeer Kwaik

Hi, I'm a new member in this site.How can I take the code ?

Comment only
04 Feb 2011 Paul

Paul (view profile)

Does anyone know how to export the amplitude data as numbers (not as a .wav file)? Thanks in advance

23 Nov 2010 Turner

Turner (view profile)

I'm using this file and some times it works correctly, and other times it doesn't. If I set the record time to 3 seconds, matlab warning, "SamplesPerTrigger must be specified as scalar integer value". The playback file is also wrong because if I pause 2 seconds before clapping my hands, the amplitude shows I clapped at 0.1 seconds. Other times the file works great.

I've used the core components of this code for my own code that times from a beep to the user's hands clapping together. My code has the same error(s) as this because it says the hand claps start almost instantly.

If I load a .wav file that was recorded and saved by record.m the pause before first clap is correct.

I'm using R2009b. I have the same problem on 2 computers one is a desktop with 32 bit vista, the other is a 64 bit windows 7 laptop.

Please advise.

06 Jun 2010 Serghei

29 Oct 2009 Milan Cajic

08 Aug 2009 Sunny

Sunny (view profile)

Excellent code...... VERY VERY Useful

27 Jun 2008 syed shah hassan hassan shah

code for voice record in matlab

26 Jun 2008 geoffrey andrews

great job.bravo!

23 Apr 2008 shaukat nawaz

16 Feb 2008 alaa elhabbash

11 Feb 2008 Toon Claes

Real great, thx a lot, this is really what I needed.

22 Jan 2008 Fred Blon

But how do we do to recod a random length sound ?

24 Dec 2007 zhang hongxia

Wonderful!Thank you,but if you may give an example, it's convenient and comprehensible!

Comment only
03 Oct 2007 waqas mehboob

09 Sep 2007 Jim yang

Nice work!

Comment only
17 Jun 2007 Sona Patel

Wonderful! Simple yes, but it saved me the time of doing it!

11 Apr 2007 Nurul Bostanudin

simple program with good description. easy to understand.tq.

05 Mar 2007 Ahmad Mujaddid Amin

simple, usefull and user friendly. thanx before

21 Feb 2007 Juan Ramon Beristain

I have not try it, however I read the whole think and looks good.

04 Jan 2007 Rajat Ranjan

23 Oct 2006 xinyu ke


Comment only
30 Jul 2006 Julia P.

Thank's alot, it works fine.
But may be someone knows how to make recording not with time slider and "record" button, but with 2 buttons: "record" and "stop recording"?
Thank you in advance!

01 Jun 2006 Jim Wilcox

How would you do this program if you didn't have the data acquisition toolbox?

26 Feb 2006 Alon Konchitsky

It is very nice. Thank you. Just one short question, which I belive relates to Matlab or PC and less to this file. How do we record stereo from microphones? What is the wav file format? Is it interlaced (left right left right etc) or other fileformat?


16 Feb 2006 tan jane

is v good. But can anyone know how to stop a (.wav) file while it is playing?? I have tried using the stop(player), it doesn't work. It will just hang up the whole system. So do anyone have the solution to this problem??

08 Jan 2006 Srikanth J

its very nice...



29 May 2005 haky smoke

06 Mar 2005 Boris Savary

Excellent : very usefull, user-friendly, works well.
But it will be a good thing that to have a kind of scale for the spectrogramm especially for novices...

01 Feb 2005 liu yong xiang

run this program on 6.5,I find only show a GUI without everything on the GUI panal.

17 Jan 2005 sourav ray

28 Nov 2004 chow yt

I cannot run it on v6.51 and an error

"??? Undefined function or variable 'analoginput'.

Error in ==> C:\MATLAB6p5p1\work\record.m (init_sound)
On line 396 ==> ai = analoginput('winsound');

Error in ==> C:\MATLAB6p5p1\work\record.m
On line 130 ==> ai = init_sound(R_fs,R_samp_len);

??? Error while evaluating uicontrol Callback."

will show in the command window. Jesse any changes or suggestion to this problem?

22 Nov 2004 Yan Luo

very nice program, help me much! thanks

11 Nov 2004 Michael S

08 Nov 2004 divya thejus

02 Nov 2004 Futterlon Futterlon

02 Nov 2004 George George

02 Nov 2004 Ahmeed Ahmeed

02 Nov 2004 Jason Jason

02 Nov 2004 nelle nelle

10 Oct 2004 Tiw SIIT

This GUI is very useful for my project, speaker verification. I will apply to my presentation. Committes must love it.

07 Sep 2004 Astari Paramita

I have a question .. I'm trying to convert the sound file that I have (*.wav) so I can get its vector form. I need it to do the feature extraction and classification. Can you help me ? Or anyone can help me ? Waiting for your reply. Thank you.

07 Aug 2004 ahmad hamedi

i had any problem about save sound
by'wavwrite' and play it
by'windows media player'.
please help me.

Comment only
11 Dec 2003 Matt D

Could not use the file because there are functions called from other toolboxes that were not listed and that I don't own.

The description says "Required Products: Signal Processing Toolbox" however the analoginput.m function from the Data Acquisition Toolbox is used as well as the getrect.m function from the Image Processing Toolbox.

10 Nov 2003 Wolfe Harnett

very useful, Thank-you

14 Jan 2003 yadong Wang


Contact us