1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-16 16:20:50 +02:00

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' ) capture( 'Spectral001.png', 'First_Track' )
# As spectrogram. # As spectrogram.
do( 'SetTrack: Track=0 Display=Spectrogram') do( 'SetTrack: Track=0 Display=Spectrogram')
do( 'SetTrack: Track=1 Display=Spectrogram')
do( 'Select: Start=55 End=70 First=0 Last=1') do( 'Select: Start=55 End=70 First=0 Last=1')
capture( 'Spectral002.png', 'First_Track' ) capture( 'Spectral002.png', 'First_Track' )
# Half spectrogram, half wave.
do( 'SetTrack: Channel=1 Display=Waveform')
capture( 'MixedMode.png', 'First_Track' )
def spectro_image3and4(): def spectro_image3and4():
makeStepper(); makeStepper();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,12 @@
/********************************************************************** /**********************************************************************
Audacity: A Digital Audio Editor 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 File License: wxwidgets
ImportExportCommands.h ImportExportCommands.h
Dan Horgan Dan Horgan
James Crook
******************************************************************//** ******************************************************************//**

View File

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

View File

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

View File

@ -1,11 +1,12 @@
/********************************************************************** /**********************************************************************
Audacity: A Digital Audio Editor 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 File License: wxwidgets
OpenSaveCommands.h OpenSaveCommands.h
Stephen Parry Stephen Parry
James Crook
******************************************************************//** ******************************************************************//**

View File

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

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity: A Digital Audio Editor 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 File License: wxwidgets
PreferenceCommands.h PreferenceCommands.h
@ -18,8 +18,8 @@
*//*******************************************************************/ *//*******************************************************************/
#ifndef __PREFERENCECOMMANDS__ #ifndef __PREFERENCE_COMMANDS__
#define __PREFERENCECOMMANDS__ #define __PREFERENCE_COMMANDS__
#include "Command.h" #include "Command.h"
#include "CommandType.h" #include "CommandType.h"
@ -65,4 +65,4 @@ public:
bool mbReload; 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 Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt License: GPL v2 - see LICENSE.txt
Dominic Mazzoni Dominic Mazzoni

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt License: GPL v2 - see LICENSE.txt
Dominic Mazzoni Dominic Mazzoni
@ -10,8 +10,8 @@
**********************************************************************/ **********************************************************************/
#ifndef __SCREENSHOTCOMMAND__ #ifndef __SCREENSHOT_COMMAND__
#define __SCREENSHOTCOMMAND__ #define __SCREENSHOT_COMMAND__
#include "Command.h" #include "Command.h"
#include "../commands/AudacityCommand.h" #include "../commands/AudacityCommand.h"
@ -98,4 +98,4 @@ public:
wxTopLevelWindow *GetFrontWindow(AudacityProject *project); 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 Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
File License: wxWidgets File License: wxWidgets
Dan Horgan Dan Horgan

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
File License: wxWidgets File License: wxWidgets
Dan Horgan Dan Horgan
@ -13,8 +13,8 @@
*//*******************************************************************/ *//*******************************************************************/
#ifndef __SCRIPTCOMMANDRELAY__ #ifndef __SCRIPT_COMMAND_RELAY__
#define __SCRIPTCOMMANDRELAY__ #define __SCRIPT_COMMAND_RELAY__
#include "../Audacity.h" #include "../Audacity.h"
#include "../MemoryX.h" #include "../MemoryX.h"
@ -55,4 +55,4 @@ class ScriptCommandRelay
static std::shared_ptr<ResponseQueueTarget> GetResponseTarget(); 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; bool sel = mFirstTrack <= index && index <= last;
if( mMode == 0 ){ // Set if( mMode == 0 ){ // Set
t->SetSelected(sel); t->SetSelected(sel);
// if (sel)
// context.Status(wxT("Selected track '") + t->GetName() + wxT("'"));
} }
else if( mMode == 1 && sel ){ // Add else if( mMode == 1 && sel ){ // Add
t->SetSelected(sel); t->SetSelected(sel);
// context.Status(wxT("Added track '") + t->GetName() + wxT("'"));
} }
else if( mMode == 2 && sel ){ // Remove else if( mMode == 2 && sel ){ // Remove
t->SetSelected(!sel); 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(); t = iter.Next();
++index;
} }
return true; return true;
} }

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: GPL v2 - see LICENSE.txt License: GPL v2 - see LICENSE.txt
Dan Horgan Dan Horgan
@ -14,8 +14,8 @@
*//*******************************************************************/ *//*******************************************************************/
#ifndef __SELECTCOMMAND__ #ifndef __SELECT_COMMAND__
#define __SELECTCOMMAND__ #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 Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: wxwidgets License: wxwidgets
Dan Horgan
James Crook James Crook
******************************************************************//** ******************************************************************//**
@ -50,11 +49,13 @@ static const wxString kColourStrings[nColours] =
bool SetClipCommand::DefineParams( ShuttleParams & S ){ bool SetClipCommand::DefineParams( ShuttleParams & S ){
wxArrayString colours( nColours, kColourStrings ); wxArrayString colours( nColours, kColourStrings );
S.Define( mClipIndex, wxT("Clip"), 0, 0, 100 ); S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours ); 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. // Allowing a negative start time is not a mistake.
// It will be used in demonstrating time before zero. // 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; return true;
}; };
@ -64,15 +65,13 @@ void SetClipCommand::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(0, 5); S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieNumericTextBox( _("Clip Index"), mClipIndex );
}
S.EndMultiColumn();
S.StartMultiColumn(3, wxALIGN_CENTER); S.StartMultiColumn(3, wxALIGN_CENTER);
{ {
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours ); S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.Optional( bHasT0 ).TieNumericTextBox( _("Start:"), mT0 ); 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(); S.EndMultiColumn();
} }
@ -84,32 +83,46 @@ bool SetClipCommand::Apply(const CommandContext & context)
Track *t = iter.First(); Track *t = iter.First();
WaveClip * pClip = NULL; WaveClip * pClip = NULL;
int i=0; int i=0;
int j=0;
while (t && i <= mClipIndex) { bool bIsSecondChannel = false;
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); WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
WaveClipPointers ptrs( waveTrack->SortedClipArray()); 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; 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(); 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; return true;
} }

