Ardour  9.0-pre0-582-g084a23a80d
mp3fileimportable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2019 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef _ardour_mp3file_importable_source_h_
21 #define _ardour_mp3file_importable_source_h_
22 
23 #include <stdint.h>
24 
26 #include "ardour/types.h"
28 
29 namespace ARDOUR {
30 
31 /* 64bit CPUs always have SSE2, armhf/aarch64 has NEON,
32  * except apple/OSX does not provide immintrin.h
33  */
34 #if defined ( __i386__) || defined (__PPC__) || defined (__APPLE__)
35 #define MINIMP3_NO_SIMD // disable for portability
36 #endif
37 
38 #define MINIMP3_NONSTANDARD_BUT_LOGICAL
39 #define MINIMP3_FLOAT_OUTPUT
40 
41 /* use Ardour namespace for minimp3 symbols */
42 #include "ardour/minimp3.h"
43 
45 public:
46  Mp3FileImportableSource (const std::string& path);
48 
49  /* ImportableSource API */
50  uint32_t channels () const { return _info.channels; }
51  samplecnt_t length () const { return _length; }
52  samplecnt_t samplerate () const { return _info.hz; }
53  samplepos_t natural_position () const { return 0 ; }
54  void seek (samplepos_t pos);
56 
57  bool clamped_at_unity () const { return false; }
58 
59  samplecnt_t layer () const { return _info.layer; }
60  samplecnt_t bitrate () const { return _info.bitrate_kbps; }
62 
63 private:
64  void unmap_mem ();
65  int decode_mp3 (bool parse_only = false);
66 
70 
71  int _fd;
72  const uint8_t* _map_addr;
73  size_t _map_length;
74 
75  const uint8_t* _buffer;
76  size_t _remain;
77 
80  size_t _pcm_off;
81  int _n_frames;
82 };
83 
84 }
85 
86 #endif /* __ardour_mp3file_importable_source_h__ */
int decode_mp3(bool parse_only=false)
void seek(samplepos_t pos)
Mp3FileImportableSource(const std::string &path)
samplecnt_t read_unlocked(Sample *, samplepos_t start, samplecnt_t cnt, uint32_t chn)
samplecnt_t read(Sample *, samplecnt_t nframes)
samplepos_t natural_position() const
#define LIBARDOUR_API
#define MINIMP3_MAX_SAMPLES_PER_FRAME
Definition: minimp3.h:16
int16_t mp3d_sample_t
Definition: minimp3.h:36
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t