libopenmpt  0.3.0-pre.0+r7002
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 
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 
159 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
160 
162 
166 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
167 
168 namespace string {
169 
171 LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version";
173 LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features";
175 LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version";
177 LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build";
179 LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits";
181 LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact";
183 LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license";
184 
186 
214 LIBOPENMPT_CXX_API std::string get( const std::string & key );
215 
216 } // namespace string
217 
219 
222 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
223 
225 
229 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
230 
232 
241 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
242 
243 class module_impl;
244 
245 class module_ext;
246 
247 namespace detail {
248 
249 typedef std::map< std::string, std::string > initial_ctls_map;
250 
251 } // namespace detail
252 
253 class LIBOPENMPT_CXX_API module {
254 
255  friend class module_ext;
256 
257 public:
258 
262 
267  RENDER_MASTERGAIN_MILLIBEL = 1,
269 
274  RENDER_STEREOSEPARATION_PERCENT = 2,
276 
287  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
289 
296  RENDER_VOLUMERAMPING_STRENGTH = 4
297  };
298 
301  command_note = 0,
302  command_instrument = 1,
303  command_volumeffect = 2,
304  command_effect = 3,
305  command_volume = 4,
306  command_parameter = 5
307  };
308 
309 private:
310  module_impl * impl;
311 private:
312  // non-copyable
313  module( const module & );
314  void operator = ( const module & );
315 private:
316  // for module_ext
317  module();
318  void set_impl( module_impl * i );
319 public:
321 
329  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
338  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() );
348  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() );
358  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() );
367  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
377  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
387  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() );
397  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() );
398  virtual ~module();
399 public:
400 
402 
408  void select_subsong( std::int32_t subsong );
410 
417  void set_repeat_count( std::int32_t repeat_count );
419 
426  std::int32_t get_repeat_count() const;
427 
429 
432  double get_duration_seconds() const;
433 
435 
440  double set_position_seconds( double seconds );
442 
446  double get_position_seconds() const;
447 
449 
457  double set_position_order_row( std::int32_t order, std::int32_t row );
458 
460 
467  std::int32_t get_render_param( int param ) const;
469 
476  void set_render_param( int param, std::int32_t value );
477 
479 
491  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
493 
505  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
507 
521  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 );
523 
534  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
536 
548  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
550 
564  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
566 
577  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
579 
590  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
592 
603  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
605 
616  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
619 
624  std::vector<std::string> get_metadata_keys() const;
626 
643  std::string get_metadata( const std::string & key ) const;
644 
646 
649  std::int32_t get_current_speed() const;
651 
654  std::int32_t get_current_tempo() const;
656 
659  std::int32_t get_current_order() const;
661 
664  std::int32_t get_current_pattern() const;
666 
669  std::int32_t get_current_row() const;
671 
674  std::int32_t get_current_playing_channels() const;
675 
677 
682  float get_current_channel_vu_mono( std::int32_t channel ) const;
684 
689  float get_current_channel_vu_left( std::int32_t channel ) const;
691 
696  float get_current_channel_vu_right( std::int32_t channel ) const;
698 
703  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
705 
710  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
711 
713 
717  std::int32_t get_num_subsongs() const;
719 
723  std::int32_t get_num_channels() const;
725 
728  std::int32_t get_num_orders() const;
730 
733  std::int32_t get_num_patterns() const;
735 
738  std::int32_t get_num_instruments() const;
740 
743  std::int32_t get_num_samples() const;
744 
746 
750  std::vector<std::string> get_subsong_names() const;
752 
756  std::vector<std::string> get_channel_names() const;
758 
762  std::vector<std::string> get_order_names() const;
764 
768  std::vector<std::string> get_pattern_names() const;
770 
774  std::vector<std::string> get_instrument_names() const;
776 
780  std::vector<std::string> get_sample_names() const;
781 
783 
787  std::int32_t get_order_pattern( std::int32_t order ) const;
788 
790 
794  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
795 
797 
804  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
805 
807 
815  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
816 
818 
837  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
838 
840 
849  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;
851 
860  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;
861 
863 
882  std::vector<std::string> get_ctls() const;
883 
885 
890  std::string ctl_get( const std::string & ctl ) const;
892 
897  void ctl_set( const std::string & ctl, const std::string & value );
898 
899  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
900 
901 }; // class module
902 
903 } // namespace openmpt
904 
909 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:120
static const char library_version LIBOPENMPT_ATTR_DEPRECATED[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:171
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:260
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.
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:300
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:253
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.