Audacity 3.2.0
ImportPlugin.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ImportPlugin.cpp
6
7Paul Licameli split from Import.cpp
8
9**********************************************************************/
10
11#include "ImportPlugin.h"
12
13#include <wx/filename.h>
14#include "../WaveTrack.h"
15#include "../widgets/ProgressDialog.h"
16#include "QualitySettings.h"
17
19 mExtensions( std::move( supportedExtensions ) )
20{
21}
22
24
26{
27 return mExtensions;
28}
29
31{
32 // Case-insensitive check if extension is supported
33 return mExtensions.Index(extension, false) != wxNOT_FOUND;
34}
35
37: mFilename(filename)
38{
39}
40
42{
43}
44
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}
53
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}
68
69std::shared_ptr<WaveTrack> ImportFileHandle::NewWaveTrack(
70 WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
71{
72 return trackFactory.Create(ChooseFormat(effectiveFormat), rate);
73}
int format
Definition: ExportPCM.cpp:56
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
The interface that all file import "plugins" (if you want to call them that) must implement....
#define XO(s)
Definition: Internat.h:31
static const auto title
wxString FilePath
Definition: Project.h:20
sampleFormat
Definition: SampleFormat.h:29
@ floatSample
Definition: SampleFormat.h:34
@ int16Sample
Definition: SampleFormat.h:32
static wxCharBuffer mFilename
Definition: SelectFile.cpp:38
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
virtual TranslatableString GetFileDescription()=0
static sampleFormat ChooseFormat(sampleFormat effectiveFormat)
Choose appropriate format, which will not be narrower than the specified one.
FilePath mFilename
Definition: ImportPlugin.h:158
std::unique_ptr< ProgressDialog > mProgress
Definition: ImportPlugin.h:159
ImportFileHandle(const FilePath &filename)
std::shared_ptr< WaveTrack > NewWaveTrack(WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
Build a wave track with appropriate format, which will not be narrower than the specified one.
virtual ~ImportFileHandle()
virtual ~ImportPlugin()
const FileExtensions mExtensions
Definition: ImportPlugin.h:99
virtual FileExtensions GetSupportedExtensions()
ImportPlugin(FileExtensions supportedExtensions)
bool SupportsExtension(const FileExtension &extension)
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:606
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
Definition: WaveTrack.cpp:118
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
PROJECT_RATE_API sampleFormat SampleFormatChoice()
STL namespace.