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 "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{
38 return {};
39}
40
42: mFilename(filename)
43{
44}
45
47{
48}
49
51{
52 wxFileName ff( mFilename );
53
54 auto title = XO("Importing %s").Format( GetFileDescription() );
55 mProgress = std::make_unique< ProgressDialog >(
56 title, Verbatim( ff.GetFullName() ) );
57}
58
60{
61 // Consult user preference
62 auto defaultFormat = QualitySettings::SampleFormatChoice();
63
64 // Don't choose format narrower than effective or default
65 auto format = std::max(effectiveFormat, defaultFormat);
66
67 // But also always promote 24 bits to float
68 if (format > int16Sample)
70
71 return format;
72}
73
74std::shared_ptr<WaveTrack> ImportFileHandle::NewWaveTrack(
75 WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
76{
77 return trackFactory.Create(ChooseFormat(effectiveFormat), rate);
78}
int format
Definition: ExportPCM.cpp:53
XO("Cut/Copy/Paste")
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....
static const auto title
wxString FilePath
Definition: Project.h:21
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
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:163
std::unique_ptr< ProgressDialog > mProgress
Definition: ImportPlugin.h:164
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()
virtual TranslatableString FailureHint() const
User visible message suggesting what to do when a file type isn't recognized; default empty string.
const FileExtensions mExtensions
Definition: ImportPlugin.h:104
virtual FileExtensions GetSupportedExtensions()
ImportPlugin(FileExtensions supportedExtensions)
bool SupportsExtension(const FileExtension &extension)
Holds a msgid for the translation catalog; may also bind format arguments.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:565
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
Definition: WaveTrack.cpp:116
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
PROJECT_RATE_API sampleFormat SampleFormatChoice()
STL namespace.