|
|
|
04-27-2016, 03:20 PM
|
#1
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
TrackFX_GetInstrument(MediaTrack* track) C version working ? (solved)
edit:
Solved, see below
=== original post ===
I got this code for testing
Code:
void TestAction(COMMAND_T* ct)
{
MediaTrack* track = GetTrack(0, 0); // get track 1 (index 0)
int numParams = 0; int instrIdx = 0;
if (track) {
numParams = TrackFX_GetNumParams(track, 0); // works
instrIdx = TrackFX_GetInstrument(track); // does nothing or throws exception
}
}
I somehow cannot get 'TrackFX_GetInstrument(Track*)' working, it either does nothing or throws an exception.
https://i.imgur.com/gWv38ao.jpg
I know the EEL version is working, because I use it in a script.
Could someone confirm / deny if the C version is working correctly or if I'm doing something wrong ?
Last edited by nofish; 04-28-2016 at 05:00 AM.
|
|
|
04-27-2016, 03:32 PM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Have you correctly initialized the function pointer for TrackFX_GetInstrument in your C or C++ code?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-27-2016, 03:48 PM
|
#3
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Thanks Xen.
But sorry, uh what ?
That's a Reaper API function I'm calling, what do I have to init ?
I'm asking because for TrackFX_GetNumParams(Track*, idx), also an API function, I haven't init anything either and it works.
edit:
I think that's already handled by the SWS codebase I'm using ?
(sorry for the noob question, taking my first steps with SWS extensions)
|
|
|
04-27-2016, 03:52 PM
|
#4
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by nofish
Thanks Xen.
But sorry, uh what ?
That's a Reaper API function I'm calling, what do I have to init ?
I'm asking because for TrackFX_GetNumParams(Track*, idx), also an API function, I haven't init anything either and it works.
(sorry for the noob question, taking my first steps with SWS extensions)
|
The Reaper API functions must be "loaded" from Reaper in C and C++ code before they can be correctly used. I don't know how the SWS extension does the API function initing these days, but it used to be a manual thing with the horrible IMPAPI macro. There may be the IMPAPI calls for TrackFX_GetNumParams and various other API functions, but not for the one you are now trying to use.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-27-2016, 04:01 PM
|
#5
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Aha, now that makes more sense to me.
I think I now remember you mentioning IMPAPI macro when I had a look at your extension plugin example.
I can investigate further now, thanks.
|
|
|
04-27-2016, 04:12 PM
|
#6
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Just checked the source code. It's still using the manual import of the API functions and TrackFX_GetInstrument is missing in sws_extension.cpp. So you should add IMPAPI(TrackFX_GetInstrument); among the other IMPAPI invokations.
There's a way to remove the use of IMPAPI and load all the declared functions in one go, but that might need some changes in the source code I can't myself test right now.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-28-2016, 04:11 AM
|
#7
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
That helped a lot, I was totally unaware of that 'API functions loading' requirement.
Coming from ReaScript I thought I can instantly use them also in C / SWS extensions and scratched my head why it didn't work.
Will try the IMPAPI thing and report back how it went.
Thanks again.
|
|
|
04-28-2016, 04:58 AM
|
#8
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
It works !
I found it was only a one-liner to add (as you said) as SWS did already the had work.
So, easy once you know what to do.
|
|
|
04-28-2016, 05:11 AM
|
#9
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by nofish
It works !
I found it was only a one-liner to add (as you said) as SWS did already the had work.
So, easy once you know what to do.
|
The missing IMPAPI calls are a classic mine to step into. The code should really be changed to use the newer API loading mechanism instead.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
04-28-2016, 06:56 AM
|
#10
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by Xenakios
The missing IMPAPI calls are a classic mine to step into. The code should really be changed to use the newer API loading mechanism instead.
|
Agreed. Though changing the base code is nothing I could / wanted to do at this point.
But I'll ping Jeffos to at least update the SWS Wiki about it for now, because yeah, it's a stepping stone for beginners, as I've found the hard way.
|
|
|
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 12:01 PM.
|