Old 04-04-2008, 09:41 AM   #1
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default CSurf_OnVolumeChange issue

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...18&postcount=8

Last edited by sws; 04-04-2008 at 09:45 AM.
sws is offline   Reply With Quote
Old 04-04-2008, 11:08 AM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

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:


Code:
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:

Code:
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
Justin is offline   Reply With Quote
Old 04-04-2008, 11:22 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

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).
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 04-04-2008, 12:25 PM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

OK the next SDK (and build of 2.149pre) will have documented CSurf_OnVolumeChangeEx() and CSurf_OnPanChangeEx() which lets you disable ganging...

-Justin
Justin is offline   Reply With Quote
Old 04-04-2008, 12:27 PM   #5
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default

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:

Code:
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).
sws is offline   Reply With Quote
Old 04-04-2008, 12:45 PM   #6
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by sws View Post

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
Justin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.