libopenmpt  0.2.5787-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_ANCIENT_COMPILER_STDINT
23 #include <cstdint>
24 #endif
25 
64 namespace openmpt {
65 
66 class LIBOPENMPT_CXX_API exception : public std::exception {
67 private:
68  char * text;
69 public:
70  exception( const std::string & text ) throw();
71  virtual ~exception() throw();
72  virtual const char * what() const throw();
73 }; // class exception
74 
76 
80 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
81 
83 
87 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
88 
89 namespace string {
90 
92 static const char library_version [] = "library_version";
94 static const char library_features[] = "library_features";
96 static const char core_version [] = "core_version";
98 static const char build [] = "build";
100 static const char credits [] = "credits";
102 static const char contact [] = "contact";
104 static const char license [] = "license";
105 
107 
117 LIBOPENMPT_CXX_API std::string get( const std::string & key );
118 
119 } // namespace string
120 
122 
125 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
126 
128 
132 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
133 
135 
141 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
142 
143 class module_impl;
144 
145 class module_ext;
146 
147 namespace detail {
148 
149 typedef std::map< std::string, std::string > initial_ctls_map;
150 
151 } // namespace detail
152 
153 class LIBOPENMPT_CXX_API module {
154 
155  friend class module_ext;
156 
157 public:
158 
162 
167  RENDER_MASTERGAIN_MILLIBEL = 1,
169 
174  RENDER_STEREOSEPARATION_PERCENT = 2,
176 
187  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
189 
196  RENDER_VOLUMERAMPING_STRENGTH = 4
197  };
198 
201  command_note = 0,
202  command_instrument = 1,
203  command_volumeffect = 2,
204  command_effect = 3,
205  command_volume = 4,
206  command_parameter = 5
207  };
208 
209 private:
210  module_impl * impl;
211 private:
212  // non-copyable
213  module( const module & );
214  void operator = ( const module & );
215 private:
216  // for module_ext
217  module();
218  void set_impl( module_impl * i );
219 public:
221 
228  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
236  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() );
245  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() );
254  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() );
262  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
271  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
280  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() );
289  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() );
290  virtual ~module();
291 public:
292 
294 
299  void select_subsong( std::int32_t subsong );
301 
308  void set_repeat_count( std::int32_t repeat_count );
310 
317  std::int32_t get_repeat_count() const;
318 
320 
323  double get_duration_seconds() const;
324 
326 
331  double set_position_seconds( double seconds );
333 
337  double get_position_seconds() const;
338 
340 
348  double set_position_order_row( std::int32_t order, std::int32_t row );
349 
351 
358  std::int32_t get_render_param( int param ) const;
360 
367  void set_render_param( int param, std::int32_t value );
368 
370 
381  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
383 
394  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
396 
409  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 );
411 
421  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
423 
434  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
436 
449  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
451 
461  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
463 
473  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
475 
485  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
487 
497  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
500 
505  std::vector<std::string> get_metadata_keys() const;
507 
524  std::string get_metadata( const std::string & key ) const;
525 
527 
530  std::int32_t get_current_speed() const;
532 
535  std::int32_t get_current_tempo() const;
537 
540  std::int32_t get_current_order() const;
542 
545  std::int32_t get_current_pattern() const;
547 
550  std::int32_t get_current_row() const;
552 
555  std::int32_t get_current_playing_channels() const;
556 
558 
563  float get_current_channel_vu_mono( std::int32_t channel ) const;
565 
570  float get_current_channel_vu_left( std::int32_t channel ) const;
572 
577  float get_current_channel_vu_right( std::int32_t channel ) const;
579 
584  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
586 
591  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
592 
594 
598  std::int32_t get_num_subsongs() const;
600 
603  std::int32_t get_num_channels() const;
605 
608  std::int32_t get_num_orders() const;
610 
613  std::int32_t get_num_patterns() const;
615 
618  std::int32_t get_num_instruments() const;
620 
623  std::int32_t get_num_samples() const;
624 
626 
630  std::vector<std::string> get_subsong_names() const;
632 
636  std::vector<std::string> get_channel_names() const;
638 
642  std::vector<std::string> get_order_names() const;
644 
648  std::vector<std::string> get_pattern_names() const;
650 
654  std::vector<std::string> get_instrument_names() const;
656 
660  std::vector<std::string> get_sample_names() const;
661 
663 
667  std::int32_t get_order_pattern( std::int32_t order ) const;
668 
670 
674  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
675 
677 
684  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
685 
687 
695  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
696 
698 
717  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
718 
720 
729  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;
731 
740  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;
741 
743 
760  std::vector<std::string> get_ctls() const;
761 
763 
768  std::string ctl_get( const std::string & ctl ) const;
770 
775  void ctl_set( const std::string & ctl, const std::string & value );
776 
777  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
778 
779 }; // class module
780 
781 } // namespace openmpt
782 
787 #endif // LIBOPENMPT_HPP
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:200
static const char library_features[]
Return a verbose library features string from openmpt::string::get().
Definition: libopenmpt.hpp:94
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...
static const char build[]
Return information about the current build (e.g. the build date or compiler used) from openmpt::strin...
Definition: libopenmpt.hpp:98
Definition: libopenmpt.hpp:66
static const char core_version[]
Return a verbose OpenMPT core version string from openmpt::string::get().
Definition: libopenmpt.hpp:96
LIBOPENMPT_CXX_API std::uint32_t get_core_version()
Get the core version number.
static const char library_version[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:92
static const char license[]
Return the libopenmpt license from openmpt::string::get().
Definition: libopenmpt.hpp:104
Definition: libopenmpt.hpp:64
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.
static const char credits[]
Return all contributors from openmpt::string::get().
Definition: libopenmpt.hpp:100
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:160
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:153
static const char contact[]
Return contact infromation about libopenmpt from openmpt::string::get().
Definition: libopenmpt.hpp:102
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.