soundio.h

Go to the documentation of this file.
00001 /*
00002     soundio.h:
00003 
00004     Copyright (C) 1991, 2000 Barry Vercoe, Richard Dobson
00005 
00006     This file is part of Csound.
00007 
00008     The Csound Library is free software; you can redistribute it
00009     and/or modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     Csound is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with Csound; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021     02111-1307 USA
00022 */
00023                                 /*                      SOUNDIO.H       */
00024 #ifndef CSOUND_SOUNDIO_H
00025 #define CSOUND_SOUNDIO_H
00026 
00027 #include <sndfile.h>
00028 
00029 #ifdef WIN32
00030 #define IOBUFSAMPS   4096   /* default sampframes in audio iobuf, -b settable */
00031 #define IODACSAMPS   16384  /* default samps in hardware buffer,  -B settable */
00032 #elif defined(NeXT) || defined(__MACH__)
00033 #define IOBUFSAMPS   1024   /* default sampframes in audio iobuf, -b settable */
00034 #define IODACSAMPS   4096   /* default samps in hardware buffer,  -B settable */
00035 #else
00036 #define IOBUFSAMPS   256    /* default sampframes in audio iobuf, -b settable */
00037 #define IODACSAMPS   1024   /* default samps in hardware buffer,  -B settable */
00038 #endif
00039 
00040 #define SNDINBUFSIZ  4096   /* soundin bufsize;   must be > sizeof(SFHEADER), */
00041                             /*                 but small is kind to net rexec */
00042 
00043 /* standard audio encoding types */
00044 
00045 #define AE_CHAR         SF_FORMAT_PCM_S8
00046 #define AE_SHORT        SF_FORMAT_PCM_16
00047 #define AE_24INT        SF_FORMAT_PCM_24
00048 #define AE_LONG         SF_FORMAT_PCM_32
00049 #define AE_UNCH         SF_FORMAT_PCM_U8
00050 #define AE_FLOAT        SF_FORMAT_FLOAT
00051 #define AE_DOUBLE       SF_FORMAT_DOUBLE
00052 #define AE_ULAW         SF_FORMAT_ULAW
00053 #define AE_ALAW         SF_FORMAT_ALAW
00054 #define AE_IMA_ADPCM    SF_FORMAT_IMA_ADPCM
00055 #define AE_MS_ADPCM     SF_FORMAT_MS_ADPCM
00056 #define AE_GSM610       SF_FORMAT_GSM610
00057 #define AE_VOX          SF_FORMAT_VOX_ADPCM
00058 #define AE_G721_32      SF_FORMAT_G721_32
00059 #define AE_G723_24      SF_FORMAT_G723_24
00060 #define AE_G723_40      SF_FORMAT_G723_40
00061 #define AE_DWVW_12      SF_FORMAT_DWVW_12
00062 #define AE_DWVW_16      SF_FORMAT_DWVW_16
00063 #define AE_DWVW_24      SF_FORMAT_DWVW_24
00064 #define AE_DWVW_N       SF_FORMAT_DWVW_N
00065 #define AE_DPCM_8       SF_FORMAT_DPCM_8
00066 #define AE_DPCM_16      SF_FORMAT_DPCM_16
00067 
00068 #define AE_LAST   SF_FORMAT_DPCM_16     /* current last audio encoding value */
00069 
00070 /* file types */
00071 
00072 #define TYP_WAV   (SF_FORMAT_WAV >> 16)
00073 #define TYP_AIFF  (SF_FORMAT_AIFF >> 16)
00074 #define TYP_AU    (SF_FORMAT_AU >> 16)
00075 #define TYP_RAW   (SF_FORMAT_RAW >> 16)
00076 #define TYP_PAF   (SF_FORMAT_PAF >> 16)
00077 #define TYP_SVX   (SF_FORMAT_SVX >> 16)
00078 #define TYP_NIST  (SF_FORMAT_NIST >> 16)
00079 #define TYP_VOC   (SF_FORMAT_VOC >> 16)
00080 #define TYP_IRCAM (SF_FORMAT_IRCAM >> 16)
00081 #define TYP_W64   (SF_FORMAT_W64 >> 16)
00082 #define TYP_MAT4  (SF_FORMAT_MAT4 >> 16)
00083 #define TYP_MAT5  (SF_FORMAT_MAT5 >> 16)
00084 #define TYP_PVF   (SF_FORMAT_PVF >> 16)
00085 #define TYP_XI    (SF_FORMAT_XI >> 16)
00086 #define TYP_HTK   (SF_FORMAT_HTK >> 16)
00087 #define TYP_SDS   (SF_FORMAT_SDS >> 16)
00088 #define TYP_AVR   (SF_FORMAT_AVR >> 16)
00089 #define TYP_WAVEX (SF_FORMAT_WAVEX >> 16)
00090 #if defined(HAVE_LIBSNDFILE) && HAVE_LIBSNDFILE >= 1011
00091 #  define TYP_SD2     (SF_FORMAT_SD2 >> 16)
00092 #  if HAVE_LIBSNDFILE >= 1013
00093 #    define TYP_FLAC  (SF_FORMAT_FLAC >> 16)
00094 #    define TYP_CAF   (SF_FORMAT_CAF >> 16)
00095 #  endif
00096 #endif
00097 
00098 #define FORMAT2SF(x) ((int) (x))
00099 #define SF2FORMAT(x) ((int) (x) & 0xFFFF)
00100 #define TYPE2SF(x)   ((int) (x) << 16)
00101 #define SF2TYPE(x)   ((int) (x& SF_FORMAT_TYPEMASK) >> 16)
00102 
00103 #ifdef  USE_DOUBLE
00104 #define sf_write_MYFLT  sf_write_double
00105 #define sf_read_MYFLT   sf_read_double
00106 #else
00107 #define sf_write_MYFLT  sf_write_float
00108 #define sf_read_MYFLT   sf_read_float
00109 #endif
00110 
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114 
00115 /* generic sound input structure */
00116 
00117 typedef struct {
00118         SNDFILE *sinfd;             /* sound file handle                    */
00119         MYFLT   *inbufp, *bufend;   /* current buffer position, end of buf  */
00120         void    *fd;                /* handle returned by csoundFileOpen()  */
00121         int     bufsmps;            /* number of mono samples in buffer     */
00122         int     format;             /* sample format (AE_SHORT, etc.)       */
00123         int     channel;            /* requested channel (ALLCHNLS: all)    */
00124         int     nchanls;            /* number of channels in file           */
00125         int     sampframsiz;        /* sample frame size in bytes           */
00126         int     filetyp;            /* file format (TYP_WAV, etc.)          */
00127         int     analonly;           /* non-zero for analysis utilities      */
00128         int     endfile;            /* end of file reached ? non-zero: yes  */
00129         int     sr;                 /* sample rate in Hz                    */
00130         int     do_floatscaling;    /* scale floats by fscalefac ? 0: no    */
00131         int64_t audrem, framesrem, getframes;   /* samples, frames, frames */
00132         MYFLT   fscalefac;
00133         MYFLT   skiptime;
00134         char    sfname[512];
00135         MYFLT   inbuf[SNDINBUFSIZ];
00136 } SOUNDIN;
00137 
00138 #ifdef __cplusplus
00139 }
00140 #endif
00141 
00142 #endif      /* CSOUND_SOUNDIO_H */
00143 

Generated on Sun Nov 9 00:04:52 2008 for Csound and CsoundAC by  doxygen 1.5.6