Old 07-29-2017, 10:04 PM   #1
dbmdbu
Human being with feelings
 
Join Date: Oct 2014
Posts: 6
Default C++ SetEnvelopeStateChunk making Reaper crash.

I have been tying to implement Volume and MUTE envelope automation ARM and UNARM functions using "GetEnvelopeStateChunk"/"SetEnvelopeStateChunk" API calls, but Reaper keeps 'unexpectedly quiting" as soon as the "SetEnvelopeStateChunk" function is executed.

This is part of the code that I use

#include <string>
#include <string.h>

/************************************************** **********************************/
// void ArmVolEnv(int trackid)
/************************************************** ***********************************/
void ArmVolEnv(int trackid)
{

std::string msgtofind("ARM");
std::string rplmsg("ARM 1");

TrackEnvelope* trackEnvelope = GetTrackEnvelopeByChunkName(GetTrack(nil,trackid), "<VOLENV2"); //Get Volume envelope from trackid

char chunk[2000];
chunk[0] = 0;

if(GetEnvelopeStateChunk(trackEnvelope, chunk, 1999, true))
{

std::string msg1(chunk);
std::size_t found = msg1.find(msgtofind);
msg1.replace(found, 5, rplmsg);
std::string msg1(chunk);
std::size_t found = msg1.find(msgtofind);
msg1.replace(found, 5, rplmsg);
char * modchunk = new char[msg1.length()+1];
std::strcpy (modchunk, msg1.c_str());
SetEnvelopeStateChunk(trackEnvelope,modchunk , 0);

//Test that chunk is correctly extracted:
char msgbuf1[32];
ShowConsoleMsg("Original msg: \n");
ShowConsoleMsg(chunk);
ShowConsoleMsg(" \n");
sprintf(msgbuf1,"%lu",strlen(chunk));
ShowConsoleMsg("caracter count in chunk:");
ShowConsoleMsg(msgbuf1);
ShowConsoleMsg(" \n");

//test that "modchunk" is modified:

sprintf(msgbuf1,"%lu",strlen(modchunk));
ShowConsoleMsg("caracter count in modchunk:");
ShowConsoleMsg(msgbuf1);
ShowConsoleMsg(" \n");
ShowConsoleMsg("Replaced by :\n");
sprintf(msgbuf1,"%s",msg1.c_str());
ShowConsoleMsg(msgbuf1);

// SetEnvelopeStateChunk(trackEnvelope, modchunk, 1);

}
}


if I comment out "SetEnvelopeStateChunk", it makes Reaper systematically crash.

I have attached the OSX crash report

Any help on that issue would be appreciated


dbmdbu
Attached Images
File Type: jpg Screen Shot 2017-07-30 at 10.23.18 AM.jpg (61.0 KB, 266 views)

Last edited by dbmdbu; 07-30-2017 at 07:26 AM.
dbmdbu is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.