1 /* 2 pvfileio.h: 3 4 Copyright (C) 2000 Richard Dobson 5 6 This file is part of Csound. 7 8 The Csound Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 Csound is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with Csound; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 02110-1301 USA 22 */ 23 24 /* pvfileio.h: header file for PVOC_EX file format */ 25 /* Initial Version 0.1 RWD 25:5:2000 all rights reserved: work in progress! */ 26 27 #ifndef __PVFILEIO_H_INCLUDED 28 #define __PVFILEIO_H_INCLUDED 29 30 #include "sysdep.h" 31 32 #if defined(WIN32) || defined(_WIN32) || defined(_MSC_VER) 33 34 #include <windows.h> 35 36 #else 37 38 typedef struct 39 { 40 uint32_t Data1; 41 uint16_t Data2; 42 uint16_t Data3; 43 unsigned char Data4[8]; 44 } GUID; 45 46 typedef struct /* waveformatex */ { 47 uint16_t wFormatTag; 48 uint16_t nChannels; 49 uint32_t nSamplesPerSec; 50 uint32_t nAvgBytesPerSec; 51 uint16_t nBlockAlign; 52 uint16_t wBitsPerSample; 53 uint16_t cbSize; 54 } WAVEFORMATEX; 55 56 #endif 57 58 /* NB no support provided for double format (yet) */ 59 60 typedef enum pvoc_wordformat { 61 PVOC_IEEE_FLOAT, 62 PVOC_IEEE_DOUBLE 63 } pvoc_wordformat; 64 65 /* include PVOC_COMPLEX for some parity with SDIF */ 66 67 typedef enum pvoc_frametype { 68 PVOC_AMP_FREQ = 0, 69 PVOC_AMP_PHASE, 70 PVOC_COMPLEX 71 } pvoc_frametype; 72 73 /* a minimal list */ 74 75 typedef enum pvoc_windowtype { 76 PVOC_DEFAULT = 0, 77 PVOC_HAMMING = 0, 78 PVOC_HANN, 79 PVOC_KAISER, 80 PVOC_RECT, 81 PVOC_CUSTOM 82 } pv_wtype; 83 84 /* Renderer information: source is presumed to be of this type */ 85 86 typedef enum pvoc_sampletype { 87 STYPE_16, 88 STYPE_24, 89 STYPE_32, 90 STYPE_IEEE_FLOAT 91 } pv_stype; 92 93 typedef struct pvoc_data { /* 32 bytes */ 94 uint16_t wWordFormat; /* pvoc_wordformat */ 95 uint16_t wAnalFormat; /* pvoc_frametype */ 96 uint16_t wSourceFormat; /* WAVE_FORMAT_PCM or WAVE_FORMAT_IEEE_FLOAT */ 97 uint16_t wWindowType; /* pvoc_windowtype */ 98 uint32_t nAnalysisBins; /* implicit FFT size = (nAnalysisBins-1) * 2 */ 99 uint32_t dwWinlen; /* analysis winlen, in samples */ 100 /* NB may be != FFT size */ 101 uint32_t dwOverlap; /* samples */ 102 uint32_t dwFrameAlign; /* usually nAnalysisBins * 2 * sizeof(float) */ 103 float fAnalysisRate; 104 float fWindowParam; /* default 0.0f unless needed */ 105 } PVOCDATA; 106 107 typedef struct { 108 WAVEFORMATEX Format; /* 18 bytes: info for renderer */ 109 /* as well as for pvoc */ 110 union { /* 2 bytes */ 111 uint16_t wValidBitsPerSample; /* as per standard WAVE_EX: */ 112 /* applies to renderer */ 113 uint16_t wSamplesPerBlock; 114 uint16_t wReserved; 115 } Samples; 116 uint32_t dwChannelMask; /* 4 bytes: can be used as in */ 117 /* standrad WAVE_EX */ 118 GUID SubFormat; /* 16 bytes */ 119 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; 120 121 typedef struct { 122 WAVEFORMATEXTENSIBLE wxFormat; /* 40 bytes */ 123 uint32_t dwVersion; /* 4 bytes */ 124 uint32_t dwDataSize; /* 4 bytes: sizeof PVOCDATA data block */ 125 PVOCDATA data; /* 32 bytes */ 126 } WAVEFORMATPVOCEX; /* total 80 bytes */ 127 128 /* at least VC++ will give 84 for sizeof(WAVEFORMATPVOCEX), */ 129 /* so we need our own version */ 130 #define SIZEOF_FMTPVOCEX (80) 131 /* for the same reason: */ 132 #define SIZEOF_WFMTEX (18) 133 #define PVX_VERSION (1) 134 135 /******* the all-important PVOC GUID 136 137 {8312B9C2-2E6E-11d4-A824-DE5B96C3AB21} 138 139 **************/ 140 141 #ifndef CSOUND_CSDL_H 142 143 extern const GUID KSDATAFORMAT_SUBTYPE_PVOC; 144 145 /* pvoc file handling functions */ 146 147 const char *pvoc_errorstr(CSOUND *); 148 int init_pvsys(CSOUND *); 149 int pvoc_createfile(CSOUND *, const char *, 150 uint32, uint32, uint32, 151 uint32, int32, int, int, 152 float, float *, uint32); 153 int pvoc_openfile(CSOUND *, 154 const char *filename, void *data_, void *fmt_); 155 int pvoc_closefile(CSOUND *, int); 156 int pvoc_putframes(CSOUND *, 157 int ofd, const float *frame, int32 numframes); 158 int pvoc_getframes(CSOUND *, 159 int ifd, float *frames, uint32 nframes); 160 int pvoc_framecount(CSOUND *, int ifd); 161 int pvoc_fseek(CSOUND *, int ifd, int offset); 162 int pvsys_release(CSOUND *); 163 164 #endif /* CSOUND_CSDL_H */ 165 166 #endif /* __PVFILEIO_H_INCLUDED */ 167 168