Do you mean “of 50MB each”? If so, embedding them as BinaryData is no good idea. What the Projucer does when encoding your files into binary data is reading it byte by byte and creating a huge char
array from that containing each byte as integer constant. Just have a look at the BinaryData.cpp
file from a current project where a few SVG files are embedded as binary data:
You can probably imagine how huge your BinaryData file would become if you would try to embed 500MB of data this way and how slow compilation would become. For that reason, the Projucer even limits the max size of each file to be encoded into BinaryData to 20MB. This should definitively be read from file. If I got you wrong and you didn’t mean 50MB then you basically have two options:
First would be to reinterpret_cast
your BinaryData to a float pointer that can be accessed like a one-dimensional array. You would then have to compute the offsets in that one dimensional array depending on the three dimensions. Maybe with some helper struct like
template <int dim1, int dim2, int dim3>
struct ThreeDimBinaryData
{
ThreeDimBinaryData (const char* binaryData) : values (reinterpret_cast<const float*> (binaryData) {};
const float* values;
int getIdxAt (int x, int y, int z)
{
return x + y * dim1 + z * dim1 * dim2;
}
float getValueAt (int x, int y, int z)
{
return values[getIdxAt (x, y, z)];
}
};
(Untested, better check the index calculation, might be wrong, but I guess you get what I mean). Usage would be like
ThreeDimBinaryData<dim1, dim2, dim3> data (BinaryData::something_extension);
float foo = data.getValueAt (1, 2, 3);
However, if you want to stick to the 3D array, you can of course do the same as reading from file through a stupid std::memcpy
float array[dim1][dim2][dim3];
std::memcpy (array, BinaryData::something_extension, sizeof (array));
However that could be quite inefficient, as you are duplicating content that already lives in memory.
If you want to go the file route, you should also check the JUCE File
and FileInputStream
classes which give you a lot better file handling options for real-world applications.