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

📄 sphere.doc

📁 speech signal process tools
💻 DOC
📖 第 1 页 / 共 5 页
字号:
header.Syntax:    int sp_h_delete_field(SP_FILE *sp_file, char *field_name)	Arguments:    sp_h_delete_field deletes the header field named by,'field_name', in the opened SPHERE file pointed to by 'sp_file'.Remarks:    If the specified header field to be deleted, 'field_name', doesnot exist in the opened SPHERE file header, sp_h_delete_field() willnot complain, but will return a special value (see below).  ReturnValue:Return Value:    sp_h_delete_field() returns a 0 on success, a 1 if the headerfield does not exist, and a 100 or greater on error.See Also:    sp_open(), sp_h_set_field(), sp_h_get_field()II.B.4  sp_copy_header()Description:    Copies the SPHERE header fields and their values from a sourceheader pointed by an SP_FILE pointer to a destination header pointedto by another SP_FILE pointer.  Overwrites any existing fields commonto both the source and destination headers.Syntax:    int sp_copy_header(SP_FILE *source_sp, SP_FILE *destination_sp)	Arguments:    sp_copy_header copies the fields and their values from the headerpointed to by 'source_sp' to the header pointed to by 'destination_sp'.Return Value:    sp_copy_header() returns a zero on success, and 100 or greateron error.See Also:    sp_open(), sp_close()II.C   Waveform I/O FunctionsII.C.1 sp_read_data()Description:       Reads blocks of waveform data from an opened SPHERE file.Syntax:    /* New syntax for SPHERE version 2.2 or later              */    int sp_read_data(void *ptr, size_t n, SP_FILE *sp_file)    /* Syntax prior to SPHERE version 2.2, still supported for */    /* backwards compatibility                                 */    int sp_read_data(void *ptr, size_t size, size_t n, SP_FILE *sp_file)Arguments:    Reads 'n' elements from the waveform data section of the openedSPHERE file pointed to by 'sp_file'.  An element is defined to be thesample values of all channels for a particular sample number (commontime point).  The function performs the read (including anyconversions as necessary) to format the data according to the firstencoding specified in the header field, 'sample_coding'.  Thisexcludes subsequent encodings used on the stored waveform such ascompression, etc.   The 'ptr' argument can be either a linear array of interleavedchannel samples, or a 2-dimensional array of non-interleaved channelsamples, with each channel contained in a separate array.  Either datastructure can be created by a call to the 'sp_data_alloc' function.The form of the data structure is determined by the mode string passedto the 'sp_set_data_mode' function.  By default, the function expectsthe data to be structured in a linear array.  To change the format toa multi-channel 2-dimensional array, use the sp_set_data_modefunction.Remarks:    In order to support multi-channel data, the manner of specifyingthe waveform parameters has been simplified in SPHERE version 2.2.Instead of extracting the information from the a variable number offunction arguments, the function now extracts the necessaryinformation from the SPHERE header.  Therefore, the function argumentlist has changed from previous versions of SPHERE.  However, theSPHERE 2.1 argument list is still supported for backward compatibility.The 'size' argument although accepted, is now ignored.  Section VI,"Linking to the SPHERE library" describes how to use either the 3 or 4argument function call by using the C-define'd preprocessor variable"SPHERE_PRE_2_2".    If there is no 'sample_coding' field in the header, the defaultoperation is to read the data as PCM data.  The default behavior of'sp_read_data()' can be modified by the function 'sp_set_data_mode()'before 'sp_read_data()' is called.  If a checksum is present inthe header, the checksum is verified after reading the last block of data.Return Value:    The value returned by 'sp_read_data' indicates the number ofelements read in from the file.  If no elements are read, a zero isreturned.  Likewise, if an error or checksum verification erroroccurs, a zero is returned.  The functions 'sp_eof()' and 'sp_error()'may be used to determine if an error or an immediate end-of-filecaused the zero to be returned.See Also:    sp_eof(), sp_error(), sp_set_data_mode(), sp_data_alloc(),    sp_data_free()II.C.2 sp_write_data()Description:       Writes blocks of waveform data to an opened SPHERE file.Syntax:    /* New syntax for SPHERE version 2.2 or later              */    int sp_write_data(void *ptr, size_t n, SP_FILE *sp_file)    /* Syntax prior to SPHERE version 2.2, still supported for */    /* backwards compatibility                                 */    int sp_write_data(void *ptr, size_t size, size_t n, SP_FILE *sp_file)Arguments:    Appends 'n' elements to the end of the waveform data section ofthe opened SPHERE file pointed to by 'sp_file'.  An element is definedto be the sample values of all channels for a particular sample number(common time point).  The function outputs the data in the formspecified by the mode string passed to 'sp_set_data_mode'.  Bydefault, the data is written with interleaved channels (if the data ismulti-channel data) and without further conversions.   The 'ptr' argument can be either a linear array of interleavedchannel samples, or a 2-dimensional array of non-interleaved channelsamples, with each channel contained in a separate array.  The data iswritten from an existing waveform data structure.    [ A waveform data structure is created by a call to the'sp_data_alloc' function.  The form of the data structure isdetermined by the mode string passed to the 'sp_set_data_mode'function.  By default, the function expects the data to be structuredin a linear array.  To change the format to a multi-channel2-dimensional array, use the sp_set_data_mode function. ]Remarks:    In order to support multi-channel data, the manner of specifyingthe waveform parameters has been simplified in SPHERE version 2.2.Instead of writing the data according to a variable number of functionarguments, the function now extracts the necessary information from aSPHERE header constructed prior to the write.  Therefore, the functionargument list has changed from previous versions of SPHERE.  However,the SPHERE 2.1 argument list is still supported for backwardcompatibility.  The 'size' argument although accepted, is now ignored.Section VI, "Linking to the SPHERE library" describes how to useeither the 3 or 4 argument function call by using the C-define'dpreprocessor variable "SPHERE_PRE_2_2".    sp_write_data() uses the 'sample_coding', 'channel_count''sample_byte_format' and 'sample_n_bytes' fields of the header in the'sp_file' structure to identify the format of the data in memory tobe written.  The default behavior is for the data to be written asit is represented in memory (as specified by the above header fields).    The default behavior of 'sp_write_data()' can be modified by thefunction 'sp_set_data_mode()' before 'sp_write_data()' is called.'sp_set_data_mode()' allows the programmer to specify waveform datatransformations as the data is written.Return Value:    The value returned by 'sp_write_data' indicates the number ofelements written to the file pointed to by the 'sp_file' structure.Incomplete writes are not flagged by the function.  It is theprogrammer's responsibility to make sure that the return value equals'n'.See Also:    sp_eof(), sp_error(), sp_set_data_mode(), sp_data_alloc(),    sp_data_free()II.C.3 sp_set_data_mode()Description:       Changes the default behavior of the SPHERE File I/O functions, 'sp_read_data()' and 'sp_write_data()'.Syntax:    int sp_set_data_mode(SP_FILE *sp_file, char *mode)Arguments:    Specifies the waveform transformations for data read from, orwritten to, the file pointed to by 'sp_file'.  The transformations arespecified in the string, 'mode'.  See the "Remarks" section for theformat and permissible values of this string.Remarks:    The 'mode' string argument specifies sample encoding and byteorder transformations to be performed by the SPHERE File I/Ofunctions, 'sp_read_data()' and 'sp_write_data()'.  (Future versionsmay support sample rate transformations as well.)  The 'mode' stringhas the following format:        MODE        :==  <MODE_FLAG> | <MODE_FLAG>:<MODE>        MODE_FLAG   :==  SE-<SE_OPTIONS> | SBF-<SBF_OPTIONS> |			 DF-<DF_OPTIONS> | CH-<CHANNEL_OPTIONS>        SE_OPTIONS  :==  PCM | PCM-1 | PCM-2 | ULAW | RAW | ORIG |                         SHORTEN | WAVPACK	SBF_OPTIONS :==  01 | 10 | 1 | N | ORIGMode Flag and Option Descriptions:    DF -> specifies the data structure of the buffer passed	  into the functions 'sp_read_data()' and 'sp_write_data()'.  The	  default format, "DF-RAW", specifies interleaved channels in a	  1-dimensional array.	DF_OPTIONS:	    "RAW"     -> Data buffers are 1-dimensional arrays of contiguous		 	 memory.  If multiple channels are present, they			 are assumed to be interleaved.	    "ARRAY"   -> Data buffers are 2-dimensional arrays (double 			 pointers) where the data for each channel is in a			 1-dimensional array of contiguous data.  The channel			 number, starting at zero for the first channel, is			 the first index in 2-dimensional array and the			 sample number the second index.  See			 'sp_data_alloc()' for a  description of the memory			 layout.	  The functions 'sp_data_alloc()' and 'sp_data_free()' allocate and 	  deallocate data buffers in either format.    CH -> specifies the channels to be read from a file, or written	  to a file via the <CHANNEL_OPTIONS>.  If the file is being	  read, the function 'sp_read_data()' returns the requested	  channels from the input file.  If the files is being written	  or updated, the library extracts the channels from the input	  buffer before writing the samples to the file.  The default	  operation (without channel selection), is to not perform any	  modifications.	  The <CHANNEL_OPTIONS> can select and re-order channels.  If the	  sample type is pcm or ulaw, the <CHANNEL_OPTIONS> can sum two 	  or more channels together.	  The <CHANNEL_OPTIONS> format is a comma separated list of 	  channel identifiers.  The channel identifiers start at 1 	  for the first channel.  The <CHANNEL_OPTIONS> are of the	  following format:	CHANNEL_OPTIONS :== <CHANNEL_ID> | <CHANNEL_ID>,<CHANNEL_OPTIONS>	CHANNEL_ID      :== <CHANNEL_NUMBER> | <CHANNEL_NUMBER>+<CHANNEL_ID>	CHANNEL_NUMBER  :== the channel number, starting with 1 for	 		    the first channel.	  		   	     SE -> specifies a transformation to the encoding of the sampled	  waveform data.        SE_OPTIONS:            "PCM-2"   -> Read or write data as 2-byte PCM samples.            "PCM-1"   -> Read or write data as 1-byte PCM samples.            "PCM"     -> Synonym for "PCM-2"            "ULAW"    -> Read or write data as 1-byte ULAW samples.  	    "RAW"     -> Read or write data as 1-byte character	                 stream (for unsupported data types).            "ORIG"    -> Read or write data as-is.	    "SHORTEN" -> Write data as Shorten-compressed byte stream.	    "WAVPACK" -> Write data as Wavpack-compressed byte stream.        SBF -> specifies a transformation to the byte format (byte order)	   of the sampled waveform data.  This is only appropriate for           multi-byte sampled data.        SBF_OPTIONS:            "01"      -> Read or write data as LSB/MSB.            "10"      -> Read or write data as MSB/LSB.            "1"       -> Read or write data as 1-byte samples.            "N"       -> Read or write data as natural to the host.            "ORIG"    -> Read or write data as-is.Currently Supported Sample Encoding (SE) Read Transformations: ***    PCM-2   -->  ULAW | RAW | ORIG    ULAW    -->  PCM-2 | RAW | ORIG    RAW     -->  ORIG    SHORTEN -->  PCM-2 | ULAW | RAW | ORIG    WAVPACK -->  PCM-2 | ULAW | RAW | ORIG    Currently Supported Sample Encoding (SE) Write Transformations: ***    PCM-2   -->  ULAW | ORIG | SHORTEN | WAVPACK     ULAW    -->  PCM-2 | ORIG | SHORTEN | WAVPACK     RAW     -->  ORIGReturn Value:    The value returned by 'sp_set_data_mode()' is 0 if thetransformation specified by 'mode' is supported, a 100 ifthe transformation is not supported, and greater than100 on error.See Also:    sp_read_data(), sp_write_data(), sp_open(), sp_close(),    sp_data_alloc(), sp_data_free()II.D   Status FunctionsII.D.1 sp_eof()Description:    Returns the End-of-File (EOF) status of an opened SPHERE file.Syntax:    int sp_eof(SP_FILE *sp_file)	Arguments:    sp_eof takes as it's argument a SPHERE file pointer, 'sp_file',and returns the EOF status of that file.Return Value:    sp_eof returns a non-zero value if the end-of-file has beenreached during the last file read.  Otherwise, it returns a zero.See Also:    sp_read_data(), sp_error()II.D.2 sp_error()Description:    Returns the error status of an opened SPHERE file.Syntax:    int sp_error(SP_FILE *sp_file)	Arguments:    sp_error takes as it's argument a SPHERE file pointer, 'sp_file',and returns the error status of that file.Return Value:    sp_error returns a zero if no errors occurred during the last fileI/O operation, a 100 if a checksum verification error occurred, or greaterthan 100 if a fatal file I/O error occurred.See Also:    sp_read_data(), sp_write_data(), sp_eof()II.D.3 sp_print_return_status()

⌨️ 快捷键说明

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