User Guide
DLL Component
To set the output value we need to create a new byte array. Again, this is very similar to the arrays and strings. Once again the management
of memory is up to you:
// Create a new byte array (assuming we have already defined bytes)
unsigned char* pNewBytes = new unsigned char[bytes+4*3];
*((unsigned char**)(&pOut[x])) = pNewBytes;
// Set the data descriptors (assume width, height and channels have been defined)
*((int*)pNewBytes) = width
*((int*)pNewBytes+1) = height
*((int*)pNewBytes+2) = channels
// Get pointer to pixel data
unsigned char* pPixelData = pNewBytes+12;
{you then need to initialise your byte data}
This only shows you how to create the data. You may have to provide additional code to manage when the bitmap data is deleted. For
example, you may want to create a new array and then keep reusing it (as opposed to deleting and recreating it every time). You may then
want to delete and recreate it only when the bitmap changes size. All this is down to you to decide.
Frames
By handling Ruby Frame objects (generated by the Mono To Frame component) you can process audio at sampling rate.
Like Float arrays, Frames are represented as a C array of floats. They have the same extra entry at the start providing 4 bytes to store the
number of array elements followed by the float array itself. To separate these we do the following:
int size = *((int*)pIn[x]);
float* array = (float*)pIn[x]+1;
Unlike Float Arrays, Frames use the same array for both the input and the output. This means that you don't have to create a new array to
pass to the output array – it has already been done for you. The main reason for this is that the output array must be the same size as the
input one. However, there is also a benefit in terms of efficiency too.
So all you need to do is process the input array and update it. Just be careful not to assign a value to an array element until you've finished
using it or you've stored its value otherwise you may end up using the new value instead of the one that came originally.
Helpers
The casting can be a bit cumbersome so we came up with some simple macros that make accessing and setting the input and output arrays
a bit easier and more readable.
192 of 212