mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 00:19:27 +02:00
Add envelope commands
- Added SetEnvelope (which can also delete/clear an envelope.) - Added GetInfo: Type=Envelope
This commit is contained in:
parent
5d36890cb0
commit
edf90d6e2c
@ -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 = "<group>"; };
|
||||
5EF3E658203FDACE006C6882 /* SetProjectCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetProjectCommand.cpp; sourceTree = "<group>"; };
|
||||
5EF3E659203FDACE006C6882 /* SetProjectCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetProjectCommand.h; sourceTree = "<group>"; };
|
||||
5EF3E65D203FDFE9006C6882 /* SetEnvelopeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetEnvelopeCommand.cpp; sourceTree = "<group>"; };
|
||||
5EF3E65E203FDFE9006C6882 /* SetEnvelopeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetEnvelopeCommand.h; sourceTree = "<group>"; };
|
||||
5EF958831DEB121800191280 /* InconsistencyException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InconsistencyException.cpp; sourceTree = "<group>"; };
|
||||
5EF958841DEB121800191280 /* InconsistencyException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InconsistencyException.h; sourceTree = "<group>"; };
|
||||
82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = "<group>"; };
|
||||
@ -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 */,
|
||||
|
@ -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 )
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 )
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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<WaveTrack*>(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;k<pEnv->mEnv.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();
|
||||
|
@ -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 );
|
||||
|
@ -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, () ) \
|
||||
|
104
src/commands/SetEnvelopeCommand.cpp
Normal file
104
src/commands/SetEnvelopeCommand.cpp
Normal file
@ -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<WaveTrack*>(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;i<pEnv->mEnv.size() && !bFound;i++ ){
|
||||
bFound = tFind > pEnv->mEnv[i].GetT();
|
||||
}
|
||||
i -= bFound ? 1 :0;
|
||||
|
||||
pEnv->Insert( i, EnvPoint( mT, mV ) );
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
47
src/commands/SetEnvelopeCommand.h
Normal file
47
src/commands/SetEnvelopeCommand.h
Normal file
@ -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__ */
|
@ -144,6 +144,7 @@
|
||||
<ClCompile Include="..\..\..\src\commands\LoadCommands.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\OpenSaveCommands.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\SetClipCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\SetEnvelopeCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\SetLabelCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\SetProjectCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\Dependencies.cpp" />
|
||||
@ -485,6 +486,7 @@
|
||||
<ClInclude Include="..\..\..\src\commands\LoadCommands.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\OpenSaveCommands.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\SetClipCommand.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\SetEnvelopeCommand.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\SetLabelCommand.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\SetProjectCommand.h" />
|
||||
<ClInclude Include="..\..\..\src\DeviceChange.h" />
|
||||
|
@ -1073,6 +1073,9 @@
|
||||
<ClCompile Include="..\..\..\src\commands\SetProjectCommand.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\commands\SetEnvelopeCommand.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||
@ -2140,6 +2143,9 @@
|
||||
<ClInclude Include="..\..\..\src\commands\SetProjectCommand.h">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\commands\SetEnvelopeCommand.h">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\audacity.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user