vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
MIT License
2.24k stars 147 forks source link

Accessing an externally defined C++ data structure #311

Closed sletz closed 1 year ago

sletz commented 1 year ago

I need to access an externally defined C++ data structure, like the following one, to be created and filled by another part of the program, add then accessed in the MIR code. Is that possible, and if yes using which API ?

struct Soundfile {
    void* fBuffers; // will correspond to a double** or float** pointer chosen at runtime
    int* fLength;   // length of each part (so fLength[P] contains the length in frames of part P)
    int* fSR;       // sample rate of each part (so fSR[P] contains the SR of part P)
    int* fOffset;   // offset of each part in the global buffer (so fOffset[P] contains the offset in frames of part P)
    int fChannels;  // max number of channels of all concatenated files
    int fParts;     // the total number of loaded parts
    bool fIsDouble; // keep the sample format (float or double)
}
sletz commented 1 year ago

I found the solution.

LightSun commented 1 year ago

@sletz how to do?

sletz commented 1 year ago

@LightSun have a look at https://github.com/grame-cncm/faust/blob/master-dev/compiler/generator/interpreter/fbc_mir_compiler.hh, see use of fSoundArrayTable, fSoundTableID and fMIRSoundTable.

LightSun commented 1 year ago

@sletz ok, thanks. I see some.

LightSun commented 1 year ago

@sletz I found how to use member of stuct, But I can't find how to create struct. Do you have a demo?

sletz commented 1 year ago

Nope.

LightSun commented 1 year ago

@sletz Thanks all the same. Do you use this library to do some funny things?

sletz commented 1 year ago

Used in Faust.