Audacity 3.2.0
ExportUtils.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ExportUtils.cpp
6
7 Dominic Mazzoni
8
9 Vitaly Sverchinsky split from ExportPlugin.h
10
11**********************************************************************/
12
13#include "ExportUtils.h"
14
15#include <algorithm>
16#include <vector>
17
18#include "Track.h"
19#include "ViewInfo.h"
20#include "WaveTrack.h"
21
22//TODO: used in many places in anticipation that Exporter yields same result, fix that
24{
25 bool anySolo =
26 !(tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo).empty();
27
28 return tracks.Any<const WaveTrack>()
29 + (selectedOnly ? &Track::IsSelected : &Track::Any)
31}
32
34{
35 return !FindExportWaveTracks(TrackList::Get(project), true).empty() &&
37}
38
40{
42 for(int i = 0, count = editor.GetOptionsCount(); i < count; ++i)
43 {
44 ExportOption option;
45 ExportValue value;
46 if(editor.GetOption(i, option) && editor.GetValue(option.id, value))
47 parameters.emplace_back(option.id, value);
48 }
49 return parameters;
50}
51
52namespace
53{
55{
58};
59
61{
62 static std::vector<ExportHookElement> hooks;
63 return hooks;
64}
65}
66
68{
69 auto& hooks = ExportHooks();
70 hooks.insert(
71 std::upper_bound(
72 hooks.begin(), hooks.end(), priority,
73 [](Priority priority, const ExportHookElement& element)
74 { return priority > element.priority; }),
75 { hook, priority });
76}
77
80 bool selectedOnly)
81{
82 auto& hooks = ExportHooks();
83 for (auto& hook : hooks)
84 {
85 if (
86 hook.hook(project, format, trace, selectedOnly) !=
88 return;
89 }
90}
std::variant< bool, int, double, std::string > ExportValue
A type of option values (parameters) used by exporting plugins.
Definition: ExportTypes.h:38
AudiocomTrace
Definition: ExportUtils.h:27
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
const auto tracks
const auto project
declares abstract base class Track, TrackList, and iterators over TrackList
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Editor objects are used to retrieve a set of export options, and configure exporting parameters accor...
virtual bool GetValue(ExportOptionID id, ExportValue &value) const =0
virtual bool GetOption(int index, ExportOption &option) const =0
virtual int GetOptionsCount() const =0
std::vector< std::tuple< ExportOptionID, ExportValue > > Parameters
Definition: ExportPlugin.h:93
unsigned Priority
Definition: ExportUtils.h:64
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:23
static void PerformInteractiveExport(AudacityProject &project, const FileExtension &format, AudiocomTrace trace, bool selectedOnly)
Definition: ExportUtils.cpp:78
std::function< ExportHookResult(AudacityProject &, const FileExtension &, AudiocomTrace, bool)> ExportHook
Definition: ExportUtils.h:62
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:39
static bool HasSelectedAudio(const AudacityProject &project)
Definition: ExportUtils.cpp:33
static void RegisterExportHook(ExportHook hook, Priority=DEFAULT_EXPORT_HOOK_PRIORITY)
Definition: ExportUtils.cpp:67
bool isPoint() const
Definition: ViewInfo.h:40
bool GetNotSolo() const
Definition: PlayableTrack.h:50
bool IsSelected() const
Definition: Track.cpp:258
bool Any() const
Definition: Track.cpp:255
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
bool GetMute() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2318
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2323
A type that provides a description of an exporting option. Isn't allowed to change except non-type re...
Definition: ExportTypes.h:43
ExportOptionID id
Internal option id.
Definition: ExportTypes.h:56
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:682