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

📄 miio.tme

📁 speech signal process tools
💻 TME
字号:
.lo.SJ "Machine Independent File I/O (MIIO) Module for ESPS".AU "Alan Parker".TM ETM-S-88-3:rap 1.1 4/13/90.sh 1 "Introduction".ppPrevious versions of ESPS used C structures directly for file inputand output of the header and some data records.   This has the advantage of resulting in very simple code.For example, to read the common part of the ESPS header, the followingC statement was all that was needed:.sp.vS.nfif (fread ((char *)ptr, 1, COMMON_SIZE, fd) == 0)	error("Error reading common part of header");.fi.vE.spIn this example, \fIptr\fR is a pointer to the common part of the headerstructure..ppDespite this simplicity, doing file I/O with C structures had thepotential to causeserious problems as we move ESPS to more machine architectures.   Adesign goal of ESPS is that all data files are compatible across allsupported machines.    This means that all ESPS files will havethe same bit level format at the file level..ppThe definition for theC language, does not bind the implementor to allocating members ofstructures to any particular scheme.   The members of a structure mightbe allocated in any order convenient to the compiler.   Since a pointer tothe structure is used for the I/O (by \fIfread\fR or \fIfwrite\fR) thedata on the actual file will be an exact image of the in memoryrepresentation of the structure.    A data file containing thesestructures cannot be used on another machine unless its compilerimplements the structure exactly the same way.   Even if we did not careabout portability between different machine architectures, there isstill the risk that within a given machine type, the format ofstructures could change between compiler versions, resulting in unusableESPS data files (and very unhappy users)..ppEven if all C implementations allocated structures the same way, wewould still have problems since the basic C data types are not the samesize on all machines and numeric formats may vary (all machines do notuse the same floating point formats, for example)..ppAnother difference between computer architectures that we must be concerned about is byte order.   In some cases the byte with the lower machineaddress contain the least significant part of multibyte data, and inother cases it contains the most significant part.  When binary datafiles are moved between machines that differ in this respect, the datamust be \fIbyte swapped\fR.   For example this is the case between VAX and Sun machines..ppThe document describes the solution to these problems that we haveimplemented..sh 1 "MIIO Module".ppFor each supported machine type, there isa machine dependent module that implements a set of input and outputfunctions that know how to read and write the standard ESPS data typesfrom a file and convert them to the machine's internal representation.This module is called the \fimachine independent input/output module\fRor MIIO.  There is an implementation of the MIIO module for eachsupported machine architecture.  The correct one will be linked in whenESPS compiled; depending on information in the installation script..ppAn ESPS program can write ESPS data files in one of twoformats; either the machine's native format, or in ESPS external datarepresentation (EDR).   Files in EDR formant can always be read by anyESPS implementation on any supported machine type.   Files written in amachine's native format can always be read by that same machine type andperhaps other supported ESPS machines, but it is not guaranteed that anative format file can be read on other machine types..pp [\fInote:\fR EDR suggest the Sun XDR, external data representationscheme.   This is similar in idea and we considered simply using the XDRroutines.   The reason that we didn't, was that we could not count onthe XDR library being implemented on all machine types that we neededand we wanted to put some ESPS specific features into the routines.].sh 1 "User Control of File Format".ppThe default action is to write files in the machine's native format.On somemachines, this may result in faster execution time or higher floatingpoint precision (since conversions would not be done).  .ppOtherwise, the user might desire to write his data files in EDR format.This is a run\-time decision that can be made by setting the Unixenvironment variable \fBESPS_EDR\fR to \fBon\fR.  The actual effect of this environment variable is in the libraryroutines \fInew_header\fR and \fIcopy_header\fR.   When a new header iscreated (either a empty one, or a copy of an existing one) the headeritem \fIcommon.edr\fR is initialized (YES means the file is inEDR format, NO means it is in native format)..ppIf the Unix environment variable \fBESPS_EDR\fR is defined and has avalue of \fIon\fR, then the header item \fIcommon.edr\fR is set toYES, which means that this data file will be written to the disk inEntropic's external data representation (EDR).  Otherwise the file iswritten in the host machine's native data format..ppIf the program needs to force the output data representation format,then it can reset the value of \fIcommon.edr\fR after the return from\fInew_header\fR, or \fIcopy_header\fR, but before a \fIwrite_header\fRis done.   Resetting \fIcommon.edr\fR after \fIwrite_header\fR, butbefore closing the file will result in a garbage file..ppSome programs might also have command line options to affectthe mode of output files, as appropriate (conversion programs for example) or be hard\-codedfor native or ESPS standard I/O.In any case the MIIO module will be used, but in the case of a nativeformat file, it will not do anything but straight I/O.For eachsupported machine there is a statement describing the expected effecton run\-time and precision of the conversions.   .ppThe ESPS standards have been chosen so that many common machinesrequire no conversions at all.  (Those with only machines that differfrom the standards might not agree, however.  But there are probablymore 680X0 and Sparc based machines being used for this type of work, than anyother single type.)  In fact, in the case of the following machines, themachine's native format is identical to EDR format: Sun3, Sun4 (allSparcs), Solbourne, Masscomp/Concurrent, Convex in IEEE mode, SiliconGraphics, HP 300, HP 900, and Apple MAC II.    Sun 386i and DEC DS3100native format files are different than EDR, because of byte orderdifferences..ppThis means that if your machines are in that first group, you do notneed to be concerned with the difference between native format files andEDR format.  If you machines are in the second group, or you have somein each group you do need to be concerned.    The current implementationof MIIO on all supported machine types as of this version of ESPS (4.0)will read files in native format from any of these machines.   In otherwords, whether you write files in native or EDR format on a Sun 386iwill not affect the ability to read them on a Sun4.   The issue is whereand when you pay the price of conversion.   If you write the file on theSun 386i in native format and read it on a Sun4, then the conversionprice is paid when reading.   If you expect to read this file often on adifferent machine type, then perhaps you would be better off paying theconversion price when writing the file..sh 1 "ESPS Data Types".ppThis section describes the ESPS data types as they are represented inESPS data files.  Keep in mind, that the description here applies to therepresentation on the file.  Once read into memory by the ESPS program,the data is in the machine's internal representation; as it must be forthe machine to operate on the data..ppESPS programs use all of the data types supported by C.  The exactrepresentation of these data types will vary between machinearchitectures and C implementations.  Since it is a goal of ESPS for alldata files to be binary compatible across supported machines we must define what these datatypes mean for ESPS data files.   In ESPS data types, a byte is 8 bits..ppThis table shows the basic ESPS data types and gives their formats inESPS data files.Additional built\-in ESPS types may be added to this list..sp.TSbox, center, tab(;);c s sc c cl n l.ESPS Data Types=Type;Size (bytes);C type_double;8;doublefloat;4;floatlong;4;longshort;2;shortchar;1;charbyte;1;char.TE.ppTypes in this table that are not standard C types are defined as\fItypedefs\fR in an ESPS header file..sh 2 "Numeric Formats".ppOn ESPS data files, floating point values are stored using the IEEEfloating point format, for 32 bit single precision values(floats) and 64 bit double precision (double).   Integertypes are stored as twos\-compliment integers with short being 16bits, long being 32 bits, and byte being 8 bits.  Characterdata (char) is stored in ASCII, with one character in each 8 bitbyte..sh 2 "Byte Order".ppThe interpretation of byte\-order differs among computer architectures.This is a difference, like numeric formats, that will be resolved by themachine dependent module.  The ESPS standard byte\-order is that of the 680X0 processor..sh 1 "Summary".ppThis implementation of machine independent I/O for ESPS allows datafiles to be written either in the machine's native format for maximumefficiency, or in a standard format for maximum portability.   In thecurrent implementation all ESPS data files can be read by any othersupported implementation, but this is not guaranteed to be true of allfuture versions.   It is guaranteed, however, that any ESPS file writtentoday in EDR format will be readable by any future ESPS version.   It isalso guaranteed that some method of conversion will be available fornative format files from some current available host to a futuresupported machine..ppThe ESPS application programmer does not need to be concerned with MIIOfunctions at all.  They are all contained inside of the header and dataI/O routines..ppIt is important that ESPS programs only use the ESPS header and recordI/O routines;  a program that uses \fIfread\fR for example, will notcorrect read all ESPS data files from all other machine types..ppSee the manual pages for \fInew_header\fR and \fIcopy_header\fR.

⌨️ 快捷键说明

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