Can choose by Channel or by Track in Set commands.

This commit is contained in:
James Crook 2018-02-16 20:34:30 +00:00 committed by Paul Licameli
parent 8ab9345268
commit e9e9ee2998
30 changed files with 258 additions and 194 deletions

View File

@ -38,9 +38,11 @@ def spectro_image1and2() :
capture( 'Spectral001.png', 'First_Track' )
# As spectrogram.
do( 'SetTrack: Track=0 Display=Spectrogram')
do( 'SetTrack: Track=1 Display=Spectrogram')
do( 'Select: Start=55 End=70 First=0 Last=1')
capture( 'Spectral002.png', 'First_Track' )
# Half spectrogram, half wave.
do( 'SetTrack: Channel=1 Display=Waveform')
capture( 'MixedMode.png', 'First_Track' )
def spectro_image3and4():
makeStepper();

View File

@ -23,8 +23,8 @@ def track_image2and6() :
# A stereo track, with its name on the track
capture( 'AutoTracks002.png', 'First_Track' )
# A stereo track, with different sized channels
do( 'SetTrack: Track=0 Height=80')
do( 'SetTrack: Track=1 Height=180')
do( 'SetTrack: Channel=0 Height=80')
do( 'SetTrack: Channel=1 Height=180')
capture( 'AutoTracks006.png', 'First_Track' )
# Four colours of track
@ -43,15 +43,14 @@ def track_image7and4and5():
do( 'SetTrack: Track=1 Height=80')
capture( 'AutoTracks007.png', 'First_Two_Tracks' )
# Two Tracks, ready to make stereo
do( 'SetTrack: Track=0 Name="Left Track" Height=80')
do( 'SetTrack: Track=1 Name="Right Track" Height=80')
do( 'SetTrack: Channel=0 Name="Left Track" Height=80')
do( 'SetTrack: Channel=1 Name="Right Track" Height=80')
capture( 'AutoTracks004.png', 'First_Two_Tracks' )
# Combined Stereo Track
do( 'SetTrack: Track=0 Pan=-1 Height=80')
do( 'SetTrack: Track=1 Pan=1 Height=80')
do( 'MixAndRender' )
do( 'SetTrack: Track=0 Name="Combined" Height=80')
do( 'SetTrack: Track=1 Height=80')
do( 'Select: First=0 Last=1' )
capture( 'AutoTracks005.png', 'First_Track' )

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxWidgets
James Crook
@ -228,8 +228,13 @@ bool GetInfoCommand::SendTracks(const CommandContext & context)
context.StartArray();
while (trk)
{
TrackPanel *panel = context.GetProject()->GetTrackPanel();
Track * fTrack = panel->GetFocusedTrack();
context.StartStruct();
context.AddItem( trk->GetName(), "name" );
context.AddBool( (trk == fTrack), "focused");
auto t = dynamic_cast<WaveTrack*>( trk );
if( t )
{
@ -242,11 +247,12 @@ bool GetInfoCommand::SendTracks(const CommandContext & context)
context.AddBool( t->GetSolo(), "solo" );
context.AddBool( t->GetMute(), "mute");
}
TrackPanel *panel = context.GetProject()->GetTrackPanel();
Track * fTrack = panel->GetFocusedTrack();
context.AddBool( (trk == fTrack), "focused");
context.EndStruct();
trk=iter.Next();
// Skip second tracks of stereo...
if( trk->GetLinked() )
trk= iter.Next();
if( trk )
trk=iter.Next();
}
context.EndArray();
return true;
@ -272,7 +278,11 @@ bool GetInfoCommand::SendClips(const CommandContext &context)
context.EndStruct();
}
}
t = iter.Next();
// Skip second tracks of stereo...
if( t->GetLinked() )
t= iter.Next();
if( t )
t=iter.Next();
i++;
}
context.EndArray();
@ -315,8 +325,11 @@ bool GetInfoCommand::SendEnvelopes(const CommandContext &context)
j++;
}
}
t = iter.Next();
i++;
// Skip second tracks of stereo...
if( t->GetLinked() )
t= iter.Next();
if( t )
t=iter.Next();
}
context.EndArray();
@ -362,7 +375,13 @@ bool GetInfoCommand::SendLabels(const CommandContext &context)
#endif
}
}
t = iter.Next();
// Theoretically you could have a stereo LabelTrack, and
// this way you'd skip the second version of it.
// Skip second tracks of stereo...
//if( t->GetLinked() )
// t= iter.Next();
if( t )
t=iter.Next();
i++;
}
context.EndArray();

