⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diskio.m

📁 实现fs1016w的CELP的低速率语音编解码功能的基于vc开发环境的原代码。
💻 M
字号:
% MATLAB SIMULATION OF NSA FS-1016 CELP v3.2
% COPYRIGHT (C) 1995-99 ANDREAS SPANIAS AND TED PAINTER
%
% This Copyright applies only to this particular MATLAB implementation
% of the FS-1016 CELP coder.  The MATLAB software is intended only for educational
% purposes.  No other use is intended or authorized.  This is not a public
% domain program and distribution to individuals or networks is strictly
% prohibited.  Be aware that use of the standard in any form is goverened
% by rules of the US DoD.  Therefore patents and royalties may apply to
% authors, companies, or committees associated with this standard, FS-1016.  For
% questions regarding the MATLAB implementation please contact Andreas
% Spanias at (602) 965-1837.  For questions on rules,
% royalties, or patents associated with the standard, please contact the DoD.
%
% ALL DERIVATIVE WORKS MUST INCLUDE THIS COPYRIGHT NOTICE.
%
% ******************************************************************
% DISKIO
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 6-7-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Disk read/write interface.
%
% DESIGN NOTES
%
% Manages I/O to and from sampled data (speech) files.
% Uses sequential access, unformatted binary files with
% signed 16 bit samples.
%
% VARIABLES
%
% INPUTS
%   mode            -   READ or WRITE
%   fileptr         -   MATLAB file pointer
%   input           -   Buffer of samples to be written to disk
%   length          -   Number of samples to read or write
%
% OUTPUTS
%   status          -   Returns either EOF or number samples read
%   outbuf          -   Buffer of samples read from disk
%
% INTERNALS
%   samples         -   Number of samples returned by fread
%
% CONSTANTS
%   EOF             -   End of file status flag
%   READ            -   Read control flag
%   WRITE           -   Write control flag
%
% ******************************************************************

function [ outbuf, status ] = diskio( mode, fileptr, input, length )

% DECLARE GLOBAL FLAGS AND CONSTANTS
global EOF READ WRITE;

% READ AN INPUT FRAME
if mode == READ
    % READ A FRAME FROM INPUT FILE, FLAG EOF
    [ outbuf, samples ] = fread( fileptr, length, 'short' );
    if samples ~= length
        status = EOF;
    else
        status = samples;
    end

% WRITE AN OUTPUT FRAME
else
    % WRITE A FRAME TO OUTPUT FILE, FLAG ERRORS
    samples = fwrite( fileptr, input, 'short');
    if samples ~= length
        error( '**** disk write error ****\n' );
    end
    outbuf = input;
    [status q]=size(samples);
end

⌨️ 快捷键说明

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