Audacity 3.2.0
Classes | Namespaces | Functions | Variables
WaveTrack.cpp File Reference
#include "WaveTrack.h"
#include "WaveClip.h"
#include <wx/defs.h>
#include <wx/debug.h>
#include <wx/log.h>
#include <float.h>
#include <math.h>
#include <algorithm>
#include <optional>
#include <numeric>
#include "float_cast.h"
#include "Envelope.h"
#include "Sequence.h"
#include "Project.h"
#include "ProjectRate.h"
#include "Prefs.h"
#include "TimeWarper.h"
#include "QualitySettings.h"
#include "prefs/SpectrogramSettings.h"
#include "prefs/WaveformSettings.h"
#include "InconsistencyException.h"
#include "ProjectFormatExtensionsRegistry.h"
#include "SampleBlock.h"
Include dependency graph for WaveTrack.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{WaveTrack.cpp}::SplitInfo
 

Namespaces

namespace  anonymous_namespace{WaveTrack.cpp}
 

Functions

bool anonymous_namespace{WaveTrack.cpp}::AreAligned (const WaveClipPointers &a, const WaveClipPointers &b)
 
Track::LinkType anonymous_namespace{WaveTrack.cpp}::ToLinkType (int value)
 
static const Track::TypeInfotypeInfo ()
 
template<typename Container >
static Container MakeIntervals (const std::vector< WaveClipHolder > &clips)
 
WaveClipHolders::const_iterator anonymous_namespace{WaveTrack.cpp}::FindClip (const WaveClipHolders &list, const WaveClip *clip, int *distance=nullptr)
 
WaveClipHolders::iterator anonymous_namespace{WaveTrack.cpp}::FindClip (WaveClipHolders &list, const WaveClip *clip, int *distance=nullptr)
 
bool anonymous_namespace{WaveTrack.cpp}::IsValidChannel (const int nValue)
 
template<typename Cont1 , typename Cont2 >
Cont1 anonymous_namespace{WaveTrack.cpp}::FillSortedClipArray (const Cont2 &mClips)
 
void VisitBlocks (TrackList &tracks, BlockVisitor visitor, SampleBlockIDSet *pIDs)
 
void InspectBlocks (const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs)
 
bool GetEditClipsCanMove ()
 
 DEFINE_XML_METHOD_REGISTRY (WaveTrackIORegistry)
 

Variables

static auto DefaultName = XO("Audio")
 
static ProjectFileIORegistry::ObjectReaderEntry readerEntry
 
static auto TrackFactoryFactory
 
static const AudacityProject::AttachedObjects::RegisteredFactory key2
 
ProjectFormatExtensionsRegistry::Extension smartClipsExtension ([](const AudacityProject &project) -> ProjectFormatVersion { const TrackList &trackList=TrackList::Get(project);for(auto wt :trackList.Any< const WaveTrack >()) { for(const auto &clip :wt->GetAllClips()) { if(clip->GetTrimLeft() > 0.0||clip->GetTrimRight() > 0.0) return { 3, 1, 0, 0 };} } return BaseProjectFormatVersion;})
 
StringSetting AudioTrackNameSetting
 
BoolSetting EditClipsCanMove
 

Function Documentation

◆ DEFINE_XML_METHOD_REGISTRY()

DEFINE_XML_METHOD_REGISTRY ( WaveTrackIORegistry  )

◆ GetEditClipsCanMove()

bool GetEditClipsCanMove ( )

Definition at line 2847 of file WaveTrack.cpp.

2848{
2849 bool mIsSyncLocked;
2850 gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mIsSyncLocked, false);
2851 if( mIsSyncLocked )
2852 return true;
2853 bool editClipsCanMove;
2854 return EditClipsCanMove.Read();
2855}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:70
BoolSetting EditClipsCanMove
Definition: WaveTrack.cpp:2857
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200

References EditClipsCanMove, gPrefs, Setting< T >::Read(), and wxT().

Referenced by WaveTrack::ExpandCutLine(), WaveTrack::HandleClear(), WaveTrack::PasteWaveTrack(), and Generator::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InspectBlocks()

void InspectBlocks ( const TrackList tracks,
BlockInspector  inspector,
SampleBlockIDSet pIDs 
)

Definition at line 2778 of file WaveTrack.cpp.

2780{
2782 const_cast<TrackList &>(tracks), std::move( inspector ), pIDs );
2783}
void VisitBlocks(TrackList &tracks, BlockVisitor visitor, SampleBlockIDSet *pIDs)
Definition: WaveTrack.cpp:2757
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1338

References VisitBlocks().

Referenced by anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::CalculateUsage(), ProjectFileIO::CopyTo(), EstimateRemovedBlocks(), ProjectFileIO::GetCurrentUsage(), ProjectFileIO::SaveProject(), and ProjectFileIO::ShouldCompact().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeIntervals()

