Audacity 3.2.0
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
24class ChoiceSetting;
25class wxString;
26
27//
28// enumerating headers
29//
30
34AUDACITY_DLL_API
35int sf_num_headers();
36
44AUDACITY_DLL_API
45wxString sf_header_index_name(int format_num);
46
47AUDACITY_DLL_API
48unsigned int sf_header_index_to_type(int format_num);
49
50//
51// enumerating encodings
52//
55AUDACITY_DLL_API
60AUDACITY_DLL_API
61wxString sf_encoding_index_name(int encoding_num);
62AUDACITY_DLL_API
63unsigned int sf_encoding_index_to_subtype(int encoding_num);
64
65//
66// getting info about an actual SF format
67//
74AUDACITY_DLL_API
75wxString sf_header_name(int format);
82AUDACITY_DLL_API
83wxString sf_header_shortname(int format);
90AUDACITY_DLL_API
91wxString sf_header_extension(int format);
98wxString sf_encoding_name(int encoding_num);
99
100//
101// simple formats
102//
103
105SF_FORMAT_INFO *sf_simple_format(int i);
106
107//
108// other utility functions
109//
110
111AUDACITY_DLL_API
112bool sf_subtype_more_than_16_bits(unsigned int format);
113AUDACITY_DLL_API
114bool sf_subtype_is_integer(unsigned int format);
115AUDACITY_DLL_API
116int sf_subtype_bytes_per_sample(unsigned int format);
117
118AUDACITY_DLL_API
121
122AUDACITY_DLL_API
124
125wxString 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
133template<typename R, typename F, typename... Args>
134inline 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*
141struct AUDACITY_DLL_API SFFileCloser { int operator () (SNDFILE*) const; };
142struct 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
const TranslatableString name
Definition: Distortion.cpp:76
int format
Definition: ExportPCM.cpp:53
AUDACITY_DLL_API FileExtensions sf_get_all_extensions()
AUDACITY_DLL_API wxString sf_header_name(int format)
Get the string name of the specified container format.
SF_FORMAT_INFO * sf_simple_format(int i)
AUDACITY_DLL_API wxString sf_header_shortname(int format)
Get an abbreviated form of the string name of the specified format.
AUDACITY_DLL_API wxString sf_header_extension(int format)
Get the most common file extension for the given format.
AUDACITY_DLL_API unsigned int sf_header_index_to_type(int format_num)
Definition: FileFormats.cpp:58
ChoiceSetting FileFormatsSaveWithDependenciesSetting
AUDACITY_DLL_API unsigned int sf_encoding_index_to_subtype(int encoding_num)
Definition: FileFormats.cpp:94
AUDACITY_DLL_API wxString sf_header_index_name(int format_num)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:46
AUDACITY_DLL_API int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:74
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:83
AUDACITY_DLL_API bool sf_subtype_more_than_16_bits(unsigned int format)
wxString sf_normalize_name(const char *name)
AUDACITY_DLL_API int sf_subtype_bytes_per_sample(unsigned int format)
int sf_num_simple_formats()
ChoiceSetting FileFormatsCopyOrEditSetting
AUDACITY_DLL_API bool sf_subtype_is_integer(unsigned int format)
wxString sf_encoding_name(int encoding_num)
Get the string name of the specified data encoding.
R SFCall(F fun, Args &&... args)
Definition: FileFormats.h:134
AUDACITY_DLL_API int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:36
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.
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
STL namespace.
int close()
Definition: FileFormats.h:150
SFFile()=default
SFFile(SFFile &&that)
Definition: FileFormats.h:145