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 <memory>
20#include <sndfile.h>
21
22class ChoiceSetting;
23class wxString;
24
25//
26// enumerating headers
27//
28
32FILE_FORMATS_API
33int sf_num_headers();
34
42FILE_FORMATS_API
43wxString sf_header_index_name(int format_num);
44
45FILE_FORMATS_API
46unsigned int sf_header_index_to_type(int format_num);
47
48//
49// enumerating encodings
50//
53FILE_FORMATS_API
58FILE_FORMATS_API
59wxString sf_encoding_index_name(int encoding_num);
60FILE_FORMATS_API
61unsigned int sf_encoding_index_to_subtype(int encoding_num);
62
63//
64// getting info about an actual SF format
65//
72FILE_FORMATS_API
73wxString sf_header_name(int format);
80FILE_FORMATS_API
81wxString sf_header_shortname(int format);
88FILE_FORMATS_API
89wxString sf_header_extension(int format);
96wxString sf_encoding_name(int encoding_num);
97
98//
99// simple formats
100//
101
103SF_FORMAT_INFO *sf_simple_format(int i);
104
105//
106// other utility functions
107//
108
109FILE_FORMATS_API
110bool sf_subtype_more_than_16_bits(unsigned int format);
111FILE_FORMATS_API
112bool sf_subtype_is_integer(unsigned int format);
113FILE_FORMATS_API
114int sf_subtype_bytes_per_sample(unsigned int format);
115
116FILE_FORMATS_API
119
120FILE_FORMATS_API
122
123wxString sf_normalize_name(const char *name);
124
125
126// This function wrapper uses a mutex to serialize calls to the SndFile library.
127// PRL: Keeping this in a comment, but with Unitary, the only remaining uses
128// of libsndfile should be in import/export and so are on the main thread only
129//extern std::mutex libSndFileMutex;
130
131template<typename R, typename F, typename... Args>
132inline R SFCall(F fun, Args&&... args)
133{
134 //std::lock_guard<std::mutex> guard{ libSndFileMutex };
135 return fun(std::forward<Args>(args)...);
136}
137
138//RAII for SNDFILE*
139struct FILE_FORMATS_API SFFileCloser { int operator () (SNDFILE*) const; };
140struct SFFile : public std::unique_ptr<SNDFILE, ::SFFileCloser>
141{
142 SFFile() = default;
143 SFFile( SFFile &&that )
144 : std::unique_ptr<SNDFILE, ::SFFileCloser>( std::move( that ) )
145 {}
146
147 // Close explicitly, not ignoring return values.
148 int close()
149 {
150 auto result = get_deleter() ( get() );
151 release();
152 return result;
153 }
154};
155
156#endif
FILE_FORMATS_API wxString sf_header_extension(int format)
Get the most common file extension for the given format.
FILE_FORMATS_API unsigned int sf_header_index_to_type(int format_num)
Definition: FileFormats.cpp:54
FILE_FORMATS_API FileExtensions sf_get_all_extensions()
SF_FORMAT_INFO * sf_simple_format(int i)
FILE_FORMATS_API int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:32
FILE_FORMATS_API int sf_subtype_bytes_per_sample(unsigned int format)
FILE_FORMATS_API bool sf_subtype_is_integer(unsigned int format)
FILE_FORMATS_API wxString sf_encoding_index_name(int encoding_num)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:79
FILE_FORMATS_API sampleFormat sf_subtype_to_effective_format(unsigned int format)
Choose the narrowest value in the sampleFormat enumeration for a given libsndfile format.
FILE_FORMATS_API wxString sf_header_name(int format)
Get the string name of the specified container format.
FILE_FORMATS_API wxString sf_header_shortname(int format)
Get an abbreviated form of the string name of the specified format.
FILE_FORMATS_API wxString sf_header_index_name(int format_num)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:42
wxString sf_normalize_name(const char *name)
int sf_num_simple_formats()
FILE_FORMATS_API bool sf_subtype_more_than_16_bits(unsigned int format)
wxString sf_encoding_name(int encoding_num)
Get the string name of the specified data encoding.
FILE_FORMATS_API unsigned int sf_encoding_index_to_subtype(int encoding_num)
Definition: FileFormats.cpp:90
FILE_FORMATS_API int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:70
R SFCall(F fun, Args &&... args)
Definition: FileFormats.h:132
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
wxString name
Definition: TagsEditor.cpp:166
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
STL namespace.
int close()
Definition: FileFormats.h:148
SFFile()=default
SFFile(SFFile &&that)
Definition: FileFormats.h:143