Audacity  3.0.3
FileFormats.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  FileFormats.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_FILE_FORMATS__
12 #define __AUDACITY_FILE_FORMATS__
13 
14 
15 
16 #include "Identifier.h"
17 #include "SampleFormat.h"
18 
19 //#include <mutex>
20 #include <memory>
21 
22 #include "sndfile.h"
23 
24 class ChoiceSetting;
25 class wxString;
26 
27 //
28 // enumerating headers
29 //
30 
34 AUDACITY_DLL_API
35 int sf_num_headers();
36 
44 AUDACITY_DLL_API
45 wxString sf_header_index_name(int format_num);
46 
47 AUDACITY_DLL_API
48 unsigned int sf_header_index_to_type(int format_num);
49 
50 //
51 // enumerating encodings
52 //
55 AUDACITY_DLL_API
56 int sf_num_encodings();
60 AUDACITY_DLL_API
61 wxString sf_encoding_index_name(int encoding_num);
62 AUDACITY_DLL_API
63 unsigned int sf_encoding_index_to_subtype(int encoding_num);
64 
65 //
66 // getting info about an actual SF format
67 //
74 AUDACITY_DLL_API
75 wxString sf_header_name(int format);
82 AUDACITY_DLL_API
83 wxString sf_header_shortname(int format);
90 AUDACITY_DLL_API
91 wxString sf_header_extension(int format);
98 wxString sf_encoding_name(int encoding_num);
99 
100 //
101 // simple formats
102 //
103 
105 SF_FORMAT_INFO *sf_simple_format(int i);
106 
107 //
108 // other utility functions
109 //
110 
111 AUDACITY_DLL_API
112 bool sf_subtype_more_than_16_bits(unsigned int format);
113 AUDACITY_DLL_API
114 bool sf_subtype_is_integer(unsigned int format);
115 AUDACITY_DLL_API
116 int sf_subtype_bytes_per_sample(unsigned int format);
117 
118 AUDACITY_DLL_API
121 
122 AUDACITY_DLL_API
124 
125 wxString sf_normalize_name(const char *name);
126 
127 
128 // This function wrapper uses a mutex to serialize calls to the SndFile library.
129 // PRL: Keeping this in a comment, but with Unitary, the only remaining uses
130 // of libsndfile should be in import/export and so are on the main thread only
131 //extern std::mutex libSndFileMutex;
132 
133 template<typename R, typename F, typename... Args>
134 inline R SFCall(F fun, Args&&... args)
135 {
136  //std::lock_guard<std::mutex> guard{ libSndFileMutex };
137  return fun(std::forward<Args>(args)...);
138 }
139 
140 //RAII for SNDFILE*
141 struct AUDACITY_DLL_API SFFileCloser { int operator () (SNDFILE*) const; };
142 struct SFFile : public std::unique_ptr<SNDFILE, ::SFFileCloser>
143 {
144  SFFile() = default;
145  SFFile( SFFile &&that )
146  : std::unique_ptr<SNDFILE, ::SFFileCloser>( std::move( that ) )
147  {}
148 
149  // Close explicitly, not ignoring return values.
150  int close()
151  {
152  auto result = get_deleter() ( get() );
153  release();
154  return result;
155  }
156 };
157 
160 
161 #endif
SFFile::SFFile
SFFile(SFFile &&that)
Definition: FileFormats.h:145
sf_header_index_to_type
AUDACITY_DLL_API unsigned int sf_header_index_to_type(int format_num)
Definition: FileFormats.cpp:59
sf_get_all_extensions
AUDACITY_DLL_API FileExtensions sf_get_all_extensions()
Definition: FileFormats.cpp:241
sf_normalize_name
wxString sf_normalize_name(const char *name)
Definition: FileFormats.cpp:275
sf_num_headers
AUDACITY_DLL_API int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:37
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
sf_encoding_index_name
AUDACITY_DLL_API wxString sf_encoding_index_name(int encoding_num)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
sf_header_name
AUDACITY_DLL_API wxString sf_header_name(int format)
Get the string name of the specified container format.
Definition: FileFormats.cpp:111
SFFile::SFFile
SFFile()=default
ChoiceSetting
Definition: Prefs.h:267
SFFileCloser
Definition: FileFormats.h:141
sf_encoding_name
wxString sf_encoding_name(int encoding_num)
Get the string name of the specified data encoding.
Definition: FileFormats.cpp:157
SFFile::close
int close()
Definition: FileFormats.h:150
sf_num_encodings
AUDACITY_DLL_API int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
name
const TranslatableString name
Definition: Distortion.cpp:98
Identifier.h
sf_num_simple_formats
int sf_num_simple_formats()
Definition: FileFormats.cpp:168
sf_simple_format
SF_FORMAT_INFO * sf_simple_format(int i)
Definition: FileFormats.cpp:179
format
int format
Definition: ExportPCM.cpp:56
FileFormatsSaveWithDependenciesSetting
ChoiceSetting FileFormatsSaveWithDependenciesSetting
Definition: FileFormats.cpp:368
SFFile
Definition: FileFormats.h:143
sf_subtype_bytes_per_sample
AUDACITY_DLL_API int sf_subtype_bytes_per_sample(unsigned int format)
Definition: FileFormats.cpp:207
sampleFormat
sampleFormat
Definition: SampleFormat.h:29
FileFormatsCopyOrEditSetting
ChoiceSetting FileFormatsCopyOrEditSetting
Definition: FileFormats.cpp:353
sf_encoding_index_to_subtype
AUDACITY_DLL_API unsigned int sf_encoding_index_to_subtype(int encoding_num)
Definition: FileFormats.cpp:95
sf_header_extension
AUDACITY_DLL_API wxString sf_header_extension(int format)
Get the most common file extension for the given format.
Definition: FileFormats.cpp:146
sf_subtype_more_than_16_bits
AUDACITY_DLL_API bool sf_subtype_more_than_16_bits(unsigned int format)
Definition: FileFormats.cpp:190
sf_subtype_is_integer
AUDACITY_DLL_API bool sf_subtype_is_integer(unsigned int format)
Definition: FileFormats.cpp:199
SampleFormat.h
sf_header_index_name
AUDACITY_DLL_API wxString sf_header_index_name(int format_num)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:47
sf_subtype_to_effective_format
AUDACITY_DLL_API sampleFormat sf_subtype_to_effective_format(unsigned int format)
Choose the narrowest value in the sampleFormat enumeration for a given libsndfile format.
Definition: FileFormats.cpp:229
SFCall
R SFCall(F fun, Args &&... args)
Definition: FileFormats.h:134
sf_header_shortname
AUDACITY_DLL_API wxString sf_header_shortname(int format)
Get an abbreviated form of the string name of the specified format.
Definition: FileFormats.cpp:122