comparison data/fileio/MP3FileReader.h @ 1305:9f9f55a8af92 mp3-gapless

Add gapless flag to MP3FileReader, and implement trimming the delay samples from the start (padding is not yet trimmed from end)
author Chris Cannam
date Tue, 29 Nov 2016 11:35:56 +0000
parents fa574c909c3d
children aa1b1fc2d018
comparison
equal deleted inserted replaced
1304:7cff8367d9b1 1305:9f9f55a8af92
30 class MP3FileReader : public CodedAudioFileReader 30 class MP3FileReader : public CodedAudioFileReader
31 { 31 {
32 Q_OBJECT 32 Q_OBJECT
33 33
34 public: 34 public:
35 /**
36 * How the MP3FileReader should handle leading and trailing gaps.
37 * See http://lame.sourceforge.net/tech-FAQ.txt for a technical
38 * explanation of the numbers here.
39 */
40 enum GaplessMode {
41 /**
42 * Trim unwanted samples from the start and end of the decoded
43 * audio. From the start, trim a number of samples equal to
44 * the decoder delay (a fixed 529 samples) plus any encoder
45 * delay that may be specified in Xing/LAME metadata. From the
46 * end, trim any padding specified in Xing/LAME metadata, less
47 * the fixed decoder delay. This usually results in "gapless"
48 * audio, i.e. with no spurious zero padding at either end.
49 */
50 Gapless,
51
52 /**
53 * Do not trim any samples. Also do not suppress any frames
54 * from being passed to the mp3 decoder, even Xing/LAME
55 * metadata frames. This will result in the audio being padded
56 * with zeros at either end: at the start, typically
57 * 529+576+1152 = 2257 samples for LAME-encoded mp3s; at the
58 * end an unknown number depending on the fill ratio of the
59 * final coded frame, but typically less than 1152-529 = 623.
60 *
61 * This mode produces the same output as produced by older
62 * versions of this code before the gapless option was added,
63 * and is present mostly for backward compatibility.
64 */
65 Gappy
66 };
67
35 MP3FileReader(FileSource source, 68 MP3FileReader(FileSource source,
36 DecodeMode decodeMode, 69 DecodeMode decodeMode,
37 CacheMode cacheMode, 70 CacheMode cacheMode,
71 GaplessMode gaplessMode,
38 sv_samplerate_t targetRate = 0, 72 sv_samplerate_t targetRate = 0,
39 bool normalised = false, 73 bool normalised = false,
40 ProgressReporter *reporter = 0); 74 ProgressReporter *reporter = 0);
41 virtual ~MP3FileReader(); 75 virtual ~MP3FileReader();
42 76
66 QString m_path; 100 QString m_path;
67 QString m_error; 101 QString m_error;
68 QString m_title; 102 QString m_title;
69 QString m_maker; 103 QString m_maker;
70 TagMap m_tags; 104 TagMap m_tags;
105 GaplessMode m_gaplessMode;
71 sv_frame_t m_fileSize; 106 sv_frame_t m_fileSize;
72 double m_bitrateNum; 107 double m_bitrateNum;
73 int m_bitrateDenom; 108 int m_bitrateDenom;
74 int m_mp3FrameCount; 109 int m_mp3FrameCount;
75 int m_completion; 110 int m_completion;