Audacity 3.2.0
Static Public Member Functions | List of all members
ImportUtils Class Referencefinal

#include <ImportUtils.h>

Static Public Member Functions

static sampleFormat ChooseFormat (sampleFormat effectiveFormat)
 Choose appropriate format, which will not be narrower than the specified one. More...
 
static std::shared_ptr< WaveTrackNewWaveTrack (WaveTrackFactory &trackFactory, unsigned nChannels, sampleFormat effectiveFormat, double rate)
 
static void ShowMessageBox (const TranslatableString &message, const TranslatableString &caption=XO("Import Project"))
 
static void ForEachChannel (TrackList &trackList, const std::function< void(WaveChannel &)> &op)
 Iterates over channels in each wave track from the list. More...
 
static void ForEachChannel (WaveTrack &track, const std::function< void(WaveChannel &)> &op)
 Iterates over channels in one wave track. More...
 
static void FinalizeImport (TrackHolders &outTracks, const std::vector< std::shared_ptr< WaveTrack > > &importedStreams)
 Flushes the given channels and moves them to outTracks. More...
 
static void FinalizeImport (TrackHolders &outTracks, TrackList &&trackList)
 
static void FinalizeImport (TrackHolders &outTracks, WaveTrack &track)
 Flushes the given channels and moves them to outTracks. More...
 

Detailed Description

Definition at line 30 of file ImportUtils.h.

Member Function Documentation

◆ ChooseFormat()

sampleFormat ImportUtils::ChooseFormat ( sampleFormat  effectiveFormat)
static

Choose appropriate format, which will not be narrower than the specified one.

Definition at line 19 of file ImportUtils.cpp.

20{
21 // Consult user preference
22 auto defaultFormat = QualitySettings::SampleFormatChoice();
23
24 // Don't choose format narrower than effective or default
25 auto format = std::max(effectiveFormat, defaultFormat);
26
27 // But also always promote 24 bits to float
28 if (format > int16Sample)
30
31 return format;
32}
PROJECT_RATE_API sampleFormat SampleFormatChoice()

References floatSample, anonymous_namespace{ExportPCM.cpp}::format, int16Sample, and QualitySettings::SampleFormatChoice().

Referenced by FFmpegImportFileHandle::Import(), PCMImportFileHandle::Import(), ImportRaw(), NewWaveTrack(), and PCMImportFileHandle::PCMImportFileHandle().

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

◆ FinalizeImport() [1/3]

void ImportUtils::FinalizeImport ( TrackHolders outTracks,
const std::vector< std::shared_ptr< WaveTrack > > &  importedStreams 
)
static

Flushes the given channels and moves them to outTracks.

Definition at line 49 of file ImportUtils.cpp.

50{
51 for(auto& stream : importedStreams)
52 FinalizeImport(outTracks, *stream);
53}
static void FinalizeImport(TrackHolders &outTracks, const std::vector< std::shared_ptr< WaveTrack > > &importedStreams)
Flushes the given channels and moves them to outTracks.
Definition: ImportUtils.cpp:49

References FinalizeImport().

Referenced by FinalizeImport(), FFmpegImportFileHandle::Import(), FLACImportFileHandle::Import(), anonymous_namespace{ImportMP3_MPG123.cpp}::MP3ImportFileHandle::Import(), OggImportFileHandle::Import(), OpusImportFileHandle::Import(), PCMImportFileHandle::Import(), and WavPackImportFileHandle::Import().

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

◆ FinalizeImport() [2/3]

void ImportUtils::FinalizeImport ( TrackHolders outTracks,
TrackList &&  trackList 
)
static

Flushes the given channels and moves them to outTracks trackList is emptied

Definition at line 55 of file ImportUtils.cpp.

56{
57 if(trackList.empty())
58 return;
59
60 for(const auto track : trackList.Any<WaveTrack>())
61 track->Flush();
62
63 while (!trackList.empty())
64 outTracks.push_back(trackList.DetachFirst());
65}
bool empty() const
Definition: Track.cpp:758
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
Track::Holder DetachFirst()
Remove and return the first track.
Definition: Track.cpp:897
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

◆ FinalizeImport() [3/3]

void ImportUtils::FinalizeImport ( TrackHolders outTracks,
WaveTrack track 
)
static

Flushes the given channels and moves them to outTracks.

Definition at line 67 of file ImportUtils.cpp.

68{
69 track.Flush();
70 outTracks.push_back(track.shared_from_this());
71}
void Flush() override
Definition: WaveTrack.cpp:2315

References WaveTrack::Flush().

Here is the call graph for this function:

◆ ForEachChannel() [1/2]

void ImportUtils::ForEachChannel ( TrackList trackList,
const std::function< void(WaveChannel &)> &  op 
)
static

Iterates over channels in each wave track from the list.

Definition at line 73 of file ImportUtils.cpp.

74{
75 for(auto track : trackList.Any<WaveTrack>())
76 {
77 for(auto channel : track->Channels())
78 {
79 op(*channel);
80 }
81 }
82}

References TrackList::Any().

Referenced by anonymous_namespace{ImportMP3_MPG123.cpp}::MP3ImportFileHandle::Import(), OggImportFileHandle::Import(), OpusImportFileHandle::Import(), PCMImportFileHandle::Import(), WavPackImportFileHandle::Import(), ImportRaw(), MyFLACFile::write_callback(), and FFmpegImportFileHandle::WriteData().

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

◆ ForEachChannel() [2/2]

void ImportUtils::ForEachChannel ( WaveTrack track,
const std::function< void(WaveChannel &)> &  op 
)
static

Iterates over channels in one wave track.

Definition at line 84 of file ImportUtils.cpp.

85{
86 for(auto channel : track.Channels())
87 {
88 op(*channel);
89 }
90}
auto Channels()
Definition: WaveTrack.h:263

References WaveTrack::Channels().

Here is the call graph for this function:

◆ NewWaveTrack()

WaveTrack::Holder ImportUtils::NewWaveTrack ( WaveTrackFactory trackFactory,
unsigned  nChannels,
sampleFormat  effectiveFormat,
double  rate 
)
static

Builds a wave track The format will not be narrower than the specified one.

Definition at line 35 of file ImportUtils.cpp.

39{
40 return trackFactory.Create(nChannels, ChooseFormat(effectiveFormat), rate);
41}
static sampleFormat ChooseFormat(sampleFormat effectiveFormat)
Choose appropriate format, which will not be narrower than the specified one.
Definition: ImportUtils.cpp:19
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
Definition: WaveTrack.cpp:391

References ChooseFormat(), and WaveTrackFactory::Create().

Referenced by FLACImportFileHandle::Import(), OpusImportFileHandle::Import(), and anonymous_namespace{ImportMP3_MPG123.cpp}::MP3ImportFileHandle::SetupOutputFormat().

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

◆ ShowMessageBox()

void ImportUtils::ShowMessageBox ( const TranslatableString message,
const TranslatableString caption = XO("Import Project") 
)
static

Definition at line 43 of file ImportUtils.cpp.

44{
46 BasicUI::MessageBoxOptions().Caption(caption));
47}
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:287

References BasicUI::ShowMessageBox().

Referenced by AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleProject(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::Import(), WavPackImportFileHandle::Import(), LOFImportFileHandle::lofOpenFiles(), OpusImportFileHandle::NotifyImportFailed(), and AUPImportFileHandle::Open().

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

The documentation for this class was generated from the following files: