First of all, my knowledge of C is closer to zero, so I`m sorry if I saying something totally wrong.
I though before that C++ code perform faster because it closely interract with some internal REAPER objects. Today I just for interest took a look at SWS source and find their stuff also operate almost same things I have in mind from scripter side.
Code:
bool SNM_AddTCPFXParm(MediaTrack* _tr, int _fxId, int _prmId)
{
bool updated = false;
if (_tr && _fxId>=0 && _prmId>=0 && _fxId<TrackFX_GetCount(_tr) && _prmId<TrackFX_GetNumParams(_tr, _fxId))
{
// already exists?
int fxId, prmId;
for (int i=0; i<CountTCPFXParms(NULL, _tr); i++)
if (GetTCPFXParm(NULL, _tr, i, &fxId, &prmId))
if (fxId==_fxId && prmId==_prmId)
return false;
SNM_ChunkParserPatcher p(_tr);
// first get the fx chain: a straight search for the fx would fail (possible mismatch with frozen track, item fx, etc..)
WDL_FastString chainChunk;
if (p.GetSubChunk("FXCHAIN", 2, 0, &chainChunk, "<ITEM") > 0)
{
SNM_ChunkParserPatcher pfxc(&chainChunk, false);
int pos = pfxc.Parse(SNM_GET_CHUNK_CHAR,1,"FXCHAIN","WAK",_fxId,0);
if (pos>0)
{
char line[SNM_MAX_CHUNK_LINE_LENGTH] = "";
if (_snprintfStrict(line, sizeof(line), "PARM_TCP %d\n", _prmId) > 0)
{
pfxc.GetChunk()->Insert(line, --pos);
if (p.ReplaceSubChunk("FXCHAIN", 2, 0, pfxc.GetChunk()->Get(), "<ITEM")) {
updated = true;
p.Commit(true);
}
}
}
}
}
return updated;
}
This function add 'PARM_TCP param_number' line to FX chunk. As far as I can see, there is no any special access to some internal variables, but just parse chunk. If I do almost same thing (I need to set parameter alias) in Lua, will it be 'worse' (much slower, less safer) than a using extension API?