Home > utils > mp3_toolbox > mp3write.m

mp3write

PURPOSE ^

MP3WRITE Write MP3 (".mp3") sound file.

SYNOPSIS ^

function mp3write(Y,FS,NBITS,ENCODING,MP3FILE)

DESCRIPTION ^

MP3WRITE Write MP3 (".mp3") sound file.
    MP3WRITE(Y,FS,NBITS,ENCODING,MP3FILE) writes data Y to a MP3
    file specified by the file name MP3FILE, with a sample rate
    of FS Hz and with NBITS number of bits. Stereo data should 
    be specified as a matrix with two columns. 
    ENCODING must be specified as an integer number from 1 to 5
 
   1 = Fixed bit rate 128kbs encoding.
   2 = Fixed bit rate jstereo 128kbs encoding, high quality (recommended).
   3 = Average bit rate 112kbs encoding.
   4 = Fast encode, low quality.
   5 = Variable bitrate.

    See also MP3READ, WAVREAD, WAVWRITE.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mp3write(Y,FS,NBITS,ENCODING,MP3FILE)
0002 %MP3WRITE Write MP3 (".mp3") sound file.
0003 %    MP3WRITE(Y,FS,NBITS,ENCODING,MP3FILE) writes data Y to a MP3
0004 %    file specified by the file name MP3FILE, with a sample rate
0005 %    of FS Hz and with NBITS number of bits. Stereo data should
0006 %    be specified as a matrix with two columns.
0007 %    ENCODING must be specified as an integer number from 1 to 5
0008 %
0009 %   1 = Fixed bit rate 128kbs encoding.
0010 %   2 = Fixed bit rate jstereo 128kbs encoding, high quality (recommended).
0011 %   3 = Average bit rate 112kbs encoding.
0012 %   4 = Fast encode, low quality.
0013 %   5 = Variable bitrate.
0014 %
0015 %    See also MP3READ, WAVREAD, WAVWRITE.
0016 
0017 s = which('mp3write.m');
0018 ww = findstr('mp3write.m',s);
0019 lame = s(1:ww-2);
0020 wavwrite(Y,FS,NBITS,strcat(lame,'\temp.wav'));
0021 tmpfile = strcat(lame,'\temp.wav');
0022 MP3FILE = strcat(pwd,'\',MP3FILE);
0023 ENCODING =  num2str(ENCODING);
0024 switch ENCODING
0025     case {'1'}
0026         cmd = [lame,'\lame', ' --quiet', ' ', tmpfile, ' ',MP3FILE];
0027     case {'2'}
0028         cmd = [lame,'\lame', ' --quiet', ' -b 128 ', tmpfile, ' ',MP3FILE];
0029     case {'3'}
0030         cmd = [lame,'\lame', ' --quiet', ' --abr 112 ', tmpfile, ' ',MP3FILE];
0031     case {'4'}
0032         cmd = [lame,'\lame', ' --quiet', ' -f ', tmpfile, ' ',MP3FILE];
0033     case {'5'}
0034         cmd = [lame,'\lame', ' --quiet', ' -h ', ' -V ', tmpfile, ' ',MP3FILE];
0035     otherwise
0036         error('Encoding parameters not suported') 
0037 end
0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0039 %%%%%%%%%%%%%% Data Encoding  using "Lame.exe"%%%%%%%%%%%%%%%%%%%%
0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0041 dos(cmd);
0042 % Delete temporary file
0043 delete(tmpfile);

Generated on Wed 22-May-2019 04:00:51 by m2html © 2003