diff --git a/scripts/piped-work/docimages_spectro.py b/scripts/piped-work/docimages_spectro.py index 814836c41..d24df4e19 100644 --- a/scripts/piped-work/docimages_spectro.py +++ b/scripts/piped-work/docimages_spectro.py @@ -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(); diff --git a/scripts/piped-work/docimages_tracks.py b/scripts/piped-work/docimages_tracks.py index e66b2808e..424841aa6 100644 --- a/scripts/piped-work/docimages_tracks.py +++ b/scripts/piped-work/docimages_tracks.py @@ -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' ) diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index 35e687f6c..bcd1c45e8 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team License: wxwidgets Dan Horgan diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 1dbbce070..db4ebb1c4 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -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( 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(); diff --git a/src/commands/GetInfoCommand.h b/src/commands/GetInfoCommand.h index bfd5a649e..9d973feef 100644 --- a/src/commands/GetInfoCommand.h +++ b/src/commands/GetInfoCommand.h @@ -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 ******************************************************************//** diff --git a/src/commands/HelpCommand.cpp b/src/commands/HelpCommand.cpp index ecbf5a5e7..1d408adc8 100644 --- a/src/commands/HelpCommand.cpp +++ b/src/commands/HelpCommand.cpp @@ -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 ******************************************************************//** diff --git a/src/commands/HelpCommand.h b/src/commands/HelpCommand.h index fbb1561ba..71ffe2a64 100644 --- a/src/commands/HelpCommand.h +++ b/src/commands/HelpCommand.h @@ -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 ******************************************************************//** diff --git a/src/commands/ImportExportCommands.cpp b/src/commands/ImportExportCommands.cpp index f7c68668e..a4ea67010 100644 --- a/src/commands/ImportExportCommands.cpp +++ b/src/commands/ImportExportCommands.cpp @@ -5,6 +5,7 @@ File License: wxWidgets Dan Horgan + James Crook ******************************************************************//** diff --git a/src/commands/ImportExportCommands.h b/src/commands/ImportExportCommands.h index 2dc221d6c..f229053df 100644 --- a/src/commands/ImportExportCommands.h +++ b/src/commands/ImportExportCommands.h @@ -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 ******************************************************************//** diff --git a/src/commands/MessageCommand.cpp b/src/commands/MessageCommand.cpp index 1acc6f21c..b40833c9e 100644 --- a/src/commands/MessageCommand.cpp +++ b/src/commands/MessageCommand.cpp @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team License: wxwidgets Dan Horgan diff --git a/src/commands/OpenSaveCommands.cpp b/src/commands/OpenSaveCommands.cpp index 6faab3d7e..d5d261990 100644 --- a/src/commands/OpenSaveCommands.cpp +++ b/src/commands/OpenSaveCommands.cpp @@ -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 ******************************************************************//** diff --git a/src/commands/OpenSaveCommands.h b/src/commands/OpenSaveCommands.h index 3dbe7fd2c..41798d3e9 100644 --- a/src/commands/OpenSaveCommands.h +++ b/src/commands/OpenSaveCommands.h @@ -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 ******************************************************************//** diff --git a/src/commands/PreferenceCommands.cpp b/src/commands/PreferenceCommands.cpp index bfccb87aa..11f97db4a 100644 --- a/src/commands/PreferenceCommands.cpp +++ b/src/commands/PreferenceCommands.cpp @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team File License: wxWidgets Dan Horgan diff --git a/src/commands/PreferenceCommands.h b/src/commands/PreferenceCommands.h index 8cba7cac4..fba717242 100644 --- a/src/commands/PreferenceCommands.h +++ b/src/commands/PreferenceCommands.h @@ -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__ */ diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index b8f1ca8e6..4984e5edd 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -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 diff --git a/src/commands/ScreenshotCommand.h b/src/commands/ScreenshotCommand.h index 52a71cd3e..cfdb47495 100644 --- a/src/commands/ScreenshotCommand.h +++ b/src/commands/ScreenshotCommand.h @@ -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__ */ diff --git a/src/commands/ScriptCommandRelay.cpp b/src/commands/ScriptCommandRelay.cpp index 87f0833f8..b721a3c90 100644 --- a/src/commands/ScriptCommandRelay.cpp +++ b/src/commands/ScriptCommandRelay.cpp @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team File License: wxWidgets Dan Horgan diff --git a/src/commands/ScriptCommandRelay.h b/src/commands/ScriptCommandRelay.h index 3e6760e59..453aa3d36 100644 --- a/src/commands/ScriptCommandRelay.h +++ b/src/commands/ScriptCommandRelay.h @@ -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 GetResponseTarget(); }; -#endif /* End of include guard: __SCRIPTCOMMANDRELAY__ */ +#endif /* End of include guard: __SCRIPT_COMMAND_RELAY__ */ diff --git a/src/commands/SelectCommand.cpp b/src/commands/SelectCommand.cpp index a05314393..4f2f26662 100644 --- a/src/commands/SelectCommand.cpp +++ b/src/commands/SelectCommand.cpp @@ -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; } diff --git a/src/commands/SelectCommand.h b/src/commands/SelectCommand.h index 36c66d1fc..410e58f0d 100644 --- a/src/commands/SelectCommand.h +++ b/src/commands/SelectCommand.h @@ -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__ */ diff --git a/src/commands/SetClipCommand.cpp b/src/commands/SetClipCommand.cpp index 78df2d98c..a6da5870d 100644 --- a/src/commands/SetClipCommand.cpp +++ b/src/commands/SetClipCommand.cpp @@ -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(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; } diff --git a/src/commands/SetClipCommand.h b/src/commands/SetClipCommand.h index b050586bb..133e20fd9 100644 --- a/src/commands/SetClipCommand.h +++ b/src/commands/SetClipCommand.h @@ -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; }; diff --git a/src/commands/SetEnvelopeCommand.cpp b/src/commands/SetEnvelopeCommand.cpp index f78c6af3f..da75cdcc4 100644 --- a/src/commands/SetEnvelopeCommand.cpp +++ b/src/commands/SetEnvelopeCommand.cpp @@ -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(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;imEnv.size() && !bFound;i++ ){ - bFound = tFind > pEnv->mEnv[i].GetT(); - } - i -= bFound ? 1 :0; - - pEnv->Insert( i, EnvPoint( mT, mV ) ); - */ return true; } diff --git a/src/commands/SetEnvelopeCommand.h b/src/commands/SetEnvelopeCommand.h index 3320672e8..635f59367 100644 --- a/src/commands/SetEnvelopeCommand.h +++ b/src/commands/SetEnvelopeCommand.h @@ -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; }; diff --git a/src/commands/SetLabelCommand.cpp b/src/commands/SetLabelCommand.cpp index 9d952801c..31f0ab523 100644 --- a/src/commands/SetLabelCommand.cpp +++ b/src/commands/SetLabelCommand.cpp @@ -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 ******************************************************************//** diff --git a/src/commands/SetLabelCommand.h b/src/commands/SetLabelCommand.h index 2caa2b7bf..02b65a13f 100644 --- a/src/commands/SetLabelCommand.h +++ b/src/commands/SetLabelCommand.h @@ -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 ******************************************************************//** diff --git a/src/commands/SetProjectCommand.cpp b/src/commands/SetProjectCommand.cpp index 8b2332112..a9b0967b2 100644 --- a/src/commands/SetProjectCommand.cpp +++ b/src/commands/SetProjectCommand.cpp @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team License: wxwidgets Dan Horgan diff --git a/src/commands/SetProjectCommand.h b/src/commands/SetProjectCommand.h index 09081aa10..7a69aced1 100644 --- a/src/commands/SetProjectCommand.h +++ b/src/commands/SetProjectCommand.h @@ -1,7 +1,7 @@ /********************************************************************** Audacity - A Digital Audio Editor - Copyright 1999-2009 Audacity Team + Copyright 1999-2018 Audacity Team License: wxwidgets Dan Horgan diff --git a/src/commands/SetTrackInfoCommand.cpp b/src/commands/SetTrackInfoCommand.cpp index 606e74697..ae020e66e 100644 --- a/src/commands/SetTrackInfoCommand.cpp +++ b/src/commands/SetTrackInfoCommand.cpp @@ -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(t); + auto pt = dynamic_cast(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(t); - auto pt = dynamic_cast(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; } diff --git a/src/commands/SetTrackInfoCommand.h b/src/commands/SetTrackInfoCommand.h index 15d859d50..29ffb2e27 100644 --- a/src/commands/SetTrackInfoCommand.h +++ b/src/commands/SetTrackInfoCommand.h @@ -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;