View File

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

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: wxwidgets License: wxwidgets
James Crook James Crook
@ -32,10 +32,12 @@ SetEnvelopeCommand::SetEnvelopeCommand()
bool SetEnvelopeCommand::DefineParams( ShuttleParams & S ){ bool SetEnvelopeCommand::DefineParams( ShuttleParams & S ){
S.Define( mTrackIndex, wxT("Track"), 0, 0, 100 ); S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Define( mT, wxT("Time"), 0.0, 0.0, 100000.0); S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
S.Define( mV, wxT("Value"), 0.0, 0.0, 2.0); S.Optional( bHasContainsTime ).Define( mContainsTime, wxT("At"), 0.0, 0.0, 100000.0 );
S.Define( mbDelete, wxT("Delete"), false ); 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; return true;
}; };
@ -43,12 +45,14 @@ void SetEnvelopeCommand::PopulateOrExchange(ShuttleGui & S)
{ {
S.AddSpace(0, 5); S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(3, wxALIGN_CENTER);
{ {
S.TieNumericTextBox( _("Track Index:"), mTrackIndex ); S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.TieNumericTextBox( _("Time:"), mT ); S.Optional( bHasChannelIndex).TieNumericTextBox( _("Channel Index:"), mChannelIndex );
S.TieNumericTextBox( _("Value:"), mV ); S.Optional( bHasContainsTime).TieNumericTextBox( _("At:"), mContainsTime );
S.TieCheckBox( _("Delete:"), mbDelete ); S.Optional( bHasT ).TieNumericTextBox( _("Time:"), mT );
S.Optional( bHasV ).TieNumericTextBox( _("Value:"), mV );
S.Optional( bHasDelete ).TieCheckBox( _("Delete:"), mbDelete );
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -63,42 +67,45 @@ bool SetEnvelopeCommand::Apply(const CommandContext & context)
Track *t = iter.First(); Track *t = iter.First();
WaveClip * pClip = NULL; WaveClip * pClip = NULL;
int i=0; int i=0;
int j=0;
bool bFound = false; bool bIsSecondChannel = false;
while (t && !bFound) { while (t )
if (t->GetKind() == Track::Wave) { {
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); WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
WaveClipPointers ptrs( waveTrack->SortedClipArray()); 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; pClip = *it;
bFound = bFound =
( pClip->GetStartTime() <= mT ) && !bHasContainsTime || (
( pClip->GetEndTime() >= mT ); ( 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(); 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; return true;
} }

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: wxwidgets License: wxwidgets
James Crook James Crook
@ -38,9 +38,18 @@ public:
public: public:
int mTrackIndex; int mTrackIndex;
int mChannelIndex;
double mContainsTime;
double mT; double mT;
double mV; double mV;
bool mbDelete; 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 Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: wxwidgets License: wxwidgets
Dan Horgan
James Crook James Crook
******************************************************************//** ******************************************************************//**

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
Audacity - A Digital Audio Editor Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team Copyright 1999-2018 Audacity Team
License: wxwidgets License: wxwidgets
Dan Horgan Dan Horgan
@ -82,7 +82,8 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
wxArrayString displays( nDisplayTypes, kDisplayTypeStrings ); wxArrayString displays( nDisplayTypes, kDisplayTypeStrings );
wxArrayString scales( nScaleTypes, kScaleTypeStrings ); 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( bHasTrackName ).Define( mTrackName, wxT("Name"), wxT("Unnamed") );
S.Optional( bHasPan ).Define( mPan, wxT("Pan"), 0.0, -1.0, 1.0); 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); 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( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
S.Optional( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true ); S.Optional( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
S.Optional( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false ); 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( bHasSelected ).Define( bSelected, wxT("Selected"), false );
S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false ); S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false );
S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false ); S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false );
@ -107,20 +109,17 @@ void SetTrackCommand::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(0, 5); S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieNumericTextBox( _("Track Index"), mTrackIndex );
}
S.EndMultiColumn();
S.StartMultiColumn(3, wxALIGN_CENTER); S.StartMultiColumn(3, wxALIGN_CENTER);
{ {
S.Optional( bHasTrackName ).TieTextBox( _("Name:"), mTrackName ); S.Optional( bHasTrackIndex ).TieNumericTextBox( _("Track Index:"), mTrackIndex );
S.Optional( bHasPan ).TieSlider( _("Pan:"), mPan, 1.0, -1.0); S.Optional( bHasChannelIndex).TieNumericTextBox( _("Channel Index:"), mChannelIndex );
S.Optional( bHasGain ).TieSlider( _("Gain:"), mGain, 10.0, 0.0); S.Optional( bHasTrackName ).TieTextBox( _("Name:"), mTrackName );
S.Optional( bHasHeight ).TieNumericTextBox( _("Height:"), mHeight ); S.Optional( bHasPan ).TieSlider( _("Pan:"), mPan, 1.0, -1.0);
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours ); S.Optional( bHasGain ).TieSlider( _("Gain:"), mGain, 10.0, 0.0);
S.Optional( bHasDisplayType ).TieChoice( _("Display:"), mDisplayType, &displays ); S.Optional( bHasHeight ).TieNumericTextBox( _("Height:"), mHeight );
S.Optional( bHasScaleType ).TieChoice( _("Scale:"), mScaleType, &scales ); S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour, &colours );
S.Optional( bHasDisplayType ).TieChoice( _("Display:"), mDisplayType, &displays );
S.Optional( bHasScaleType ).TieChoice( _("Scale:"), mScaleType, &scales );
} }
S.EndMultiColumn(); S.EndMultiColumn();
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
@ -137,66 +136,73 @@ void SetTrackCommand::PopulateOrExchange(ShuttleGui & S)
bool SetTrackCommand::Apply(const CommandContext & context) bool SetTrackCommand::Apply(const CommandContext & context)
{ {
//wxString mode = GetString(wxT("Type"));
// (Note: track selection ought to be somewhere else) long i = 0;// track counter
long i = 0; long j = 0;// channel counter
TrackListIterator iter(context.GetProject()->GetTracks()); TrackListIterator iter(context.GetProject()->GetTracks());
Track *t = iter.First(); 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(); 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; return true;
} }

View File

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