Old 07-29-2017, 10:04 PM   #1
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(" \n");
ShowConsoleMsg("caracter count in chunk:");
ShowConsoleMsg(" \n");

//test that "modchunk" is modified:

ShowConsoleMsg("caracter count in modchunk:");
ShowConsoleMsg(" \n");
ShowConsoleMsg("Replaced by :\n");

// 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

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

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

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 04:02 PM.

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