1. Related functions
1. The uigetfile function
- Standardize open select file dialog
Use form:
[filename, pname]=uigetfile('.wav', 'select audio file');
explain:
[returned filename, pathname of returned file]
'Selected file type'% Multiple file types are enclosed by {}
'Select Audio File' % title of the open dialog
2. audioread function
[y,fs] = audioread(filename); %y is the saved audio data
3. Sound function
sound(y);% The default sampling rate is 8192Hz to send an audio signal to the speaker
sound(y, fs);% Send sampled signal at sampling rate fs
sound(y, fs, nbit);% Use the nbit sampling rate for the audio signal y; nbit means that each sample point is represented by several bits, that is, the resolution
2. Record audio
obj = audiorecorder(44100, 16, 1);
%Create an object to save audio information, which includes sampling rate, time, recorded audio information, etc.
%44100 is the sampling rate in Hz
%16 is stored in 16bits
%1 is mono, 2 is two-channel stereo
record(obj);% start recording
pause(5);% recording for 5 seconds
stop(obj);% end recording
myvioce = getaudiodata(obj);
% Get the newly recorded audio signal stored in n*2 digital matrix
axes(handle s.axes1);% draw in axes1
plot(myvioce);% draw sound waveform
audio write('myvioce.wav', myvioce, 44100);% write audio to file
3. Play and stop
% play
overall and
global fs
sound(y ,fs);
%stop
clear sound