pvfileio.h

Go to the documentation of this file.
00001 /*
00002     pvfileio.h:
00003 
00004     Copyright (C) 2000 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 
00024 /* pvfileio.h: header file for PVOC_EX file format */
00025 /* Initial Version 0.1 RWD 25:5:2000 all rights reserved: work in progress! */
00026 
00027 #ifndef __PVFILEIO_H_INCLUDED
00028 #define __PVFILEIO_H_INCLUDED
00029 
00030 #include "sysdep.h"
00031 
00032 #if defined(WIN32) || defined(_WIN32) || defined(_MSC_VER)
00033 
00034 #include <windows.h>
00035 
00036 #else
00037 
00038 typedef struct _GUID
00039 {
00040     uint32_t        Data1;
00041     uint16_t        Data2;
00042     uint16_t        Data3;
00043     unsigned char   Data4[8];
00044 } GUID;
00045 
00046 typedef struct /* waveformatex */ {
00047     uint16_t    wFormatTag;
00048     uint16_t    nChannels;
00049     uint32_t    nSamplesPerSec;
00050     uint32_t    nAvgBytesPerSec;
00051     uint16_t    nBlockAlign;
00052     uint16_t    wBitsPerSample;
00053     uint16_t    cbSize;
00054 } WAVEFORMATEX;
00055 
00056 #endif
00057 
00058 /* NB no support provided for double format (yet) */
00059 
00060 typedef enum pvoc_wordformat {
00061     PVOC_IEEE_FLOAT,
00062     PVOC_IEEE_DOUBLE
00063 } pvoc_wordformat;
00064 
00065 /* include PVOC_COMPLEX for some parity with SDIF */
00066 
00067 typedef enum pvoc_frametype {
00068     PVOC_AMP_FREQ = 0,
00069     PVOC_AMP_PHASE,
00070     PVOC_COMPLEX
00071 } pvoc_frametype;
00072 
00073 /* a minimal list */
00074 
00075 typedef enum pvoc_windowtype {
00076     PVOC_DEFAULT = 0,
00077     PVOC_HAMMING,
00078     PVOC_HANN,
00079     PVOC_KAISER,
00080     PVOC_RECT,
00081     PVOC_CUSTOM
00082 } pv_wtype;
00083 
00084 /* Renderer information: source is presumed to be of this type */
00085 
00086 typedef enum pvoc_sampletype {
00087     STYPE_16,
00088     STYPE_24,
00089     STYPE_32,
00090     STYPE_IEEE_FLOAT
00091 } pv_stype;
00092 
00093 typedef struct pvoc_data {   /* 32 bytes */
00094     uint16_t    wWordFormat;    /* pvoc_wordformat                           */
00095     uint16_t    wAnalFormat;    /* pvoc_frametype                            */
00096     uint16_t    wSourceFormat;  /* WAVE_FORMAT_PCM or WAVE_FORMAT_IEEE_FLOAT */
00097     uint16_t    wWindowType;    /* pvoc_windowtype                           */
00098     uint32_t    nAnalysisBins;  /* implicit FFT size = (nAnalysisBins-1) * 2 */
00099     uint32_t    dwWinlen;       /* analysis winlen, in samples               */
00100                                 /*   NB may be != FFT size                   */
00101     uint32_t    dwOverlap;      /* samples                                   */
00102     uint32_t    dwFrameAlign;   /* usually nAnalysisBins * 2 * sizeof(float) */
00103     float       fAnalysisRate;
00104     float       fWindowParam;   /* default 0.0f unless needed                */
00105 } PVOCDATA;
00106 
00107 typedef struct {
00108     WAVEFORMATEX    Format;                 /* 18 bytes: info for renderer   */
00109                                             /*           as well as for pvoc */
00110     union {                                 /* 2 bytes */
00111       uint16_t      wValidBitsPerSample;    /* as per standard WAVE_EX:      */
00112                                             /*           applies to renderer */
00113       uint16_t      wSamplesPerBlock;
00114       uint16_t      wReserved;
00115     } Samples;
00116     uint32_t        dwChannelMask;          /* 4 bytes: can be used as in    */
00117                                             /*          standrad WAVE_EX     */
00118     GUID            SubFormat;              /* 16 bytes */
00119 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
00120 
00121 typedef struct {
00122     WAVEFORMATEXTENSIBLE wxFormat;  /* 40 bytes                              */
00123     uint32_t    dwVersion;          /* 4 bytes                               */
00124     uint32_t    dwDataSize;         /* 4 bytes: sizeof PVOCDATA data block   */
00125     PVOCDATA    data;               /* 32 bytes                              */
00126 } WAVEFORMATPVOCEX;                 /* total 80 bytes                        */
00127 
00128 /* at least VC++ will give 84 for sizeof(WAVEFORMATPVOCEX), */
00129 /* so we need our own version */
00130 #define SIZEOF_FMTPVOCEX    (80)
00131 /* for the same reason: */
00132 #define SIZEOF_WFMTEX       (18)
00133 #define PVX_VERSION         (1)
00134 
00135 /******* the all-important PVOC GUID
00136 
00137  {8312B9C2-2E6E-11d4-A824-DE5B96C3AB21}
00138 
00139 **************/
00140 
00141 #ifndef CSOUND_CSDL_H
00142 
00143 extern  const GUID KSDATAFORMAT_SUBTYPE_PVOC;
00144 
00145 /* pvoc file handling functions */
00146 
00147 const char *pvoc_errorstr(CSOUND *);
00148 int     init_pvsys(CSOUND *);
00149 int     pvoc_createfile(CSOUND *, const char *,
00150                         unsigned long, unsigned long, unsigned long,
00151                         unsigned long, long, int, int,
00152                         float, float *, unsigned long);
00153 int     pvoc_openfile(CSOUND *,
00154                       const char *filename, PVOCDATA *data, WAVEFORMATEX *fmt);
00155 int     pvoc_closefile(CSOUND *, int);
00156 int     pvoc_putframes(CSOUND *,
00157                        int ofd, const float *frame, long numframes);
00158 int     pvoc_getframes(CSOUND *,
00159                        int ifd, float *frames, unsigned long nframes);
00160 int     pvoc_framecount(CSOUND *, int ifd);
00161 int     pvoc_fseek(CSOUND *, int ifd, int offset);
00162 int     pvsys_release(CSOUND *);
00163 
00164 #endif  /* CSOUND_CSDL_H */
00165 
00166 #endif  /* __PVFILEIO_H_INCLUDED */
00167 

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