View File

@ -1,10 +1,10 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxWidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,10 +1,11 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,10 +1,11 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -5,6 +5,7 @@
File License: wxWidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,11 +1,12 @@
/**********************************************************************
Audacity: A Digital Audio Editor
Audacity(R) is copyright (c) 1999-2009 Audacity Team.
Audacity(R) is copyright (c) 1999-2018 Audacity Team.
File License: wxwidgets
ImportExportCommands.h
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan

View File

@ -1,10 +1,11 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
File License: wxWidgets
Stephen Parry
James Crook
******************************************************************//**

View File

@ -1,11 +1,12 @@
/**********************************************************************
Audacity: A Digital Audio Editor
Audacity(R) is copyright (c) 1999-2009 Audacity Team.
Audacity(R) is copyright (c) 1999-2018 Audacity Team.
File License: wxwidgets
OpenSaveCommands.h
Stephen Parry
James Crook
******************************************************************//**

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
File License: wxWidgets
Dan Horgan

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity: A Digital Audio Editor
Audacity(R) is copyright (c) 1999-2009 Audacity Team.
Audacity(R) is copyright (c) 1999-2018 Audacity Team.
File License: wxwidgets
PreferenceCommands.h
@ -18,8 +18,8 @@
*//*******************************************************************/
#ifndef __PREFERENCECOMMANDS__
#define __PREFERENCECOMMANDS__
#ifndef __PREFERENCE_COMMANDS__
#define __PREFERENCE_COMMANDS__
#include "Command.h"
#include "CommandType.h"
@ -65,4 +65,4 @@ public:
bool mbReload;
};
#endif /* End of include guard: __PREFERENCECOMMANDS__ */
#endif /* End of include guard: __PREFERENCE_COMMANDS__ */

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt
Dominic Mazzoni

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt
Dominic Mazzoni
@ -10,8 +10,8 @@
**********************************************************************/
#ifndef __SCREENSHOTCOMMAND__
#define __SCREENSHOTCOMMAND__
#ifndef __SCREENSHOT_COMMAND__
#define __SCREENSHOT_COMMAND__
#include "Command.h"
#include "../commands/AudacityCommand.h"
@ -98,4 +98,4 @@ public:
wxTopLevelWindow *GetFrontWindow(AudacityProject *project);
};
#endif /* End of include guard: __SCREENSHOTCOMMAND__ */
#endif /* End of include guard: __SCREENSHOT_COMMAND__ */

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
File License: wxWidgets
Dan Horgan

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
File License: wxWidgets
Dan Horgan
@ -13,8 +13,8 @@
*//*******************************************************************/
#ifndef __SCRIPTCOMMANDRELAY__
#define __SCRIPTCOMMANDRELAY__
#ifndef __SCRIPT_COMMAND_RELAY__
#define __SCRIPT_COMMAND_RELAY__
#include "../Audacity.h"
#include "../MemoryX.h"
@ -55,4 +55,4 @@ class ScriptCommandRelay
static std::shared_ptr<ResponseQueueTarget> GetResponseTarget();
};
#endif /* End of include guard: __SCRIPTCOMMANDRELAY__ */
#endif /* End of include guard: __SCRIPT_COMMAND_RELAY__ */

View File