template<typename Container >
static Container MakeIntervals ( const std::vector< WaveClipHolder > &  clips)
static

Definition at line 405 of file WaveTrack.cpp.

406{
407 Container result;
408 for (const auto &clip: clips) {
409 result.emplace_back( clip->GetPlayStartTime(), clip->GetPlayEndTime(),
410 std::make_unique<WaveTrack::IntervalData>( clip ) );
411 }
412 return result;
413}

◆ typeInfo()

static const Track::TypeInfo & typeInfo ( )
static

Definition at line 308 of file WaveTrack.cpp.

309{
310 static const Track::TypeInfo info{
311 { "wave", "wave", XO("Wave Track") },
313 return info;
314}
XO("Cut/Copy/Paste")
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:70

References WritableSampleTrack::ClassTypeInfo(), and XO().

Referenced by WaveTrack::ClassTypeInfo(), and WaveTrack::GetTypeInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VisitBlocks()

void VisitBlocks ( TrackList tracks,
BlockVisitor  visitor,
SampleBlockIDSet pIDs 
)

Definition at line 2757 of file WaveTrack.cpp.

2759{
2760 for (auto wt : tracks.Any< const WaveTrack >()) {
2761 // Scan all clips within current track
2762 for(const auto &clip : wt->GetAllClips()) {
2763 // Scan all sample blocks within current clip
2764 auto blocks = clip->GetSequenceBlockArray();
2765 for (const auto &block : *blocks) {
2766 auto &pBlock = block.sb;
2767 if ( pBlock ) {
2768 if ( pIDs && !pIDs->insert(pBlock->GetBlockID()).second )
2769 continue;
2770 if ( visitor )
2771 visitor( *pBlock );
2772 }
2773 }
2774 }
2775 }
2776}
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
A Track that contains audio waveform data.
Definition: WaveTrack.h:57

References TrackList::Any().

Referenced by InspectBlocks().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ AudioTrackNameSetting

StringSetting AudioTrackNameSetting
Initial value:
{
L"/GUI/TrackNames/DefaultTrackName",
[]{ return DefaultName.Translation(); }
}
static auto DefaultName
Definition: WaveTrack.cpp:98

Definition at line 2837 of file WaveTrack.cpp.

Referenced by TracksPrefs::Commit(), WaveTrack::GetDefaultAudioTrackNamePreference(), and TracksPrefs::PopulateOrExchange().

◆ DefaultName

auto DefaultName = XO("Audio")
static

Definition at line 98 of file WaveTrack.cpp.

Referenced by WaveTrack::GetDefaultAudioTrackNamePreference().

◆ EditClipsCanMove

BoolSetting EditClipsCanMove
Initial value:
{
L"/GUI/EditClipCanMove", false }

Definition at line 2857 of file WaveTrack.cpp.

Referenced by TracksBehaviorsPrefs::Commit(), GetEditClipsCanMove(), BenchmarkDialog::OnRun(), TracksBehaviorsPrefs::PopulateOrExchange(), and WaveTrack::SyncLockAdjust().

◆ key2

◆ readerEntry

Initial value:
{
"wavetrack",
}
static WaveTrack * New(AudacityProject &project)
Definition: WaveTrack.cpp:128

Definition at line 113 of file WaveTrack.cpp.

◆ smartClipsExtension

ProjectFormatExtensionsRegistry::Extension smartClipsExtension([](const AudacityProject &project) -> ProjectFormatVersion { const TrackList &trackList=TrackList::Get(project);for(auto wt :trackList.Any< const WaveTrack >()) { for(const auto &clip :wt->GetAllClips()) { if(clip->GetTrimLeft() > 0.0||clip->GetTrimRight() > 0.0) return { 3, 1, 0, 0 };} } return BaseProjectFormatVersion;}) ( [] (const AudacityProject &project) -> ProjectFormatVersion { const TrackList &trackList=TrackList::Get(project);for(auto wt :trackList.Any< const WaveTrack >()) { for(const auto &clip :wt->GetAllClips()) { if(clip->GetTrimLeft() > 0.0||clip->GetTrimRight() > 0.0) return { 3, 1, 0, 0 };} } return BaseProjectFormatVersion;}  )

◆ TrackFactoryFactory

auto TrackFactoryFactory
static
Initial value:
= []( AudacityProject &project ) {
return std::make_shared< WaveTrackFactory >(
ProjectRate::Get( project ),
}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
static SampleBlockFactoryPtr New(AudacityProject &project)
Definition: SampleBlock.cpp:16

Definition at line 2787 of file WaveTrack.cpp.

Referenced by WaveTrackFactory::Reset().