|
|
|
04-05-2017, 03:51 AM
|
#1
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
Can't get MIDI metadata C++
Hi. I'm using the following code in C++ to get the sysex messages:
Code:
auto mehwnd = MIDIEditor_GetActive();
auto mit = MIDIEditor_GetTake(mehwnd);
int numOfNotes;
int numOfCCs;
int numOfSysex;
MIDI_CountEvts(mit, &numOfNotes, &numOfCCs, &numOfSysex);
for (int i = 0; i < numOfSysex; ++i)
{
bool selectedOutOptional;
bool mutedOutOptional;
double ppqposOutOptional;
int typeOutOptional;
char msgOptional[1024];
int msgOptional_sz;
int retval = MIDI_GetTextSysexEvt(mit, i,
&selectedOutOptional, &mutedOutOptional, &ppqposOutOptional,
&typeOutOptional, msgOptional, &msgOptional_sz);
ShowConsoleMsg(msgOptional);
I tried char* msgOptional, many different array values, nothing works. All the other data are retrived fine. What am I doing wrong, guys?
Thanks.
__________________
Ceanganb
Last edited by ceanganb; 04-05-2017 at 03:52 AM.
Reason: improve title
|
|
|
04-06-2017, 03:34 AM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Maybe msgOptional_sz needs to initially have the size of your char buffer.
Code:
char msgOptional[1024];
int msgOptional_sz=sizeof(msgOptional);
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-06-2017, 08:01 AM
|
#3
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
|
|
|
04-06-2017, 09:16 AM
|
#4
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
@Xenakios: That was it, the * in the msgOptional_sz field led me to thinking I was getting a value instead of setting, like the rest of them. Thanks again for saving me.
@nofish: Yes, I'm also struggling with the older standard C-style idioms, I'm new to C++ and virtually bypassed the char* stuff, back to school again.
__________________
Ceanganb
|
|
|
04-06-2017, 09:39 AM
|
#5
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by ceanganb
@Xenakios: That was it, the * in the msgOptional_sz field led me to thinking I was getting a value instead of setting
|
In C there isn't really much else to do for "optional" variables than to use a pointer. So you might be able to use a null pointer in this case too...But the pointer to the size variable may also be used to return how much of the buffer Reaper ended up using, so it's probably safer/more useful to give it the address of the integer size variable.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-06-2017, 09:58 AM
|
#6
|
Human being with feelings
Join Date: May 2009
Location: Brazil
Posts: 323
|
Quote:
Originally Posted by Xenakios
But the pointer to the size variable may also be used to return how much of the buffer Reaper ended up using, so it's probably safer/more useful to give it the address of the integer size variable.
|
That's what I though, the pointer made me think that it was a value returned from the function, based on other functions' signature, like GetTrackName(MediaTrack* track, char* buf, int buf_sz), where it's clear that the size must be provided. And why "optional", my poor mind can't see what is optional in a sysex message. If it was the case of an empty sysex, but then sizeof would reveal that.
P.S.: In Reaper, an empty sysex can't even exist.
__________________
Ceanganb
|
|
|
04-07-2017, 06:09 AM
|
#7
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by ceanganb
And why "optional", my poor mind can't see what is optional in a sysex message
|
It's probably optional for the purposes of ReaScript, the C API is just using a similar function signature although the stuff isn't really optional when used from C. (In ReaScript the function can do the needed buffer allocation itself but in C it's typical the allocation and passing in the available size is the responsibility of the calling code.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:40 AM.
|