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 "WaveTrack.h"
20
21//TODO: used in many places in anticipation that Exporter yields same result, fix that
23{
24 bool anySolo =
25 !(tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo).empty();
26
27 return tracks.Any<const WaveTrack>()
28 + (selectedOnly ? &Track::IsSelected : &Track::Any)
30}
31
33{
35 for(int i = 0, count = editor.GetOptionsCount(); i < count; ++i)
36 {
37 ExportOption option;
38 ExportValue value;
39 if(editor.GetOption(i, option) && editor.GetValue(option.id, value))
40 parameters.emplace_back(option.id, value);
41 }
42 return parameters;
43}
44
45namespace
46{
48{
51};
52
54{
55 static std::vector<ExportHookElement> hooks;
56 return hooks;
57}
58}
59
61{
62 auto& hooks = ExportHooks();
63 hooks.insert(
64 std::upper_bound(
65 hooks.begin(), hooks.end(), priority,
66 [](Priority priority, const ExportHookElement& element)
67 { return priority > element.priority; }),
68 { hook, priority });
69}
70
73{
74 auto& hooks = ExportHooks();
75 for (auto& hook : hooks)
76 {
78 return;
79 }
80}
std::variant< bool, int, double, std::string > ExportValue
A type of option values (parameters) used by exporting plugins.
Definition: ExportTypes.h:38
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:43
std::function< ExportHookResult(AudacityProject &, const FileExtension &)> ExportHook
Definition: ExportUtils.h:41
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:22
static void PerformInteractiveExport(AudacityProject &project, const FileExtension &format)
Definition: ExportUtils.cpp:71
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:32
static void RegisterExportHook(ExportHook hook, Priority=DEFAULT_EXPORT_HOOK_PRIORITY)
Definition: ExportUtils.cpp:60
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
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