File Exchange

image thumbnail


version 1.0 (12.7 KB) by

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

43 Ratings



No License

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:

Comments and Ratings (48)

jing zhang


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

This can be done without that toolbox:

Ghadeer Kwaik

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


Paul (view profile)

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


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.


Milan Cajic


Sunny (view profile)

Excellent code...... VERY VERY Useful

syed shah hassan hassan shah

code for voice record in matlab

geoffrey andrews

great job.bravo!

shaukat nawaz

alaa elhabbash

Toon Claes

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

Fred Blon

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

zhang hongxia

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

waqas mehboob

Jim yang

Nice work!

Sona Patel

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

Nurul Bostanudin

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

Ahmad Mujaddid Amin

simple, usefull and user friendly. thanx before

Juan Ramon Beristain

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

Rajat Ranjan

xinyu ke


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!

Jim Wilcox

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

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?


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??

Srikanth J

its very nice...



haky smoke

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...

liu yong xiang

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

sourav ray

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?

Yan Luo

very nice program, help me much! thanks

Michael S

divya thejus

Futterlon Futterlon

George George

Ahmeed Ahmeed

Jason Jason

nelle nelle


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

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.

ahmad hamedi

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

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.

Wolfe Harnett

very useful, Thank-you

yadong Wang


MATLAB Release
MATLAB 5.3 (R11)

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

» Watch video

Win prizes and improve your MATLAB skills

Play today