comparison data/fileio/AudioFileReaderFactory.h @ 1313:ff9697592bef 3.0-integration

Add gapless preference to prefs dialog; much work on audio read tests
author Chris Cannam
date Thu, 01 Dec 2016 17:45:40 +0000
parents 329ddaf7415d
children f8e3dcbafb4d
comparison
equal deleted inserted replaced
1312:079e553dc16e 1313:ff9697592bef
32 * in a format suitable for use with QFileDialog. For example, 32 * in a format suitable for use with QFileDialog. For example,
33 * "*.wav *.aiff *.ogg". 33 * "*.wav *.aiff *.ogg".
34 */ 34 */
35 static QString getKnownExtensions(); 35 static QString getKnownExtensions();
36 36
37 enum class Normalisation {
38
39 /**
40 * Do not normalise file data.
41 */
42 None,
43
44 /**
45 * Normalise file data to abs(max) == 1.0.
46 */
47 Peak
48 };
49
50 enum class GaplessMode {
51
52 /**
53 * Any encoder delay and padding found in file metadata will
54 * be compensated for, giving gapless decoding (assuming the
55 * metadata are correct). This is currently only applicable to
56 * mp3 files: all other supported files are always gapless
57 * where the file metadata provides for it. See documentation
58 * for MP3FileReader::GaplessMode for details of the specific
59 * implementation.
60 */
61 Gapless,
62
63 /**
64 * No delay compensation will happen and the results will be
65 * equivalent to the behaviour of audio readers before the
66 * compensation logic was implemented. This is currently only
67 * applicable to mp3 files: all other supported files are
68 * always gapless where the file metadata provides for it. See
69 * documentation for MP3FileReader::GaplessMode for details of
70 * the specific implementation.
71 */
72 Gappy
73 };
74
75 enum class ThreadingMode {
76
77 /**
78 * Any necessary decoding will happen synchronously when the
79 * reader is created.
80 */
81 NotThreaded,
82
83 /**
84 * If the reader supports threaded decoding, it will be used
85 * and the file will be decoded in a background thread. If the
86 * reader does not support threaded decoding, behaviour will
87 * be as for NotThreaded.
88 */
89 Threaded
90 };
91
92 struct Parameters {
93
94 /**
95 * Sample rate to open the file at. If zero (the default), the
96 * file's native rate will be used. If non-zero, the file will
97 * be automatically resampled to that rate. You can query
98 * reader->getNativeRate() if you want to find out whether the
99 * file needed to be resampled.
100 */
101 sv_samplerate_t targetRate;
102
103 /**
104 * Normalisation to use. The default is Normalisation::None.
105 */
106 Normalisation normalisation;
107
108 /**
109 * Gapless mode to use. The default is GaplessMode::Gapless.
110 */
111 GaplessMode gaplessMode;
112
113 /**
114 * Threading mode. The default is ThreadingMode::NotThreaded.
115 */
116 ThreadingMode threadingMode;
117
118 Parameters() :
119 targetRate(0),
120 normalisation(Normalisation::None),
121 gaplessMode(GaplessMode::Gapless),
122 threadingMode(ThreadingMode::NotThreaded)
123 { }
124 };
125
37 /** 126 /**
38 * Return an audio file reader initialised to the file at the 127 * Return an audio file reader initialised to the file at the
39 * given path, or NULL if no suitable reader for this path is 128 * given path, or NULL if no suitable reader for this path is
40 * available or the file cannot be opened. 129 * available or the file cannot be opened.
41 * 130 *
42 * If targetRate is non-zero, the file will be resampled to that
43 * rate (transparently). You can query reader->getNativeRate()
44 * if you want to find out whether the file is being resampled
45 * or not.
46 *
47 * If normalised is true, the file data will be normalised to
48 * abs(max) == 1.0. Otherwise the file will not be normalised.
49 *
50 * If a ProgressReporter is provided, it will be updated with 131 * If a ProgressReporter is provided, it will be updated with
51 * progress status. Caller retains ownership of the reporter 132 * progress status. This will only be meaningful if decoding is
52 * object. 133 * being carried out in non-threaded mode (either because the
134 * threaded parameter was not supplied or because the specific
135 * file reader used does not support it); in threaded mode,
136 * reported progress will jump straight to 100% before threading
137 * takes over. Caller retains ownership of the reporter object.
53 * 138 *
54 * Caller owns the returned object and must delete it after use. 139 * Caller owns the returned object and must delete it after use.
55 */ 140 */
56 static AudioFileReader *createReader(FileSource source, 141 static AudioFileReader *createReader(FileSource source,
57 sv_samplerate_t targetRate = 0, 142 Parameters parameters,
58 bool normalised = false,
59 ProgressReporter *reporter = 0); 143 ProgressReporter *reporter = 0);
60
61 /**
62 * Return an audio file reader initialised to the file at the
63 * given path, or NULL if no suitable reader for this path is
64 * available or the file cannot be opened. If the reader supports
65 * threaded decoding, it will be used and the file decoded in a
66 * background thread.
67 *
68 * If targetRate is non-zero, the file will be resampled to that
69 * rate (transparently). You can query reader->getNativeRate()
70 * if you want to find out whether the file is being resampled
71 * or not.
72 *
73 * If normalised is true, the file data will be normalised to
74 * abs(max) == 1.0. Otherwise the file will not be normalised.
75 *
76 * If a ProgressReporter is provided, it will be updated with
77 * progress status. This will only be meaningful if threading
78 * mode is not used because the file reader in use does not
79 * support it; otherwise progress as reported will jump straight
80 * to 100% before threading mode takes over. Caller retains
81 * ownership of the reporter object.
82 *
83 * Caller owns the returned object and must delete it after use.
84 */
85 static AudioFileReader *createThreadingReader(FileSource source,
86 sv_samplerate_t targetRate = 0,
87 bool normalised = false,
88 ProgressReporter *reporter = 0);
89
90 protected:
91 static AudioFileReader *create(FileSource source,
92 sv_samplerate_t targetRate,
93 bool normalised,
94 bool threading,
95 ProgressReporter *reporter);
96 }; 144 };
97 145
98 #endif 146 #endif
99 147