|
|
|
04-04-2008, 09:41 AM
|
#1
|
Code Monkey
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
|
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.
|
|
|
04-04-2008, 11:08 AM
|
#2
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
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
|
|
|
04-04-2008, 11:22 AM
|
#3
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
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.
|
|
|
04-04-2008, 12:25 PM
|
#4
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
OK the next SDK (and build of 2.149pre) will have documented CSurf_OnVolumeChangeEx() and CSurf_OnPanChangeEx() which lets you disable ganging...
-Justin
|
|
|
04-04-2008, 12:27 PM
|
#5
|
Code Monkey
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
|
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).
|
|
|
04-04-2008, 12:45 PM
|
#6
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by sws
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
|
|
|
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 01:29 AM.
|