libopenmpt  0.3.0-pre.3+r7662
cross-platform C++ and C library to decode tracked music files
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
149 namespace openmpt {
150 
151 class LIBOPENMPT_CXX_API exception : public std::exception {
152 private:
153  char * text;
154 public:
155  exception( const std::string & text ) LIBOPENMPT_NOEXCEPT;
156  virtual ~exception() LIBOPENMPT_NOEXCEPT;
157  virtual const char * what() const LIBOPENMPT_NOEXCEPT;
158 }; // class exception
159 
161 
166 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
167 
169 
173 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
174 
175 namespace string {
176 
178 LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version";
180 LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features";
182 LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version";
184 LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build";
186 LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits";
188 LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact";
190 LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license";
191 
193 
221 LIBOPENMPT_CXX_API std::string get( const std::string & key );
222 
223 } // namespace string
224 
226 
229 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
230 
232 
236 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
237 
239 
249 LIBOPENMPT_CXX_API double could_open_probability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
250 
252 
255 LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API LIBOPENMPT_DEPRECATED double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
256 
257 class module_impl;
258 
259 class module_ext;
260 
261 namespace detail {
262 
263 typedef std::map< std::string, std::string > initial_ctls_map;
264 
265 } // namespace detail
266 
267 class LIBOPENMPT_CXX_API module {
268 
269  friend class module_ext;
270 
271 public:
272 
276 
281  RENDER_MASTERGAIN_MILLIBEL = 1,
283 
288  RENDER_STEREOSEPARATION_PERCENT = 2,
290 
301  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
303 
310  RENDER_VOLUMERAMPING_STRENGTH = 4
311  };
312 
315  command_note = 0,
316  command_instrument = 1,
317  command_volumeffect = 2,
318  command_effect = 3,
319  command_volume = 4,
320  command_parameter = 5
321  };
322 
323 private:
324  module_impl * impl;
325 private:
326  // non-copyable
327  module( const module & );
328  void operator = ( const module & );
329 private:
330  // for module_ext
331  module();
332  void set_impl( module_impl * i );
333 public:
335 
343  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
352  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() );
362  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() );
372  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() );
381  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
391  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
401  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() );
411  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() );
412  virtual ~module();
413 public:
414 
416 
422  void select_subsong( std::int32_t subsong );
424 
429  std::int32_t get_selected_subsong() const;
431 
438  void set_repeat_count( std::int32_t repeat_count );
440 
447  std::int32_t get_repeat_count() const;
448 
450 
453  double get_duration_seconds() const;
454 
456 
461  double set_position_seconds( double seconds );
463 
467  double get_position_seconds() const;
468 
470 
478  double set_position_order_row( std::int32_t order, std::int32_t row );
479 
481 
488  std::int32_t get_render_param( int param ) const;
490 
497  void set_render_param( int param, std::int32_t value );
498 
500 
512  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
514 
526  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
528 
542  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 );
544 
555  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
557 
569  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
571 
585  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
587 
598  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
600 
611  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
613 
624  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
626 
637  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
640 
645  std::vector<std::string> get_metadata_keys() const;
647 
664  std::string get_metadata( const std::string & key ) const;
665 
667 
670  std::int32_t get_current_speed() const;
672 
675  std::int32_t get_current_tempo() const;
677 
680  std::int32_t get_current_order() const;
682 
685  std::int32_t get_current_pattern() const;
687 
690  std::int32_t get_current_row() const;
692 
695  std::int32_t get_current_playing_channels() const;
696 
698 
703  float get_current_channel_vu_mono( std::int32_t channel ) const;
705 
710  float get_current_channel_vu_left( std::int32_t channel ) const;
712 
717  float get_current_channel_vu_right( std::int32_t channel ) const;
719 
724  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
726 
731  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
732 
734 
738  std::int32_t get_num_subsongs() const;
740 
744  std::int32_t get_num_channels() const;
746 
749  std::int32_t get_num_orders() const;
751 
754  std::int32_t get_num_patterns() const;
756 
759  std::int32_t get_num_instruments() const;
761 
764  std::int32_t get_num_samples() const;
765 
767 
771  std::vector<std::string> get_subsong_names() const;
773 
777  std::vector<std::string> get_channel_names() const;
779 
783  std::vector<std::string> get_order_names() const;
785 
789  std::vector<std::string> get_pattern_names() const;
791 
795  std::vector<std::string> get_instrument_names() const;
797 
801  std::vector<std::string> get_sample_names() const;
802 
804 
808  std::int32_t get_order_pattern( std::int32_t order ) const;
809 
811 
815  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
816 
818 
825  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
826 
828 
836  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
837 
839 
858  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
859 
861 
870  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;
872 
881  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;
882 
884 
903  std::vector<std::string> get_ctls() const;
904 
906 
911  std::string ctl_get( const std::string & ctl ) const;
913 
918  void ctl_set( const std::string & ctl, const std::string & value );
919 
920  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
921 
922 }; // class module
923 
924 } // namespace openmpt
925 
930 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:149
static const char library_version LIBOPENMPT_ATTR_DEPRECATED[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:178
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:274
STL namespace.
Definition: libopenmpt.hpp:151
LIBOPENMPT_CXX_API std::uint32_t get_core_version()
Get the core version number.
Definition: libopenmpt.hpp:149
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.
LIBOPENMPT_CXX_API double could_open_probability(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...
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:314
LIBOPENMPT_ATTR_DEPRECATED 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...
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:267
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.