Is it possible to somehow get audioMasterCallback?


#1

I'm writting a plugin exclusively for REAPER so I want to use some of it's extensions API. That API is regularly used by REAPER extensions (for example, SWS: https://github.com/Jeff0S/sws ) but VST plugins can use it too.

Documentation (http://www.cockos.com/reaper/sdk/vst/vst_ext.php#vst_host) specifies that we must use audioMasterCallback to obtain pointers to those API functions.

However, it seems that JUCE is hiding that from us (I can understand how this can be a wise decision in a system which supports multiple plugin formats). Is there some "normal" way of obtaining audioMasterCallback pointer? I've been thinking about patching JUCE for that, but that would mean I would have to repatch it every time I update it but that doesn't seems as elegant.

 

Thanks!
 

 

 

 

 


#2

There's currently no exposure of audioMasterCallback, but it could probably be made possible with a macro to allow your code to access it. Might be worth adding, I guess.

We already support a few Reaper extensions - which other ones were you trying to use?


#3

Surely you know that with Git version control there's a good chance you don't need to repatch the code when updating Juce? I've actually done this change myself (the ability to use the Reaper extension API with VST plugins in Juce) and haven't gotten any merge conflicts so far when updating Juce.


#4

Hey Jules! Thanks for a quick reply!

I just need to get the pointer to a few REAPER API functions so I can extract images that are used to display colors for MIDI channels.

For example, lets say that AudioProcessor somehow gave us the ability to access audioMasterCallback I could do it like this:


if (audioMasterCallback callback = this->getAudioMasterCallback();)
{
    void* (*GetIconThemeStruct)(int* szOut);
    *(long *)&GetIconThemeStruct = (long)callback(NULL,0xdeadbeef,0xdeadf00d,0,"GetIconThemeStruct",0.0);
    // do whatever needs to be done using the REAPER API
}

I didn't know that JUCE supports other REAPER extensions! In this specific case, I guess macro to revelal audioMasterCallback pointer would be a great addition.

I'm new to JUCE and I must confess that it's really a pleasure to work with for now. Every time I need something, it's always there, together with enough comments to understand it immediately. Big, big thanks for it!


#5

 Hey Xenakios! Nice seeing you here! :)

All that Git magic could be employed, but I will not be the only developer for this project and it will probably get published on GitHub so I would like to make it easily accessible. If I'm not mistaken, all the developers would have to keep separate branch of JUCE and watch out the patch is applied to it - just for this one project that feels a bit like an overkill.

How exactly do you manage your JUCE patches? Would you care to share a patch that allows you to get REAPER API with JUCE? Thanks! :)


#6

I've been living fairly dangerously and just do my changes on the Juce master branch. :) So far I haven't got merge conflicts when updating Juce. (Knocking on wood...) All my Juce projects on the same machine use the same Juce tree and I always check in Introjucer it doesn't make a copy of the Juce source code for the new project. I can see that in your situation with multiple developers having a forked/patched Juce might be problematic. So maybe it's best if Jules comes up with some neat solution for this. 

I haven't looked at my VST plugin project that uses the Reaper extension API for a long time, but I vaguely recall the way how I made that be able to access the audioMastercallback wasn't very pretty. IIRC it involved having that as a global variable that was shared between the code files with "extern".


#7

Haha, I just tried saving audioMasterCallback in AudioProcessor during its contruction, but I'm getting some linkage errors - still need to figure it out but I keep getting back to "real" part of the plugin I'm writting. Setting the enviroment and IDE is the most boring part of coding :)


#8

The changes I did to the Juce code were a bit more involved than I remembered...I was misled by some other problem to believe the global variable shared with "extern" wouldn't work to pass the audioMasterCallback into the plugin code. So there's not really a clean piece of source code I could share at the moment. (What I ended up doing seems far more complicated than was really necessary...) However, it is possible to make it work! And maybe Jules will add the ability to use the audioMasterCallback directly with the official Juce source.

If you are completely stuck with this now and want it working, I can look it through with you.