diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj index 77307b787..f62d623f7 100644 --- a/mac/Audacity.xcodeproj/project.pbxproj +++ b/mac/Audacity.xcodeproj/project.pbxproj @@ -1271,6 +1271,7 @@ 5EF3E65A203FDACE006C6882 /* SetClipCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E654203FDACE006C6882 /* SetClipCommand.cpp */; }; 5EF3E65B203FDACE006C6882 /* SetLabelCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E656203FDACE006C6882 /* SetLabelCommand.cpp */; }; 5EF3E65C203FDACE006C6882 /* SetProjectCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E658203FDACE006C6882 /* SetProjectCommand.cpp */; }; + 5EF3E65F203FDFE9006C6882 /* SetEnvelopeCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E65D203FDFE9006C6882 /* SetEnvelopeCommand.cpp */; }; 5EF958851DEB121800191280 /* InconsistencyException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF958831DEB121800191280 /* InconsistencyException.cpp */; }; 8406A93812D0F2510011EA01 /* EQDefaultCurves.xml in Resources */ = {isa = PBXBuildFile; fileRef = 8406A93712D0F2510011EA01 /* EQDefaultCurves.xml */; }; 8484F31413086237002DF7F0 /* DeviceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8484F31213086237002DF7F0 /* DeviceManager.cpp */; }; @@ -3176,6 +3177,8 @@ 5EF3E657203FDACE006C6882 /* SetLabelCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetLabelCommand.h; sourceTree = ""; }; 5EF3E658203FDACE006C6882 /* SetProjectCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetProjectCommand.cpp; sourceTree = ""; }; 5EF3E659203FDACE006C6882 /* SetProjectCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetProjectCommand.h; sourceTree = ""; }; + 5EF3E65D203FDFE9006C6882 /* SetEnvelopeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetEnvelopeCommand.cpp; sourceTree = ""; }; + 5EF3E65E203FDFE9006C6882 /* SetEnvelopeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetEnvelopeCommand.h; sourceTree = ""; }; 5EF958831DEB121800191280 /* InconsistencyException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InconsistencyException.cpp; sourceTree = ""; }; 5EF958841DEB121800191280 /* InconsistencyException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InconsistencyException.h; sourceTree = ""; }; 82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = ""; }; @@ -3793,6 +3796,7 @@ 28D540030FD1912A00FA7C75 /* ScriptCommandRelay.cpp */, 28851FA91027F16400152EE1 /* SelectCommand.cpp */, 5EF3E654203FDACE006C6882 /* SetClipCommand.cpp */, + 5EF3E65D203FDFE9006C6882 /* SetEnvelopeCommand.cpp */, 5EF3E656203FDACE006C6882 /* SetLabelCommand.cpp */, 5EF3E658203FDACE006C6882 /* SetProjectCommand.cpp */, 28DE72AC10388583007E18EC /* SetTrackInfoCommand.cpp */, @@ -3827,6 +3831,7 @@ 28D540040FD1912A00FA7C75 /* ScriptCommandRelay.h */, 28851FAA1027F16400152EE1 /* SelectCommand.h */, 5EF3E655203FDACE006C6882 /* SetClipCommand.h */, + 5EF3E65E203FDFE9006C6882 /* SetEnvelopeCommand.h */, 5EF3E657203FDACE006C6882 /* SetLabelCommand.h */, 5EF3E659203FDACE006C6882 /* SetProjectCommand.h */, 28DE72AD10388583007E18EC /* SetTrackInfoCommand.h */, @@ -7815,6 +7820,7 @@ 5E73964A1DAFD91D00BA0A4D /* CutlineHandle.cpp in Sources */, 1790B1A309883BFD008A330A /* Meter.cpp in Sources */, 1790B1A409883BFD008A330A /* MultiDialog.cpp in Sources */, + 5EF3E65F203FDFE9006C6882 /* SetEnvelopeCommand.cpp in Sources */, 5E73964D1DAFD95B00BA0A4D /* ButtonHandle.cpp in Sources */, 1790B1A509883BFD008A330A /* Ruler.cpp in Sources */, 1790B1A709883BFD008A330A /* Warning.cpp in Sources */, diff --git a/src/Envelope.h b/src/Envelope.h index 0c0041f6d..1381301ad 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -271,6 +271,8 @@ private: int mDragPoint { -1 }; mutable int mSearchGuess { -2 }; + friend class GetInfoCommand; + friend class SetEnvelopeCommand; }; inline void EnvPoint::SetVal( Envelope *pEnvelope, double val ) diff --git a/src/Menus.cpp b/src/Menus.cpp index 7d63a2b66..2e0354183 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -1619,6 +1619,8 @@ void AudacityProject::CreateMenusAndCommands() AudioIONotBusyFlag, AudioIONotBusyFlag); c->AddItem(wxT("SetClip"), _("Set Clip..."), FN(OnAudacityCommand), AudioIONotBusyFlag, AudioIONotBusyFlag); + c->AddItem(wxT("SetEnvelope"), _("Set Envelope..."), FN(OnAudacityCommand), + AudioIONotBusyFlag, AudioIONotBusyFlag); c->AddItem(wxT("SetLabel"), _("Set Label..."), FN(OnAudacityCommand), AudioIONotBusyFlag, AudioIONotBusyFlag); c->AddItem(wxT("SetProject"), _("Set Project..."), FN(OnAudacityCommand), diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 52e8b51a7..e7637d9a9 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -294,6 +294,7 @@ bool CommandImplementation::Apply(const CommandContext & WXUNUSED(context)) #include "SetClipCommand.cpp" #include "SetLabelCommand.cpp" #include "SetProjectCommand.cpp" +#include "SetEnvelopeCommand.cpp" #endif #endif diff --git a/src/commands/CommandContext.cpp b/src/commands/CommandContext.cpp index df14531ac..ddd543045 100644 --- a/src/commands/CommandContext.cpp +++ b/src/commands/CommandContext.cpp @@ -118,6 +118,16 @@ void CommandContext::EndStruct() const if( pOutput ) pOutput->EndStruct(); } +void CommandContext::StartField(const wxString &name) const +{ + if( pOutput ) + pOutput->StartField(name); +} +void CommandContext::EndField() const +{ + if( pOutput ) + pOutput->EndField(); +} void CommandContext::AddItem(const wxString &value , const wxString &name ) const { if( pOutput ) diff --git a/src/commands/CommandContext.h b/src/commands/CommandContext.h index 46965d00b..b204ae7d5 100644 --- a/src/commands/CommandContext.h +++ b/src/commands/CommandContext.h @@ -44,6 +44,8 @@ public: void EndArray() const; void StartStruct() const; void EndStruct() const; + void StartField(const wxString &name) const; + void EndField() const; void AddItem(const wxString &value , const wxString &name="" ) const; void AddBool(const bool value , const wxString &name="" ) const; void AddItem(const double value , const wxString &name="" ) const; diff --git a/src/commands/CommandTargets.h b/src/commands/CommandTargets.h index ffe98a3ff..c47031e5f 100644 --- a/src/commands/CommandTargets.h +++ b/src/commands/CommandTargets.h @@ -349,6 +349,16 @@ public: if (mStatusTarget) mStatusTarget->EndStruct(); } + void StartField(const wxString &name) + { + if (mStatusTarget) + mStatusTarget->StartField(name); + } + void EndField() + { + if (mStatusTarget) + mStatusTarget->EndField(); + } void AddItem(const wxString &value , const wxString &name="" ) { if (mStatusTarget) diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 078902f90..b07df2dad 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -27,15 +27,15 @@ This class now lists #include "../effects/EffectManager.h" #include "../widgets/Overlay.h" #include "../widgets/OverlayPanel.h" -#include "../Track.h" #include "../TrackPanel.h" +#include "../Track.h" #include "../WaveTrack.h" +#include "../LabelTrack.h" +#include "../Envelope.h" #include "CommandContext.h" #include "SelectCommand.h" #include "../Project.h" -#include "../Track.h" -#include "../LabelTrack.h" #include "../ShuttleGui.h" #include "CommandContext.h" @@ -45,6 +45,7 @@ enum { kMenus, kTracks, kClips, + kEnvelopes, kLabels, kBoxes, nTypes @@ -57,6 +58,7 @@ static const wxString kTypes[nTypes] = XO("Menus"), XO("Tracks"), XO("Clips"), + XO("Envelopes"), XO("Labels"), XO("Boxes") }; @@ -133,6 +135,7 @@ bool GetInfoCommand::ApplyInner(const CommandContext &context) case kMenus : return SendMenus( context ); case kTracks : return SendTracks( context ); case kClips : return SendClips( context ); + case kEnvelopes : return SendEnvelopes( context ); case kLabels : return SendLabels( context ); case kBoxes : return SendBoxes( context ); default: @@ -277,6 +280,50 @@ bool GetInfoCommand::SendClips(const CommandContext &context) return true; } +bool GetInfoCommand::SendEnvelopes(const CommandContext &context) +{ + TrackList *tracks = context.GetProject()->GetTracks(); + TrackListIterator iter(tracks); + Track *t = iter.First(); + int i=0; + int j=0; + context.StartArray(); + while (t) { + if (t->GetKind() == Track::Wave) { + WaveTrack *waveTrack = static_cast(t); + WaveClipPointers ptrs( waveTrack->SortedClipArray()); + for(WaveClip * pClip : ptrs ) { + context.StartStruct(); + context.AddItem( (double)i, "track" ); + context.AddItem( (double)j, "clip" ); + context.AddItem( pClip->GetStartTime(), "start" ); + Envelope * pEnv = pClip->GetEnvelope(); + context.StartField( "points" ); + context.StartArray(); + double offset = pEnv->mOffset; + for( int k=0;kmEnv.size(); k++) + { + context.StartStruct( ); + context.AddItem( pEnv->mEnv[k].GetT()+offset, "t" ); + context.AddItem( pEnv->mEnv[k].GetVal(), "y" ); + context.EndStruct(); + } + context.EndArray(); + context.EndField(); + context.AddItem( pClip->GetEndTime(), "end" ); + context.EndStruct(); + j++; + } + } + t = iter.Next(); + i++; + } + context.EndArray(); + + return true; +} + + bool GetInfoCommand::SendLabels(const CommandContext &context) { TrackList *tracks = context.GetProject()->GetTracks(); diff --git a/src/commands/GetInfoCommand.h b/src/commands/GetInfoCommand.h index 0d41cf3c7..bfd5a649e 100644 --- a/src/commands/GetInfoCommand.h +++ b/src/commands/GetInfoCommand.h @@ -52,6 +52,7 @@ private: bool SendTracks(const CommandContext & context); bool SendLabels(const CommandContext & context); bool SendClips(const CommandContext & context); + bool SendEnvelopes(const CommandContext & context); bool SendBoxes(const CommandContext & context); void ExploreMenu( const CommandContext &context, wxMenu * pMenu, int Id, int depth ); diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index 77e88a0ab..81eb9f241 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -33,6 +33,7 @@ modelled on BuiltinEffectsModule #include "../commands/ImportExportCommands.h" #include "../commands/OpenSaveCommands.h" #include "../commands/SetLabelCommand.h" +#include "../commands/SetEnvelopeCommand.h" #include "../commands/SetClipCommand.h" #include "../commands/SetProjectCommand.h" @@ -45,6 +46,7 @@ modelled on BuiltinEffectsModule COMMAND( SCREENSHOT, ScreenshotCommand, () ) \ COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \ COMMAND( SET_TRACK, SetTrackCommand, () ) \ + COMMAND( SET_ENVELOPE, SetEnvelopeCommand, () ) \ COMMAND( SET_CLIP, SetClipCommand, () ) \ COMMAND( SET_LABEL, SetLabelCommand, () ) \ COMMAND( SET_PROJECT, SetProjectCommand, () ) \ diff --git a/src/commands/SetEnvelopeCommand.cpp b/src/commands/SetEnvelopeCommand.cpp new file mode 100644 index 000000000..f78c6af3f --- /dev/null +++ b/src/commands/SetEnvelopeCommand.cpp @@ -0,0 +1,104 @@ +/********************************************************************** + + Audacity - A Digital Audio Editor + Copyright 1999-2009 Audacity Team + License: wxwidgets + + James Crook + +******************************************************************//** + +\file SetEnvelopeCommand.cpp +\brief Definitions for SetEnvelopeCommand + +\class SetEnvelopeCommand +\brief Command that sets envelope information + +*//*******************************************************************/ + +#include "../Audacity.h" +#include "SetEnvelopeCommand.h" +#include "../Project.h" +#include "../Track.h" +#include "../TrackPanel.h" +#include "../WaveTrack.h" +#include "../Envelope.h" +#include "../ShuttleGui.h" +#include "CommandContext.h" + +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 ); + return true; +}; + +void SetEnvelopeCommand::PopulateOrExchange(ShuttleGui & S) +{ + S.AddSpace(0, 5); + + S.StartMultiColumn(2, wxALIGN_CENTER); + { + S.TieNumericTextBox( _("Track Index:"), mTrackIndex ); + S.TieNumericTextBox( _("Time:"), mT ); + S.TieNumericTextBox( _("Value:"), mV ); + S.TieCheckBox( _("Delete:"), mbDelete ); + } + S.EndMultiColumn(); +} + +bool SetEnvelopeCommand::Apply(const CommandContext & context) +{ + // \todo we have similar code for finding the nth Label, Clip, Track etc. + // this code could be put in subroutines/reduced. + + TrackList *tracks = context.GetProject()->GetTracks(); + TrackListIterator iter(tracks); + Track *t = iter.First(); + WaveClip * pClip = NULL; + int i=0; + + bool bFound = false; + + while (t && !bFound) { + if (t->GetKind() == Track::Wave) { + WaveTrack *waveTrack = static_cast(t); + WaveClipPointers ptrs( waveTrack->SortedClipArray()); + for(auto it = ptrs.begin(); (it != ptrs.end()) && !bFound; it++,i++ ){ + pClip = *it; + bFound = + ( pClip->GetStartTime() <= mT ) && + ( pClip->GetEndTime() >= mT ); + } + } + 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 new file mode 100644 index 000000000..3320672e8 --- /dev/null +++ b/src/commands/SetEnvelopeCommand.h @@ -0,0 +1,47 @@ +/********************************************************************** + + Audacity - A Digital Audio Editor + Copyright 1999-2009 Audacity Team + License: wxwidgets + + James Crook + +******************************************************************//** + +\file SetEnvelopeCommand.h +\brief Declarations of SetEnvelopeCommand class + +*//*******************************************************************/ + +#ifndef __SET_ENVELOPE_COMMAND__ +#define __SET_ENVELOPE_COMMAND__ + +#include "Command.h" +#include "CommandType.h" + +#define SET_ENVELOPE_PLUGIN_SYMBOL XO("Set Envelope") + +class SetEnvelopeCommand : public AudacityCommand +{ +public: + SetEnvelopeCommand(); + // CommandDefinitionInterface overrides + wxString GetSymbol() override {return SET_ENVELOPE_PLUGIN_SYMBOL;}; + wxString GetDescription() override {return _("Sets an envelope point position.");}; + bool DefineParams( ShuttleParams & S ) override; + void PopulateOrExchange(ShuttleGui & S) override; + + // AudacityCommand overrides + wxString ManualPage() override {return wxT("Extra_Menu:_Tools#set_label");}; + + bool Apply(const CommandContext & context) override; + +public: + int mTrackIndex; + double mT; + double mV; + bool mbDelete; +}; + + +#endif /* End of include guard: __SETTRACKINFOCOMMAND__ */ diff --git a/win/Projects/Audacity/Audacity.vcxproj b/win/Projects/Audacity/Audacity.vcxproj index 1f507c042..1f4ad1a44 100755 --- a/win/Projects/Audacity/Audacity.vcxproj +++ b/win/Projects/Audacity/Audacity.vcxproj @@ -144,6 +144,7 @@ + @@ -485,6 +486,7 @@ + diff --git a/win/Projects/Audacity/Audacity.vcxproj.filters b/win/Projects/Audacity/Audacity.vcxproj.filters index aba5649c5..c4cb5c97d 100755 --- a/win/Projects/Audacity/Audacity.vcxproj.filters +++ b/win/Projects/Audacity/Audacity.vcxproj.filters @@ -1073,6 +1073,9 @@ src\commands + + src\commands + @@ -2140,6 +2143,9 @@ src\commands + + src\commands +