turn Pan & Gain sliders off

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10 / 11

turn Pan & Gain sliders off

Post by Edgar » Wed Oct 12, 2011 9:35 pm

In another thread we touched on disabling the Pan and Gain sliders in a Wavetrack:
waxcylinder wrote:Oh, and while we're suggesting enhancements to the TCP I'd like to add the ability to turn the sliders "on" and "off"[...] - default setting to be "off".
Peter 22Nov11: I tansfrerred the FR referenced above to the Wiki Pending Feature Requests - retaining a link there to this page.
Edgar wrote: I did this at least a year ago on my personal version of Audacity
So, I pulled just this code out and applied it to today's SVN HEAD (r11277) and hereafter follows the result...
First, we add two checkboxes to Preferences, add this code after line 92 of GUIPrefs.cpp:

Code: Select all

      S.TieCheckBox(_("Disable Gain Slider by default"),
                    wxT("/GUI/DisableGainSlider"),
                    false);
      S.TieCheckBox(_("Disable Pan Slider by default"),
                    wxT("/GUI/DisablePanSlider"),
                    false);
The result is:
newPrefs.png
newPrefs.png (18.44 KiB) Viewed 2097 times
and the audacity.cfg file has two new lines:
[GUI]
ShowSplashScreen=0
[...]

DisableGainSlider=1
DisablePanSlider=0

[GUI/ToolBars]

If these lines do not exist in the config file the sliders will default to ON contrary to waxcylinder's desire (that which would result in a regression IMHO).

The rest of the code is in TrackPanel.cpp & TrackPanel.h, in TrackPanel.h after line 426 we add two function definitions:

Code: Select all

   void OnToggleGain(wxCommandEvent &event);
   void OnTogglePan(wxCommandEvent &event);
in TrackPanel.cpp we have a few additions and changes; first after line 315 we add:

Code: Select all

   OnToggleGainID,
   OnTogglePanID,
and after what is now line 342 we add:

Code: Select all

    EVT_MENU(OnToggleGainID, TrackPanel::OnToggleGain)
    EVT_MENU(OnTogglePanID, TrackPanel::OnTogglePan)
then after what is now line 646 we add:

Code: Select all

   mWaveTrackMenu->Append(OnToggleGainID, _("Toggle Gain Slider State"));
   mWaveTrackMenu->Append(OnTogglePanID, _("Toggle Pan Slider State"));
Now at what is now line 8196 we completely change these two functions:

Code: Select all

LWSlider * TrackInfo::GainSlider(int trackIndex)
{
   LWSlider * returnSlider = mGains[trackIndex - mSliderOffset];
   bool disable;
   gPrefs->Read(wxT("/GUI/DisableGainSlider"), &disable, false);
   returnSlider->SetEnabled(!disable);
   return returnSlider;
}

LWSlider * TrackInfo::PanSlider(int trackIndex)
{
   LWSlider * returnSlider = mPans[trackIndex - mSliderOffset];
   bool disable;
   gPrefs->Read(wxT("/GUI/DisablePanSlider"), &disable, false);
   returnSlider->SetEnabled(!disable);
   return returnSlider;
}
and add two additional (currently broken) functions:

Code: Select all

//the following two functions should toggle the active state of the Pan/Gain sliders in responce to 
//the menu items but they do not work as-is
void TrackPanel::OnToggleGain(wxCommandEvent &event)
{
   wxMessageBox(wxT("debug OnToggleGain()"));
   Track * t = GetFocusedTrack();
   if (!t || (t->GetKind() != Track::Wave)) {
      return;
   }
   LWSlider * slider = mTrackInfo.GainSlider(t->GetIndex());
   if (slider->GetEnabled()) slider->SetEnabled(false);
   else slider->SetEnabled(true);
   slider->Refresh();
}

void TrackPanel::OnTogglePan(wxCommandEvent &event)
{
   wxMessageBox(wxT("debug OnTogglePan()"));
   Track * t = GetFocusedTrack();
   if (!t || (t->GetKind() != Track::Wave)) {
      return;
   }
   LWSlider * slider = mTrackInfo.PanSlider(t->GetIndex());
   if (slider->GetEnabled()) slider->SetEnabled(false);
   else slider->SetEnabled(true);
   slider->Refresh();
}
These two last functions are giving me grief! I cannot figure out how to refresh the state of these sliders. The wxMessageBox in each proves we are entering the function. Right now I must change the global state in prefs then do do a copy&paste into a new track. It works but is clunky. Personally, I almost always leave the sliders OFF so the problem does not impact my usage.

Here is the result of turning one slider off in prefs:
combo.png
combo.png (50.91 KiB) Viewed 2097 times
After looking at these graphics I see I should reverse the order of the checkboxes to reflect the order of the sliders in the panel. I did so in the above example code but did not bother to change the picture. Now everything is "gain on top, pan on bottom".
Last edited by Edgar on Fri Apr 24, 2015 3:48 pm, edited 2 times in total.
Reason: noted that I have moved the original FR that initiated this thread

kozikowski
Posts: 71538
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: turn Pan & Gain sliders off

Post by kozikowski » Thu Oct 13, 2011 11:30 pm

Tickle the pan control on a mono show so you now have a Virtual Stereo Show. Now go in and turn panning off, does the show snap back to mono?

If you do have Panning off and start a new show, then that Virtual Stereo business goes away, right?

Koz

waxcylinder
Posts: 15366
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10 / 11

Re: turn Pan & Gain sliders off

Post by waxcylinder » Tue Nov 22, 2011 2:34 pm

I transferred the original FR to the Wiki - but retained this thread here for reference.

WC

steve
Site Admin
Posts: 85703
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: turn Pan & Gain sliders off

Post by steve » Tue Nov 22, 2011 5:23 pm

kozikowski wrote:Tickle the pan control on a mono show so you now have a Virtual Stereo Show. Now go in and turn panning off, does the show snap back to mono?
I think that is an important consideration. It should not be possible to have an off-centre mono track with no pan slider.
Learn more about Nyquist programming at audionyq.com

Post Reply