Chris@148
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@148
|
2
|
Chris@148
|
3 /*
|
Chris@148
|
4 Sonic Visualiser
|
Chris@148
|
5 An audio file viewer and annotation editor.
|
Chris@148
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@148
|
7 This file copyright 2006 Chris Cannam.
|
Chris@148
|
8
|
Chris@148
|
9 This program is free software; you can redistribute it and/or
|
Chris@148
|
10 modify it under the terms of the GNU General Public License as
|
Chris@148
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@148
|
12 License, or (at your option) any later version. See the file
|
Chris@148
|
13 COPYING included with this distribution for more information.
|
Chris@148
|
14 */
|
Chris@148
|
15
|
Chris@148
|
16 #ifndef _AUDIO_FILE_READER_FACTORY_H_
|
Chris@148
|
17 #define _AUDIO_FILE_READER_FACTORY_H_
|
Chris@148
|
18
|
Chris@290
|
19 #include <QString>
|
Chris@148
|
20
|
Chris@317
|
21 #include "FileSource.h"
|
Chris@1040
|
22 #include "base/BaseTypes.h"
|
Chris@316
|
23
|
Chris@148
|
24 class AudioFileReader;
|
Chris@392
|
25 class ProgressReporter;
|
Chris@148
|
26
|
Chris@148
|
27 class AudioFileReaderFactory
|
Chris@148
|
28 {
|
Chris@148
|
29 public:
|
Chris@148
|
30 /**
|
Chris@148
|
31 * Return the file extensions that we have audio file readers for,
|
Chris@148
|
32 * in a format suitable for use with QFileDialog. For example,
|
Chris@148
|
33 * "*.wav *.aiff *.ogg".
|
Chris@148
|
34 */
|
Chris@290
|
35 static QString getKnownExtensions();
|
Chris@148
|
36
|
Chris@148
|
37 /**
|
Chris@148
|
38 * Return an audio file reader initialised to the file at the
|
Chris@148
|
39 * given path, or NULL if no suitable reader for this path is
|
Chris@148
|
40 * available or the file cannot be opened.
|
Chris@297
|
41 *
|
Chris@297
|
42 * If targetRate is non-zero, the file will be resampled to that
|
Chris@297
|
43 * rate (transparently). You can query reader->getNativeRate()
|
Chris@297
|
44 * if you want to find out whether the file is being resampled
|
Chris@297
|
45 * or not.
|
Chris@297
|
46 *
|
Chris@920
|
47 * If normalised is true, the file data will be normalised to
|
Chris@920
|
48 * abs(max) == 1.0. Otherwise the file will not be normalised.
|
Chris@920
|
49 *
|
Chris@392
|
50 * If a ProgressReporter is provided, it will be updated with
|
Chris@392
|
51 * progress status. Caller retains ownership of the reporter
|
Chris@392
|
52 * object.
|
Chris@392
|
53 *
|
Chris@148
|
54 * Caller owns the returned object and must delete it after use.
|
Chris@148
|
55 */
|
Chris@327
|
56 static AudioFileReader *createReader(FileSource source,
|
Chris@1040
|
57 sv_samplerate_t targetRate = 0,
|
Chris@920
|
58 bool normalised = false,
|
Chris@392
|
59 ProgressReporter *reporter = 0);
|
Chris@327
|
60
|
Chris@327
|
61 /**
|
Chris@327
|
62 * Return an audio file reader initialised to the file at the
|
Chris@327
|
63 * given path, or NULL if no suitable reader for this path is
|
Chris@327
|
64 * available or the file cannot be opened. If the reader supports
|
Chris@327
|
65 * threaded decoding, it will be used and the file decoded in a
|
Chris@327
|
66 * background thread.
|
Chris@327
|
67 *
|
Chris@327
|
68 * If targetRate is non-zero, the file will be resampled to that
|
Chris@327
|
69 * rate (transparently). You can query reader->getNativeRate()
|
Chris@327
|
70 * if you want to find out whether the file is being resampled
|
Chris@327
|
71 * or not.
|
Chris@327
|
72 *
|
Chris@920
|
73 * If normalised is true, the file data will be normalised to
|
Chris@920
|
74 * abs(max) == 1.0. Otherwise the file will not be normalised.
|
Chris@920
|
75 *
|
Chris@392
|
76 * If a ProgressReporter is provided, it will be updated with
|
Chris@392
|
77 * progress status. This will only be meaningful if threading
|
Chris@392
|
78 * mode is not used because the file reader in use does not
|
Chris@392
|
79 * support it; otherwise progress as reported will jump straight
|
Chris@392
|
80 * to 100% before threading mode takes over. Caller retains
|
Chris@392
|
81 * ownership of the reporter object.
|
Chris@392
|
82 *
|
Chris@327
|
83 * Caller owns the returned object and must delete it after use.
|
Chris@327
|
84 */
|
Chris@327
|
85 static AudioFileReader *createThreadingReader(FileSource source,
|
Chris@1040
|
86 sv_samplerate_t targetRate = 0,
|
Chris@920
|
87 bool normalised = false,
|
Chris@392
|
88 ProgressReporter *reporter = 0);
|
Chris@327
|
89
|
Chris@327
|
90 protected:
|
Chris@327
|
91 static AudioFileReader *create(FileSource source,
|
Chris@1040
|
92 sv_samplerate_t targetRate,
|
Chris@920
|
93 bool normalised,
|
Chris@392
|
94 bool threading,
|
Chris@392
|
95 ProgressReporter *reporter);
|
Chris@148
|
96 };
|
Chris@148
|
97
|
Chris@148
|
98 #endif
|
Chris@148
|
99
|