swapbyte.m

来自「语音处理平台 可以分析语音能量 第一振峰频率等数据」· M 代码 · 共 67 行

M
67
字号
function [out] = swapbyte(infile,hdrs) 


% Copyright (c) 1996 by Philipos C. Loizou
%
%

fp=fopen(infile,'r');
if fp<0, error('Unable to open the file in swapbyte.m ');
end

fseek(fp,hdrs,'bof'); % ..... skip hdrs bytes in header 
xin=fread(fp,inf,'ushort');


hi=floor(xin/256); % get the high byte
lo=xin-256*hi;     % get the low byte
out=256*lo+hi;     % swap


% .. convert the unsigned representation to signed representation ...
%
mx=32768*2;
med=32768;
neg=find(out>med); lneg=length(neg);
if lneg>0
 out(neg)=out(neg)-mx*ones(lneg,1);
end

fclose(fp);




































⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?