1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
* Copyright (C) 2014 Edward Costello
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "csdl.h"
#include "hdf5.h"
#include <stdbool.h>
typedef enum ArgumentType
{
STRING_VAR,
ARATE_VAR,
KRATE_VAR,
IRATE_VAR,
ARATE_ARRAY,
KRATE_ARRAY,
IRATE_ARRAY,
UNKNOWN
} ArgumentType;
typedef struct _fft {
OPDS h;
ARRAYDAT *out;
ARRAYDAT *in, *in2;
MYFLT *f;
MYFLT b;
int32_t n;
void *setup;
AUXCH mem;
} nFFT;
typedef struct HDF5Dataset
{
char *datasetName;
AUXCH datasetNameMemory;
void *argumentPointer;
ArgumentType writeType;
ArgumentType readType;
int32_t rank;
hsize_t *chunkDimensions;
AUXCH chunkDimensionsMemory;
hsize_t *maxDimensions;
AUXCH maxDimensionsMemory;
hsize_t *offset;
AUXCH offsetMemory;
hsize_t *datasetSize;
AUXCH datasetSizeMemory;
hid_t datasetID;
size_t elementCount;
MYFLT *sampleBuffer;
AUXCH sampleBufferMemory;
bool readAll;
} HDF5Dataset;
typedef struct HDF5File
{
hid_t fileHandle;
char *fileName;
hid_t floatSize;
} HDF5File;
HDF5File *HDF5IO_newHDF5File(CSOUND *csound, AUXCH *hdf5FileMemory,
STRINGDAT *path, bool openForWriting);
void HDF5IO_deleteHDF5File(CSOUND *csound, HDF5File *hdf5File);
typedef struct HDF5Write
{
OPDS h;
MYFLT *arguments[20];
int32_t inputArgumentCount;
size_t ksmps;
HDF5File *hdf5File;
AUXCH hdf5FileMemory;
HDF5Dataset *datasets;
AUXCH datasetsMemory;
} HDF5Write;
int32_t HDF5Write_initialise(CSOUND *csound, HDF5Write *self);
int32_t HDF5Write_process(CSOUND *csound, HDF5Write *self);
int32_t HDF5Write_finish(CSOUND *csound, void *inReference);
void HDF5Write_checkArgumentSanity(CSOUND *csound, const HDF5Write *self);
void HDF5Write_createDatasets(CSOUND *csound, HDF5Write *self);
void HDF5Write_newArrayDataset(CSOUND *csound, HDF5Write *self,
HDF5Dataset *dataset);
void HDF5Write_deleteArrayDataset(CSOUND *csound, HDF5Dataset *dataset);
typedef struct HDF5Read
{
OPDS h;
MYFLT *arguments[20];
STRINGDAT *path;
STRINGDAT *names[20];
int32_t inputArgumentCount;
int32_t outputArgumentCount;
size_t ksmps;
HDF5File *hdf5File;
AUXCH hdf5FileMemory;
HDF5Dataset *datasets;
AUXCH datasetsMemory;
bool isSampleAccurate;
} HDF5Read;
int32_t HDF5Read_initialise(CSOUND *csound, HDF5Read *self);
int32_t HDF5Read_process(CSOUND *csound, HDF5Read *self);
int32_t HDF5Read_finish(CSOUND *csound, void *inReference);
void HDF5Read_checkArgumentSanity(CSOUND *csound, const HDF5Read *self);
void HDF5Read_openDatasets(CSOUND *csound, HDF5Read *self);
|