home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / sound / convertsound.h < prev    next >
Text File  |  1992-02-01  |  3KB  |  78 lines

  1.  
  2. /*
  3.  *    convertsound.h
  4.  *    Copyright 1988-89 NeXT, Inc.
  5.  *
  6.  */
  7.  
  8. #import "soundstruct.h"
  9. #import "sounderror.h"
  10.  
  11. unsigned char SNDMulaw(short n);
  12. short SNDiMulaw(unsigned char m);
  13. /*
  14.  * Routines to convert from 8 bit mulaw sound to/from 16 linear sound.
  15.  * SNDMulaw returns the mulaw value for the given 16 bit linear value,
  16.  * and SNDiMulaw returns the 16 bit linear value for the given mulaw value.
  17.  */
  18.  
  19. int SNDConvertSound(SNDSoundStruct *s1, SNDSoundStruct **s2);
  20. /*
  21.  * Routine to convert the sound specified by s1 into a new sound designated
  22.  * by the header s2, which identifies the resultant data format, channel count,
  23.  * and sampling rate. If the dataSize in s2 is non-zero, then the s2's data 
  24.  * contains optional arguments for the conversion (these argumeBS`are
  25.  * conversion-specific). A new SNDSoundStruct is created which contains the
  26.  * converted sound, and s2 is set to point at it. An error code is returned.
  27.  */
  28.  
  29. int SNDRunDSP(SNDSoundStruct *core,
  30.           char *write_ptr,
  31.           int write_count,
  32.           int write_width,
  33.           int write_buf_size,
  34.           char **read_ptr,
  35.           int *read_count,
  36.           int read_width,
  37.           int negotiation_timeout,
  38.           int flush_timeout,
  39.           int conversion_timeout);
  40. /*
  41.  * This generic routine runs the DSP program represented by core, streaming
  42.  * the specified input data to it, and collecting the output data into a
  43.  * buffer that is returned in read_ptr, with a size returned in read_size.
  44.  * The dsp program should implement the 'Complex DMA mode' in its output.
  45.  * See /NextDeveloper/Examples/DSP/SoundDSPDriver for examples.
  46.  */
  47.  
  48. int SNDCompressSound(SNDSoundStruct *s1, SNDSoundStruct **s2,
  49.              int compressionType, int dropBits);
  50. /*
  51.  * If the data format of sound s1 is SND_FORMAT_COMPRESSED
  52.  * or SND_FORMAT_COMPRESSED_EMPHASIZED, the sound
  53.  * is decompressed into s2.  If s1 is SND_FORMAT_LINEAR_16 or 
  54.  * SND_FORMAT_EMPHASIZED, the sound is compressed into s2.
  55.  * The compressionType and dropBits parameters are used when compressing.
  56.  * There are currently three compress formats supported by NeXT system
  57.  * software:
  58.  *   SND_CFORMAT_BITS_DROPPED    - low bits removed for lossy compression
  59.  *   SND_CFORMAT_BIT_FAITHFUL    - lossless compression
  60.  *   SND_CFORMAT_ATC              - audio transform compression (lossy)
  61.  * (constants defined in /usr/include/sound/soundstructs.h).
  62.  * If the compression is lossless,
  63.  * the recorded sound can be decompressed exactly back to its original samples.
  64.  * Otherwise the decompressed sound will have some degradation.  The dropBits
  65.  * parameter specifies the number of bits to right shift off of each sample
  66.  * before compressing for the dropped-bits compression type.  DropBits
  67.  * ranges from 4 to 8 bits, with higher numbers giving more compression 
  68.  * but less fidelity.  A typical value is 4.  In bit faithful mode, dropBits
  69.  * may affect the amount of compression, but decompression will still be
  70.  * exact.  For type ATC, dropBits has no effect at present, but in the 
  71.  * future it may affect the compression quality such that dropBits = 0 
  72.  * gives maximum quality, and dropBits = 8 would give maximum compression.
  73.  * CompressionTypBSafaults to SND_CFORMAT_ATC and dropBits defaults to 0.
  74.  * A new SNDSoundStruct is created which contains the converted sound, and
  75.  * s2 is set to point at it. An error code is returned.
  76.  */
  77.  
  78.