@ -153,19 +153,17 @@ bool SelectTracksCommand::Apply(const CommandContext &context)
bool sel = mFirstTrack <= index && index <= last;
if( mMode == 0 ){ // Set
t->SetSelected(sel);
// if (sel)
// context.Status(wxT("Selected track '") + t->GetName() + wxT("'"));
}
else if( mMode == 1 && sel ){ // Add
t->SetSelected(sel);
// context.Status(wxT("Added track '") + t->GetName() + wxT("'"));
}
else if( mMode == 2 && sel ){ // Remove
t->SetSelected(!sel);
// context.Status(wxT("Removed track '") + t->GetName() + wxT("'"));
}
// Do second channel in stereo track too.
if( !t->GetLinked() )
++index;
t = iter.Next();
++index;
}
return true;
}

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt
Dan Horgan
@ -14,8 +14,8 @@
*//*******************************************************************/
#ifndef __SELECTCOMMAND__
#define __SELECTCOMMAND__
#ifndef __SELECT_COMMAND__
#define __SELECT_COMMAND__
@ -126,4 +126,4 @@ private:
};
#endif /* End of include guard: __SELECTCOMMAND__ */
#endif /* End of include guard: __SELECT_COMMAND__ */

View File

@ -1,10 +1,9 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**
@ -50,11 +49,13 @@ static const wxString kColourStrings[nColours] =
bool SetClipCommand::DefineParams( ShuttleParams & S ){
wxArrayString colours( nColours, kColourStrings );
S.Define( mClipIndex, wxT("Clip"), 0, 0, 100 );
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
S.Optional( bHasContainsTime ).Define( mContainsTime, wxT("At"), 0.0, 0.0, 100000.0 );
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
// Allowing a negative start time is not a mistake.
// It will be used in demonstrating time before zero.
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -5.0, 1000000.0);
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -5.0, 1000000.0);
return true;
};
@ -64,15 +65,13 @@ void SetClipCommand::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieNumericTextBox( _("Clip Index"), mClipIndex );
}
S.EndMultiColumn();
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours );
S.Optional( bHasT0 ).TieNumericTextBox( _("Start:"), mT0 );
S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.Optional( bHasChannelIndex).TieNumericTextBox( _("Channel Index:"), mChannelIndex );
S.Optional( bHasContainsTime).TieNumericTextBox( _("At:"), mContainsTime );
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours );
S.Optional( bHasT0 ).TieNumericTextBox( _("Start:"), mT0 );
}
S.EndMultiColumn();
}
@ -84,32 +83,46 @@ bool SetClipCommand::Apply(const CommandContext & context)
Track *t = iter.First();
WaveClip * pClip = NULL;
int i=0;
int j=0;
while (t && i <= mClipIndex) {
if (t->GetKind() == Track::Wave) {
bool bIsSecondChannel = false;
while (t )
{
bool bThisTrack =
(bHasTrackIndex && (i==mTrackIndex)) ||
(bHasChannelIndex && (j==mChannelIndex ) ) ||
(!bHasTrackIndex && !bHasChannelIndex) ;
if( bThisTrack && (t->GetKind() == Track::Wave)) {
bool bFound = false;
WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
WaveClipPointers ptrs( waveTrack->SortedClipArray());
for(auto it = ptrs.begin(); (it != ptrs.end()) && (i<=mClipIndex); it++,i++ ){
for(auto it = ptrs.begin(); (it != ptrs.end()); it++ ){
pClip = *it;
bFound =
!bHasContainsTime || (
( pClip->GetStartTime() <= mContainsTime ) &&
( pClip->GetEndTime() >= mContainsTime )
);
if( bFound )
{
// Inside this IF is where we actually apply the command
if( bHasColour )
pClip->SetColourIndex(mColour);
// No validation of overlap yet. We assume the user is sensible!
if( bHasT0 )
pClip->SetOffset(mT0);
// \todo Use SetClip to move a clip between tracks too.
}
}
}
bIsSecondChannel = t->GetLinked();
if( !bIsSecondChannel )
++i;
j++;
t = iter.Next();
}
if (i <= mClipIndex || !pClip)
{
context.Error(wxT("ClipIndex was invalid."));
return false;
}
if( bHasColour )
pClip->SetColourIndex(mColour);
// No validation of overlap yet. We assume the user is sensible!
if( bHasT0 )
pClip->SetOffset(mT0);
// \todo Use SetClip to move a clip between tracks too.
return true;
}

View File

@ -1,10 +1,9 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**
@ -38,11 +37,16 @@ public:
bool Apply(const CommandContext & context) override;
public:
int mClipIndex;
int mTrackIndex;
int mChannelIndex;
double mContainsTime;
int mColour;
double mT0;
// For tracking optional parameters.
bool bHasTrackIndex;
bool bHasChannelIndex;
bool bHasContainsTime;
bool bHasColour;
bool bHasT0;
};

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
James Crook
@ -32,10 +32,12 @@ SetEnvelopeCommand::SetEnvelopeCommand()
bool SetEnvelopeCommand::DefineParams( ShuttleParams & S ){
S.Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Define( mT, wxT("Time"), 0.0, 0.0, 100000.0);
S.Define( mV, wxT("Value"), 0.0, 0.0, 2.0);
S.Define( mbDelete, wxT("Delete"), false );
S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
S.Optional( bHasContainsTime ).Define( mContainsTime, wxT("At"), 0.0, 0.0, 100000.0 );
S.Optional( bHasT ).Define( mT, wxT("Time"), 0.0, 0.0, 100000.0);
S.Optional( bHasV ).Define( mV, wxT("Value"), 0.0, 0.0, 2.0);
S.Optional( bHasDelete ).Define( mbDelete, wxT("Delete"), false );
return true;
};
@ -43,12 +45,14 @@ void SetEnvelopeCommand::PopulateOrExchange(ShuttleGui & S)
{
S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.TieNumericTextBox( _("Time:"), mT );
S.TieNumericTextBox( _("Value:"), mV );
S.TieCheckBox( _("Delete:"), mbDelete );
S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.Optional( bHasChannelIndex).TieNumericTextBox( _("Channel Index:"), mChannelIndex );
S.Optional( bHasContainsTime).TieNumericTextBox( _("At:"), mContainsTime );
S.Optional( bHasT ).TieNumericTextBox( _("Time:"), mT );
S.Optional( bHasV ).TieNumericTextBox( _("Value:"), mV );
S.Optional( bHasDelete ).TieCheckBox( _("Delete:"), mbDelete );
}
S.EndMultiColumn();
}
@ -63,42 +67,45 @@ bool SetEnvelopeCommand::Apply(const CommandContext & context)
Track *t = iter.First();
WaveClip * pClip = NULL;
int i=0;
int j=0;
bool bFound = false;
bool bIsSecondChannel = false;
while (t && !bFound) {
if (t->GetKind() == Track::Wave) {
while (t )
{
bool bThisTrack =
(bHasTrackIndex && (i==mTrackIndex)) ||
(bHasChannelIndex && (j==mChannelIndex ) ) ||
(!bHasTrackIndex && !bHasChannelIndex) ;
if( bThisTrack && (t->GetKind() == Track::Wave)) {
bool bFound = false;
WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
WaveClipPointers ptrs( waveTrack->SortedClipArray());
for(auto it = ptrs.begin(); (it != ptrs.end()) && !bFound; it++,i++ ){
for(auto it = ptrs.begin(); (it != ptrs.end()); it++ ){
pClip = *it;
bFound =
( pClip->GetStartTime() <= mT ) &&
( pClip->GetEndTime() >= mT );
!bHasContainsTime || (
( pClip->GetStartTime() <= mContainsTime ) &&
( pClip->GetEndTime() >= mContainsTime )
);
if( bFound )
{
// Inside this IF is where we actually apply the command
Envelope* pEnv = pClip->GetEnvelope();
if( mbDelete )
pEnv->mEnv.clear();
else
pEnv->InsertOrReplace( mT, mV );
}
}
}
bIsSecondChannel = t->GetLinked();
if( !bIsSecondChannel )
++i;
j++;
t = iter.Next();
}
if( !bFound )
return false;
Envelope* pEnv = pClip->GetEnvelope();
if( mbDelete ){
pEnv->mEnv.clear();
return true;
}
pEnv->InsertOrReplace( mT, mV );
/*
double tFind = mT - 0.000001 - pEnv->mOffset; // 100,000th of a second before.
bFound = false;
for( i=0;i<pEnv->mEnv.size() && !bFound;i++ ){
bFound = tFind > pEnv->mEnv[i].GetT();
}
i -= bFound ? 1 :0;
pEnv->Insert( i, EnvPoint( mT, mV ) );
*/
return true;
}

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
James Crook
@ -38,9 +38,18 @@ public:
public:
int mTrackIndex;
int mChannelIndex;
double mContainsTime;
double mT;
double mV;
bool mbDelete;
bool bHasTrackIndex;
bool bHasChannelIndex;
bool bHasContainsTime;
bool bHasT;
bool bHasV;
bool bHasDelete;
};

View File

@ -1,10 +1,9 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,10 +1,9 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
James Crook
******************************************************************//**

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
@ -82,7 +82,8 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
wxArrayString displays( nDisplayTypes, kDisplayTypeStrings );
wxArrayString scales( nScaleTypes, kScaleTypeStrings );
S.Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
S.Optional( bHasTrackName ).Define( mTrackName, wxT("Name"), wxT("Unnamed") );
S.Optional( bHasPan ).Define( mPan, wxT("Pan"), 0.0, -1.0, 1.0);
S.Optional( bHasGain ).Define( mGain, wxT("Gain"), 1.0, 0.0, 10.0);
@ -92,6 +93,7 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
S.Optional( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
S.Optional( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false );
// There is also a select command. This is an alternative.
S.Optional( bHasSelected ).Define( bSelected, wxT("Selected"), false );
S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false );
S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false );
@ -107,20 +109,17 @@ void SetTrackCommand::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieNumericTextBox( _("Track Index"), mTrackIndex );
}
S.EndMultiColumn();
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.Optional( bHasTrackName ).TieTextBox( _("Name:"), mTrackName );
S.Optional( bHasPan ).TieSlider( _("Pan:"), mPan, 1.0, -1.0);
S.Optional( bHasGain ).TieSlider( _("Gain:"), mGain, 10.0, 0.0);
S.Optional( bHasHeight ).TieNumericTextBox( _("Height:"), mHeight );
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours );
S.Optional( bHasDisplayType ).TieChoice( _("Display:"), mDisplayType, &displays );
S.Optional( bHasScaleType ).TieChoice( _("Scale:"), mScaleType, &scales );
S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.Optional( bHasChannelIndex).TieNumericTextBox( _("Channel Index:"), mChannelIndex );
S.Optional( bHasTrackName ).TieTextBox( _("Name:"), mTrackName );
S.Optional( bHasPan ).TieSlider( _("Pan:"), mPan, 1.0, -1.0);
S.Optional( bHasGain ).TieSlider( _("Gain:"), mGain, 10.0, 0.0);
S.Optional( bHasHeight ).TieNumericTextBox( _("Height:"), mHeight );
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours );
S.Optional( bHasDisplayType ).TieChoice( _("Display:"), mDisplayType, &displays );
S.Optional( bHasScaleType ).TieChoice( _("Scale:"), mScaleType, &scales );
}
S.EndMultiColumn();
S.StartMultiColumn(2, wxALIGN_CENTER);
@ -137,66 +136,73 @@ void SetTrackCommand::PopulateOrExchange(ShuttleGui & S)
bool SetTrackCommand::Apply(const CommandContext & context)
{
//wxString mode = GetString(wxT("Type"));
// (Note: track selection ought to be somewhere else)
long i = 0;
long i = 0;// track counter
long j = 0;// channel counter
TrackListIterator iter(context.GetProject()->GetTracks());
Track *t = iter.First();
while (t && i != mTrackIndex)
bool bIsSecondChannel = false;
while (t )
{
bool bThisTrack =
(bHasTrackIndex && (i==mTrackIndex)) ||
(bHasChannelIndex && (j==mChannelIndex ) ) ||
(!bHasTrackIndex && !bHasChannelIndex) ;
if( bThisTrack ){
auto wt = dynamic_cast<WaveTrack *>(t);
auto pt = dynamic_cast<PlayableTrack *>(t);
// You can get some intriguing effects by setting R and L channels to
// different values.
if( bHasTrackName )
t->SetName(mTrackName);
if( wt && bHasPan )
wt->SetPan(mPan);
if( wt && bHasGain )
wt->SetGain(mGain);
if( wt && bHasColour )
wt->SetWaveColorIndex( mColour );
if( t && bHasHeight )
t->SetHeight( mHeight );
if( wt && bHasDisplayType )
wt->SetDisplay(
(mDisplayType == kWaveform) ?
WaveTrack::WaveTrackDisplay::Waveform
: WaveTrack::WaveTrackDisplay::Spectrum
);
if( wt && bHasScaleType )
wt->GetIndependentWaveformSettings().scaleType =
(mScaleType==kLinear) ?
WaveformSettings::stLinear
: WaveformSettings::stLogarithmic;
if( wt && bHasSpectralSelect )
wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect;
if( wt && bHasGrayScale )
wt->GetSpectrogramSettings().isGrayscale = bGrayScale;
// These ones don't make sense on the second channel of a stereo track.
if( !bIsSecondChannel ){
if( bHasSelected )
t->SetSelected(bSelected);
if( bHasFocused )
{
TrackPanel *panel = context.GetProject()->GetTrackPanel();
panel->SetFocusedTrack( t );
}
if( pt && bHasSolo )
pt->SetSolo(bSolo);
if( pt && bHasMute )
pt->SetMute(bMute);
}
}
bIsSecondChannel = t->GetLinked();
if( !bIsSecondChannel )
++i;
j++;
t = iter.Next();
++i;
}
if (i != mTrackIndex || !t)
{
context.Error(wxT("TrackIndex was invalid."));
return false;
}
auto wt = dynamic_cast<WaveTrack *>(t);
auto pt = dynamic_cast<PlayableTrack *>(t);
if( bHasTrackName )
t->SetName(mTrackName);
if( wt && bHasPan )
wt->SetPan(mPan);
if( wt && bHasGain )
wt->SetGain(mGain);
if( wt && bHasColour )
wt->SetWaveColorIndex( mColour );
if( t && bHasHeight )
t->SetHeight( mHeight );
if( wt && bHasDisplayType )
wt->SetDisplay(
(mDisplayType == kWaveform) ?
WaveTrack::WaveTrackDisplay::Waveform
: WaveTrack::WaveTrackDisplay::Spectrum
);
if( wt && bHasScaleType )
wt->GetIndependentWaveformSettings().scaleType =
(mScaleType==kLinear) ?
WaveformSettings::stLinear
: WaveformSettings::stLogarithmic;
if( wt && bHasSpectralSelect )
wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect;
if( wt && bHasGrayScale )
wt->GetSpectrogramSettings().isGrayscale = bGrayScale;
if( bHasSelected )
t->SetSelected(bSelected);
if( bHasFocused )
{
TrackPanel *panel = context.GetProject()->GetTrackPanel();
panel->SetFocusedTrack( t );
}
if( pt && bHasSolo )
pt->SetSolo(bSolo);
if( pt && bHasMute )
pt->SetMute(bMute);
return true;
}

View File

@ -1,7 +1,7 @@
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
@ -39,6 +39,7 @@ public:
public:
int mTrackIndex;
int mChannelIndex;
wxString mTrackName;
double mPan;
double mGain;
@ -54,6 +55,8 @@ public:
bool bMute;
// For tracking optional parameters.
bool bHasTrackIndex;
bool bHasChannelIndex;
bool bHasTrackName;
bool bHasPan;
bool bHasGain;