libopenmpt  0.2.6401
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_ANCIENT_COMPILER_STDINT
23 #include <cstdint>
24 #endif
25 
92 namespace openmpt {
93 
94 class LIBOPENMPT_CXX_API exception : public std::exception {
95 private:
96  char * text;
97 public:
98  exception( const std::string & text ) throw();
99  virtual ~exception() throw();
100  virtual const char * what() const throw();
101 }; // class exception
102 
104 
108 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
109 
111 
115 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
116 
117 namespace string {
118 
120 LIBOPENMPT_DEPRECATED static const char library_version [] = "library_version";
122 LIBOPENMPT_DEPRECATED static const char library_features[] = "library_features";
124 LIBOPENMPT_DEPRECATED static const char core_version [] = "core_version";
126 LIBOPENMPT_DEPRECATED static const char build [] = "build";
128 LIBOPENMPT_DEPRECATED static const char credits [] = "credits";
130 LIBOPENMPT_DEPRECATED static const char contact [] = "contact";
132 LIBOPENMPT_DEPRECATED static const char license [] = "license";
133 
135 
154 LIBOPENMPT_CXX_API std::string get( const std::string & key );
155 
156 } // namespace string
157 
159 
162 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
163 
165 
169 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
170 
172 
178 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
179 
180 class module_impl;
181 
182 class module_ext;
183 
184 namespace detail {
185 
186 typedef std::map< std::string, std::string > initial_ctls_map;
187 
188 } // namespace detail
189 
190 class LIBOPENMPT_CXX_API module {
191 
192  friend class module_ext;
193 
194 public:
195 
199 
204  RENDER_MASTERGAIN_MILLIBEL = 1,
206 
211  RENDER_STEREOSEPARATION_PERCENT = 2,
213 
224  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
226 
233  RENDER_VOLUMERAMPING_STRENGTH = 4
234  };
235 
238  command_note = 0,
239  command_instrument = 1,
240  command_volumeffect = 2,
241  command_effect = 3,
242  command_volume = 4,
243  command_parameter = 5
244  };
245 
246 private:
247  module_impl * impl;
248 private:
249  // non-copyable
250  module( const module & );
251  void operator = ( const module & );
252 private:
253  // for module_ext
254  module();
255  void set_impl( module_impl * i );
256 public:
258 
265  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
273  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() );
282  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() );
291  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() );
299  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
308  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
317  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() );
326  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() );
327  virtual ~module();
328 public:
329 
331 
336  void select_subsong( std::int32_t subsong );
338 
345  void set_repeat_count( std::int32_t repeat_count );
347 
354  std::int32_t get_repeat_count() const;
355 
357 
360  double get_duration_seconds() const;
361 
363 
368  double set_position_seconds( double seconds );
370 
374  double get_position_seconds() const;
375 
377 
385  double set_position_order_row( std::int32_t order, std::int32_t row );
386 
388 
395  std::int32_t get_render_param( int param ) const;
397 
404  void set_render_param( int param, std::int32_t value );
405 
407 
418  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
420 
431  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
433 
446  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 );
448 
458  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
460 
471  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
473 
486  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
488 
498  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
500 
510  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
512 
522  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
524 
534  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
537 
542  std::vector<std::string> get_metadata_keys() const;
544 
561  std::string get_metadata( const std::string & key ) const;
562 
564 
567  std::int32_t get_current_speed() const;
569 
572  std::int32_t get_current_tempo() const;
574 
577  std::int32_t get_current_order() const;
579 
582  std::int32_t get_current_pattern() const;
584 
587  std::int32_t get_current_row() const;
589 
592  std::int32_t get_current_playing_channels() const;
593 
595 
600  float get_current_channel_vu_mono( std::int32_t channel ) const;
602 
607  float get_current_channel_vu_left( std::int32_t channel ) const;
609 
614  float get_current_channel_vu_right( std::int32_t channel ) const;
616 
621  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
623 
628  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
629 
631 
635  std::int32_t get_num_subsongs() const;
637 
640  std::int32_t get_num_channels() const;
642 
645  std::int32_t get_num_orders() const;
647 
650  std::int32_t get_num_patterns() const;
652 
655  std::int32_t get_num_instruments() const;
657 
660  std::int32_t get_num_samples() const;
661 
663 
667  std::vector<std::string> get_subsong_names() const;
669 
673  std::vector<std::string> get_channel_names() const;
675 
679  std::vector<std::string> get_order_names() const;
681 
685  std::vector<std::string> get_pattern_names() const;
687 
691  std::vector<std::string> get_instrument_names() const;
693 
697  std::vector<std::string> get_sample_names() const;
698 
700 
704  std::int32_t get_order_pattern( std::int32_t order ) const;
705 
707 
711  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
712 
714 
721  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
722 
724 
732  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
733 
735 
754  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
755 
757 
766  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;
768 
777  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;
778 
780 
798  std::vector<std::string> get_ctls() const;
799 
801 
806  std::string ctl_get( const std::string & ctl ) const;
808 
813  void ctl_set( const std::string & ctl, const std::string & value );
814 
815  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
816 
817 }; // class module
818 
819 } // namespace openmpt
820 
825 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:168
static const char library_features[]
Return a verbose library features string from openmpt::string::get().
Definition: libopenmpt.hpp:122
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...
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:197
static const char build[]
Return information about the current build (e.g. the build date or compiler used) from openmpt::strin...
Definition: libopenmpt.hpp:126
Definition: libopenmpt.hpp:94
static const char core_version[]
Return a verbose OpenMPT core version string from openmpt::string::get().
Definition: libopenmpt.hpp:124
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:120
static const char license[]
Return the libopenmpt license from openmpt::string::get().
Definition: libopenmpt.hpp:132
Definition: libopenmpt.hpp:92
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:128
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:237
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:190
static const char contact[]
Return contact infromation about libopenmpt from openmpt::string::get().
Definition: libopenmpt.hpp:130
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.