libopenmpt  0.2.7299-autotools
cross-platform C++ and C library to decode tracked music files
libopenmpt.hpp
Go to the documentation of this file.
1 /*
2  * libopenmpt.hpp
3  * --------------
4  * Purpose: libopenmpt public c++ interface
5  * Notes : (currently none)
6  * Authors: OpenMPT Devs
7  * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
8  */
9 
10 #ifndef LIBOPENMPT_HPP
11 #define LIBOPENMPT_HPP
12 
13 #include "libopenmpt_config.h"
14 
15 #include <exception>
16 #include <iosfwd>
17 #include <iostream>
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 #ifndef LIBOPENMPT_QUIRK_NO_CSTDINT
23 #include <cstdint>
24 #else
25 #include <stdint.h>
26 namespace openmpt {
27 namespace std {
28 typedef ::int8_t int8_t;
29 typedef ::int16_t int16_t;
30 typedef ::int32_t int32_t;
31 typedef ::int64_t int64_t;
32 typedef ::uint8_t uint8_t;
33 typedef ::uint16_t uint16_t;
34 typedef ::uint32_t uint32_t;
35 typedef ::uint64_t uint64_t;
36 using namespace ::std;
37 }
38 }
39 #endif
40 
142 namespace openmpt {
143 
144 class LIBOPENMPT_CXX_API exception : public std::exception {
145 private:
146  char * text;
147 public:
148  exception( const std::string & text ) LIBOPENMPT_NOEXCEPT;
149  virtual ~exception() LIBOPENMPT_NOEXCEPT;
150  virtual const char * what() const LIBOPENMPT_NOEXCEPT;
151 }; // class exception
152 
154 
158 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
159 
161 
165 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
166 
167 namespace string {
168 
170 LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version";
172 LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features";
174 LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version";
176 LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build";
178 LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits";
180 LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact";
182 LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license";
183 
185 
204 LIBOPENMPT_CXX_API std::string get( const std::string & key );
205 
206 } // namespace string
207 
209 
212 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
213 
215 
219 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
220 
222 
231 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
232 
233 class module_impl;
234 
235 class module_ext;
236 
237 namespace detail {
238 
239 typedef std::map< std::string, std::string > initial_ctls_map;
240 
241 } // namespace detail
242 
243 class LIBOPENMPT_CXX_API module {
244 
245  friend class module_ext;
246 
247 public:
248 
252 
257  RENDER_MASTERGAIN_MILLIBEL = 1,
259 
264  RENDER_STEREOSEPARATION_PERCENT = 2,
266 
277  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
279 
286  RENDER_VOLUMERAMPING_STRENGTH = 4
287  };
288 
291  command_note = 0,
292  command_instrument = 1,
293  command_volumeffect = 2,
294  command_effect = 3,
295  command_volume = 4,
296  command_parameter = 5
297  };
298 
299 private:
300  module_impl * impl;
301 private:
302  // non-copyable
303  module( const module & );
304  void operator = ( const module & );
305 private:
306  // for module_ext
307  module();
308  void set_impl( module_impl * i );
309 public:
311 
319  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
328  module( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
338  module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
348  module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
357  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
367  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
377  module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
387  module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
388  virtual ~module();
389 public:
390 
392 
398  void select_subsong( std::int32_t subsong );
400 
407  void set_repeat_count( std::int32_t repeat_count );
409 
416  std::int32_t get_repeat_count() const;
417 
419 
422  double get_duration_seconds() const;
423 
425 
430  double set_position_seconds( double seconds );
432 
436  double get_position_seconds() const;
437 
439 
447  double set_position_order_row( std::int32_t order, std::int32_t row );
448 
450 
457  std::int32_t get_render_param( int param ) const;
459 
466  void set_render_param( int param, std::int32_t value );
467 
469 
481  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
483 
495  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
497 
511  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right );
513 
524  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
526 
538  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
540 
554  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
556 
567  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
569 
580  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
582 
593  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
595 
606  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
609 
614  std::vector<std::string> get_metadata_keys() const;
616 
633  std::string get_metadata( const std::string & key ) const;
634 
636 
639  std::int32_t get_current_speed() const;
641 
644  std::int32_t get_current_tempo() const;
646 
649  std::int32_t get_current_order() const;
651 
654  std::int32_t get_current_pattern() const;
656 
659  std::int32_t get_current_row() const;
661 
664  std::int32_t get_current_playing_channels() const;
665 
667 
672  float get_current_channel_vu_mono( std::int32_t channel ) const;
674 
679  float get_current_channel_vu_left( std::int32_t channel ) const;
681 
686  float get_current_channel_vu_right( std::int32_t channel ) const;
688 
693  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
695 
700  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
701 
703 
707  std::int32_t get_num_subsongs() const;
709 
713  std::int32_t get_num_channels() const;
715 
718  std::int32_t get_num_orders() const;
720 
723  std::int32_t get_num_patterns() const;
725 
728  std::int32_t get_num_instruments() const;
730 
733  std::int32_t get_num_samples() const;
734 
736 
740  std::vector<std::string> get_subsong_names() const;
742 
746  std::vector<std::string> get_channel_names() const;
748 
752  std::vector<std::string> get_order_names() const;
754 
758  std::vector<std::string> get_pattern_names() const;
760 
764  std::vector<std::string> get_instrument_names() const;
766 
770  std::vector<std::string> get_sample_names() const;
771 
773 
777  std::int32_t get_order_pattern( std::int32_t order ) const;
778 
780 
784  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
785 
787 
794  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
795 
797 
805  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
806 
808 
827  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
828 
830 
839  std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const;
841 
850  std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const;
851 
853 
872  std::vector<std::string> get_ctls() const;
873 
875 
880  std::string ctl_get( const std::string & ctl ) const;
882 
887  void ctl_set( const std::string & ctl, const std::string & value );
888 
889  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
890 
891 }; // class module
892 
893 } // namespace openmpt
894 
899 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:120
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:290
static const char library_version LIBOPENMPT_ATTR_DEPRECATED[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:170
LIBOPENMPT_CXX_API double could_open_propability(std::istream &stream, double effort=1.0, std::ostream &log=std::clog)
Roughly scan the input stream to find out whether libopenmpt might be able to open it...
STL namespace.
Definition: libopenmpt.hpp:144
LIBOPENMPT_CXX_API std::uint32_t get_core_version()
Get the core version number.
Definition: libopenmpt.hpp:142
LIBOPENMPT_CXX_API std::uint32_t get_library_version()
Get the libopenmpt version number.
LIBOPENMPT_CXX_API bool is_extension_supported(const std::string &extension)
Query whether a file extension is supported.
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:250
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:243
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.