Logo Search packages:      
Sourcecode: yiff version File versions  Download package


      Raw audio file format library

#ifndef RAW_H
#define RAW_H

#include <sys/types.h>

 *    Master version number:
#define RawLibraryVersionMajor            1
#define RawLibraryVersionMinor            1

 *    Raw library function error codes:
#define RawSuccess              0
#define RawErrorNoAccess        1
#define RawErrorNotRaw        2
#define RawErrorNoBuffers     3
#define RawErrorCorrupt       4
#define RawErrorUnsupported   5
#define RawErrorBadValue      6
#define RawErrorNoData        7
#define RawErrorEndOfData     8

 *    Byte value shift options for RawReadPartialData():
#define RawReadUnsigned8      0
#define RawReadSigned8        1

 *    Raw data structure
typedef struct {

      char *filename;
      FILE *fp;

      int sample_size;
      int channels;
      int sample_rate;
      int block_align;    

      off_t data_offset;      /*   Number of bytes to skip
                         *   untill actual data.

      off_t data_length;      /* Length of audio data in bytes. */

      /* Data loaded by RawReadPartialData(). */
      char *data;       /* The actual audio data. */
      off_t data_len;

} raw_data_struct;

 *   Checks if givin file name is a valid RAW file, returns
 *   RawSuccess if it is, RawErrorNotRaw if it is not a valid
 *   RAW file, or appropriate error if an error occured.
extern int RawIsFileRaw(const char *filename);

 *      Reads the header from the stream fp and initializes the given
 *      rd structure if fp is valid and a raw file.
 *      The given filename is used only for referance purposes, it can be
 *      NULL.
 *      If RawSuccess is returned then the given fp will be transfered
 *      to the rd structure and should not be referanced again. For all
 *      other return values, the calling function is responsible for
 *      closing the given fp.
extern int RawReadHeader(
      const char *filename, FILE *fp, raw_data_struct *rd

 *   Reads a segment of data from the RAW file specified by
 *   the filename member of the givin raw_data_struct *rd structure.
 *   The raw_data_struct *rd structure MUST HAVE VALID VALUES FROM
 *   offset is the relative byte position FROM THE START OF THE AUDIO
 *   DATA AS A COMPLETE TRACK and not a position in the file.
 *   This value must be positive.
 *   max_chunk_size is the number of bytes that you want to read from
 *   offset.   This value must be positive and greater than 0.
 *   read_opt is not used currently.
 *   The loaded data will be placed into the member data of the
 *   raw_data_struct *rd with the member data_len set appropriately.
 *   If member data is not NULL, then the old data will be first free()ed
 *   automatically before loading is performed.
extern int RawReadPartialData(
      raw_data_struct *rd,
      long offset,            /* In bytes. */
      long max_chunk_size,    /* In bytes. */
      int read_opt

 *   Frees all allocated data and resets all values of the 
 *   raw_data_struct *rd members.
 *   If raw_data_struct *rd is NULL then no action will be taken. 
extern void RawDestroyData(raw_data_struct *rd);

#endif      /* RAW_H */

Generated by  Doxygen 1.6.0   Back to index