forked from lucasselvik/Linear-Dynamical-Model-RLC-Circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertAudio.m
More file actions
21 lines (20 loc) · 675 Bytes
/
Copy pathconvertAudio.m
File metadata and controls
21 lines (20 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
%% function convertAudio(inFile,outFile)
% reads in an audio file specified by inFile
% shortens the audio to 30 sec if the file is large
% writes the audio into a mat file specified by outFile
%
% inFile - string with path to audio file
% outFile - string with path to MAT file
%
% Example usage:
% convertAudio('Eine_kleine_Nachtmusik.mp3','Eine_kleine_Nachtmusik.mat');
%
% Matthew Lew 11/16/2018
% edited 11/26/2020 to allow 30 sec of audio to be converted
function convertAudio(inFile, outFile)
[Vsound,Fs] = audioread(inFile);
len = min(length(Vsound),30*Fs);
Vsound = Vsound(1:len);
Vsound = Vsound/max(Vsound(:));
save(outFile,'Vsound','Fs');
end