Audacity  3.0.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ImportFileHandle Class Referenceabstract

An ImportFileHandle for data. More...

#include <ImportPlugin.h>

Inheritance diagram for ImportFileHandle:
[legend]
Collaboration diagram for ImportFileHandle:
[legend]

Public Types

using ProgressResult = BasicUI::ProgressResult
 
using ByteCount = unsigned long long
 

Public Member Functions

 ImportFileHandle (const FilePath &filename)
 
virtual ~ImportFileHandle ()
 
void CreateProgress ()
 
virtual TranslatableString GetFileDescription ()=0
 
virtual ByteCount GetFileUncompressedBytes ()=0
 
virtual wxInt32 GetStreamCount ()=0
 
virtual const TranslatableStringsGetStreamInfo ()=0
 
virtual void SetStreamUsage (wxInt32 StreamID, bool Use)=0
 
virtual ProgressResult Import (WaveTrackFactory *trackFactory, TrackHolders &outTracks, Tags *tags)=0
 

Static Public Member Functions

static sampleFormat ChooseFormat (sampleFormat effectiveFormat)
 Choose appropriate format, which will not be narrower than the specified one. More...
 

Protected Member Functions

std::shared_ptr< WaveTrackNewWaveTrack (WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
 Build a wave track with appropriate format, which will not be narrower than the specified one. More...
 

Protected Attributes

FilePath mFilename
 
std::unique_ptr< ProgressDialogmProgress
 

Detailed Description

An ImportFileHandle for data.

Base class for FlacImportFileHandle, LOFImportFileHandle, MP3ImportFileHandle, OggImportFileHandle and PCMImportFileHandle. Gives API for sound file import.

The Ogg format supports multiple logical bitstreams that can be chained within the physical bitstream. The sampling rate and number of channels can vary between these logical bitstreams. For the moment, we'll ignore all but the first logical bitstream.

Ogg also allows for an arbitrary number of channels. Luckily, so does Audacity. We'll call the first channel LeftChannel, the second RightChannel, and all others after it MonoChannel.

Definition at line 106 of file ImportPlugin.h.

Member Typedef Documentation

◆ ByteCount

using ImportFileHandle::ByteCount = unsigned long long

Definition at line 127 of file ImportPlugin.h.

◆ ProgressResult

Definition at line 109 of file ImportPlugin.h.

Constructor & Destructor Documentation

◆ ImportFileHandle()

ImportFileHandle::ImportFileHandle ( const FilePath filename)

Definition at line 36 of file ImportPlugin.cpp.

37 : mFilename(filename)
38 {
39 }

◆ ~ImportFileHandle()

ImportFileHandle::~ImportFileHandle ( )
virtual

Definition at line 41 of file ImportPlugin.cpp.

42 {
43 }

Member Function Documentation

◆ ChooseFormat()

sampleFormat ImportFileHandle::ChooseFormat ( sampleFormat  effectiveFormat)
static

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

Definition at line 54 of file ImportPlugin.cpp.

55 {
56  // Consult user preference
57  auto defaultFormat = QualitySettings::SampleFormatChoice();
58 
59  // Don't choose format narrower than effective or default
60  auto format = std::max(effectiveFormat, defaultFormat);
61 
62  // But also always promote 24 bits to float
63  if (format > int16Sample)
65 
66  return format;
67 }

References floatSample, format, int16Sample, and QualitySettings::SampleFormatChoice().

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

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

◆ CreateProgress()

void ImportFileHandle::CreateProgress ( )

Definition at line 45 of file ImportPlugin.cpp.

46 {
47  wxFileName ff( mFilename );
48 
49  auto title = XO("Importing %s").Format( GetFileDescription() );
50  mProgress = std::make_unique< ProgressDialog >(
51  title, Verbatim( ff.GetFullName() ) );
52 }

References GetFileDescription(), mFilename, mProgress, title, Verbatim(), and XO.

Referenced by GStreamerImportFileHandle::Import(), AUPImportFileHandle::Import(), FFmpegImportFileHandle::Import(), FLACImportFileHandle::Import(), MP3ImportFileHandle::Import(), OggImportFileHandle::Import(), and PCMImportFileHandle::Import().

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

◆ GetFileDescription()

virtual TranslatableString ImportFileHandle::GetFileDescription ( )
pure virtual

Implemented in PCMImportFileHandle, OggImportFileHandle, MP3ImportFileHandle, LOFImportFileHandle, GStreamerImportFileHandle, FLACImportFileHandle, FFmpegImportFileHandle, and AUPImportFileHandle.

Referenced by CreateProgress().

Here is the caller graph for this function:

◆ GetFileUncompressedBytes()

virtual ByteCount ImportFileHandle::GetFileUncompressedBytes ( )
pure virtual

◆ GetStreamCount()

virtual wxInt32 ImportFileHandle::GetStreamCount ( )
pure virtual

◆ GetStreamInfo()

virtual const TranslatableStrings& ImportFileHandle::GetStreamInfo ( )
pure virtual

◆ Import()

virtual ProgressResult ImportFileHandle::Import ( WaveTrackFactory trackFactory,
TrackHolders outTracks,
Tags tags 
)
pure virtual

◆ NewWaveTrack()

std::shared_ptr< WaveTrack > ImportFileHandle::NewWaveTrack ( WaveTrackFactory trackFactory,
sampleFormat  effectiveFormat,
double  rate 
)
protected

Build a wave track with appropriate format, which will not be narrower than the specified one.

Definition at line 69 of file ImportPlugin.cpp.

71 {
72  return trackFactory.NewWaveTrack(ChooseFormat(effectiveFormat), rate);
73 }

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

Referenced by FFmpegImportFileHandle::Import(), FLACImportFileHandle::Import(), OggImportFileHandle::Import(), and PCMImportFileHandle::Import().

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

◆ SetStreamUsage()

virtual void ImportFileHandle::SetStreamUsage ( wxInt32  StreamID,
bool  Use 
)
pure virtual

Member Data Documentation

◆ mFilename

FilePath ImportFileHandle::mFilename
protected

◆ mProgress

std::unique_ptr<ProgressDialog> ImportFileHandle::mProgress
protected

The documentation for this class was generated from the following files:
XO
#define XO(s)
Definition: Internat.h:31
ImportFileHandle::mProgress
std::unique_ptr< ProgressDialog > mProgress
Definition: ImportPlugin.h:159
floatSample
@ floatSample
Definition: SampleFormat.h:34
ImportFileHandle::ChooseFormat
static sampleFormat ChooseFormat(sampleFormat effectiveFormat)
Choose appropriate format, which will not be narrower than the specified one.
Definition: ImportPlugin.cpp:54
int16Sample
@ int16Sample
Definition: SampleFormat.h:32
format
int format
Definition: ExportPCM.cpp:56
ImportFileHandle::mFilename
FilePath mFilename
Definition: ImportPlugin.h:158
ImportFileHandle::GetFileDescription
virtual TranslatableString GetFileDescription()=0
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
QualitySettings::SampleFormatChoice
PROJECT_RATE_API sampleFormat SampleFormatChoice()
Definition: QualitySettings.cpp:38
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
WaveTrackFactory::NewWaveTrack
std::shared_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:113