PDA

View Full Version : CSurf_OnVolumeChange issue


sws
04-04-2008, 09:41 AM
If you call CSurf_OnVolumeChange on a track that is *not* selected, everything is fine, just that track's volume is changed. If you call CSurf_OnVolumeChange on a track that is selected, all selected tracks change volume. This behavior is in contrast to the rest of the CSurf_OnXXX functions. Bug? Shouldn't all these funcs work only on the track passed in?

Edit: same goes for CSurf_OnPanChange

Credit goes to Anomaly for finding this:
http://www.cockos.com/forum/showpost.php?p=171818&postcount=8

Justin
04-04-2008, 11:08 AM
This is because CSurf_OnVolumeChange etc simulates the user fiddling with the fader directly, as a result multiple selected tracks are "ganged" together. I'll look at adding an extended API where you can disable this behavior.

In the mean time there's a tricky workaround -- ganging only happens if the SHIFT key is NOT down. And if you have a IReaperControlSurface registered and active, you can do something like:



int g_fake_shift; // some global var

g_fake_shift=1;
CSurf_OnVolumeChange()
g_fake_shift=0;


then have your IReaperControlSurface::IsKeyDown() have something like:


if (key == VK_SHIFT && g_fake_shift) return true;




This is sorta silly, though, so probably best to wait til I add an extended vol changing API...


-Justin

Xenakios
04-04-2008, 11:22 AM
Dirty solution I found myself : store all tracks' selected status temporarily, then unselect all tracks, then do the needed volume/pan stuff and finally restore original tracks' selected status from the temporary array (or whatever).

Justin
04-04-2008, 12:25 PM
OK the next SDK (and build of 2.149pre) will have documented CSurf_OnVolumeChangeEx() and CSurf_OnPanChangeEx() which lets you disable ganging...

-Justin

sws
04-04-2008, 12:27 PM
Xen, yeah, you can do it individually as well (as long as the track your changing isn't selected you're OK). Here's the code I use in case someone else wants it:


void SetTrackVolume(int track, double vol)
{
int flags;
GetTrackInfo(track, &flags);
CSurf_OnSelectedChange(CSurf_TrackFromID(track+1, false), 0);
CSurf_OnVolumeChange(CSurf_TrackFromID(track+1, false), vol, false);
CSurf_OnSelectedChange(CSurf_TrackFromID(track+1, false), flags & 2 ? 1 : 0);
}


Also, there's an issue that OnVolume doesn't set the volume exactly. It depends on the fader curve, and very small changes it seems are ignored. With the default curves, setting track to DB2VAL(1.0) sets track vol to 0.97db. Works fine below 0.0 though. Relative changes of a small amount are ignored.
I think maybe we just need SetTrackUIVolPan(MediaTrack *tr, double vol, double pan).

Justin
04-04-2008, 12:45 PM
Also, there's an issue that OnVolume doesn't set the volume exactly. It depends on the fader curve, and very small changes it seems are ignored. With the default curves, setting track to DB2VAL(1.0) sets track vol to 0.97db. Works fine below 0.0 though. Relative changes of a small amount are ignored.
I think maybe we just need SetTrackUIVolPan(MediaTrack *tr, double vol, double pan).


Yeah actually I'm going to add a GetSetTrackInfo() API that will function a lot like the media/send APIs, allowing you to have EXACT control over vol/pan/mute/solo/record parameters/etc etc. Probably later today ;)

-Justin