View Single Post
Old 12-02-2009, 02:46 AM   #117
Human being with feelings
yhertogh's Avatar
Join Date: Nov 2006
Location: Belgium
Posts: 1,461

Originally Posted by ajaym View Post

Thanks folks

I found that I couldn't include the whole generated header file - Reaproject, referenced in some of the function declarations, is not a defined symbol anywhere including in the other header files, so I manually created the necessary extern definition for the API and added it to the dynamic load code.

Then the following code (iTrackNo starts from 0 because Sonar tracks are zero-based so we add 1)

bool bVal = false;
MediaTrack *tr=CSurf_TrackFromID(iTrackNo+1,false);
if (tr) bVal=*(bool *)GetSetMediaTrackInfo(tr,"B_MUTE",NULL);

seems to correctly return true and false.

I looked into the callback functions e.g SetSurfaceMute and found to my surprise that on a test project with one track and a single master and nothing else, this gets called about 10 times at startup (and my code to set muting was disabled at the time, because I already confirmed that if you programmatically set the mute value, you'll get the callback subsequently)

This seems rather more callbacks than I would expect, (I'd have thought just a couple, for the track and master mute status), although at present this is a bit academic because I'll get the whole thing working in 'Sonar' mode, where each poll we reconcile the surface status with the current project status, since Sonar doesn't support event change callbacks - it's not quite as efficient but in practice the CPU overhead is pretty negligible.

So at present I have one mute button working in full duplex. A very promising start. Next step is to get mute, solo, channel gain and pan up and running - these should be simple enough since there's a call for gain and pan I've already confirmed works, and then I need to check that the console and its scribble strips can be gotten working. That should also be straightforward enough since the console needs no changes; it's a completely out of process UI written in VB6 and the control surface task sends a COM method call to it with the required data in a safearray, and then the console immediately returns and posts itself a callback so as not to block the surface thread. This will all work in exactly the same way with Reaper. So, looking promising.

Where I request strings for track names etc. I take it that I need to free the string from the heap each time as you mention; this is presumably generally true where Reaper returns me a string, I'm guessing.

I'm still not entirely clear how to access the master channel's properties, though. My test project has just one track plus the master and the reported track count I get back is 1. I assume that track indexes start from 1 (in Sonar they start from 0) because this is setting the mute for the first track in my project.

Still, I'll press on with the other work and see where I next get stuck. Once again many thanks indeed.

Those 10 callback in the beginning seems to be standard reaper behaviour, dont get too bogged down about this. Once your project is loaded it settles down.

I urge you to start using the callback functions SetSurfaceXXX, it will scale a lot better than polling. Also once you start using more evolved features like automation (touch mode, flying faders) you might hit a brick wall with polling.

Typically the code would do the following:

receive midi from surface, figure out what to do and execute

CSurf_SetSurfaceXXX(tr,CSurf_OnXXXChange(tr,value, relative),NULL);

with XXX = Pan, Volume, Mute, Solo, etc.

(this wrapping of functions is needed, the CSurf_OnXXXChange sets the actual value in Reaper, and the CSurf_SetSurface will notify the callback code).

then under the virtual functions SetSurfaceXXX you add your code that sends midi stuff back to the surface.

And also note that most functions call the master track track 0, but some older ones call it track 1. Check the header files to make sure.

And is there as reason why you're not using the existing bcf2000 as a starting point ?


Last edited by yhertogh; 12-02-2009 at 02:51 AM.
yhertogh is offline   Reply With Quote