MATLAB code to completely remove ID3 tag from a mp3 file
This code creates a new file .And copy all the data of original file to the new file except the ID3 tag.Code searches the ID3 tag at the beginning of the file.If it is not present there the code stops execution.The code will work only if the tag is present at the beginning of mp3 the file.The code leaves the ID3 v1 tag as it is.
function removeID3v1_0
%remove id3 tag from a mp3 file
%ex.mp3 file with ID3 tag
%ex2.mp3 file without ID3 tag
%not suitable for very big mp3 files
%open ex.mp3 in big endian read mode
fid=fopen('ex.mp3','r','b');
%read first three bytes
tagStr=fread(fid,3,'char');%file indentifier string
%read next two bytes
tagVer=fread(fid,2,'char');%ID3 tag version
%read next byte
tagFlags=fread(fid,1,'char');%ID3 tag flags
if strcmp(char(tagStr)','ID3')
%create new file ex2.mp3 big endian write mode
fid2=fopen('ex2.mp3','w','b');
%read the length of ID3 tag
len=fread(fid,1,'int32');
len_char=dec2bin(len,32);
org_len_char=[len_char(2:8) len_char(10:16) len_char(18:24) len_char(26:32)];
org_len=bin2dec(org_len_char);
%skip the tag
fseek(fid,org_len,0);
%copy the complete data after the tag in the new file
dat=fread(fid,inf,'char');
fwrite(fid2,dat,'char');
%close file
fclose(fid2);
end
fclose(fid);
|
|
Addition of array with row vector If x is 10x3 array and y is 1x3 vector.To add y with each row of x
[r,c] = size(y);
ind=ones(r,1);
z=x+y(ind,:);
Addition of matrix with column vector If x is 10x3 array and y is 10x1 array vector.To add y with each column of x
[r,c] = size(y);
ind=ones(1,c);
z=x+y(:,ind);
|
|
|